mirror of
https://github.com/Wessel/Roommapper.git
synced 2026-07-21 23:37:11 +02:00
Add CPP to RoutePlan
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,25 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\tosl1\\source\\repos\\Roommapper\\src\\Client\\Mapper\\",
|
||||
"Documents": [],
|
||||
"WorkspaceRootPath": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\Mapper\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{52F1797E-0731-43F4-AC45-68B7CF563336}|Mapper.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\mapper\\map.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{52F1797E-0731-43F4-AC45-68B7CF563336}|Mapper.csproj|solutionrelative:map.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{A753DACA-164C-417C-8AFD-D53AB375A53D}|..\\RobotController\\RobotController.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\robotcontroller\\ultrasonic.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{A753DACA-164C-417C-8AFD-D53AB375A53D}|..\\RobotController\\RobotController.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\robotcontroller\\measurement.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{3848B011-EF47-4B92-A214-69D439583C52}|..\\..\\CoveragePathPlanner\\CoveragePathPlanner.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\coveragepathplanner\\coveragepathplanner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{52F1797E-0731-43F4-AC45-68B7CF563336}|Mapper.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\mapper\\mapper.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
|
||||
"RelativeMoniker": "D:0:0:{52F1797E-0731-43F4-AC45-68B7CF563336}|Mapper.csproj|solutionrelative:mapper.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
@@ -9,11 +27,76 @@
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": -1,
|
||||
"SelectedChildIndex": 5,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Ultrasonic.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Ultrasonic.cs",
|
||||
"RelativeDocumentMoniker": "..\\RobotController\\Ultrasonic.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Ultrasonic.cs",
|
||||
"RelativeToolTip": "..\\RobotController\\Ultrasonic.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-09T17:38:23.66Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "Measurement.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Measurement.cs",
|
||||
"RelativeDocumentMoniker": "..\\RobotController\\Measurement.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Measurement.cs",
|
||||
"RelativeToolTip": "..\\RobotController\\Measurement.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAABYAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-09T17:35:55.332Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "CoveragePathPlanner.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\CoveragePathPlanner\\CoveragePathPlanner.cs",
|
||||
"RelativeDocumentMoniker": "..\\..\\CoveragePathPlanner\\CoveragePathPlanner.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\CoveragePathPlanner\\CoveragePathPlanner.cs",
|
||||
"RelativeToolTip": "..\\..\\CoveragePathPlanner\\CoveragePathPlanner.cs",
|
||||
"ViewState": "AQIAAHoAAAAAAAAAAAAAwIYAAAAQAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-09T17:34:13.83Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 4,
|
||||
"Title": "Mapper",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\Source\\Repos\\Roommapper\\src\\Client\\Mapper\\Mapper.csproj",
|
||||
"RelativeDocumentMoniker": "Mapper.csproj",
|
||||
"ToolTip": "C:\\Users\\Tom\\Source\\Repos\\Roommapper\\src\\Client\\Mapper\\Mapper.csproj",
|
||||
"RelativeToolTip": "Mapper.csproj",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
|
||||
"WhenOpened": "2024-06-09T17:33:28.667Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Map.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\Mapper\\Map.cs",
|
||||
"RelativeDocumentMoniker": "Map.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\Mapper\\Map.cs",
|
||||
"RelativeToolTip": "Map.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAABcAAAAcAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-09T17:33:29.25Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
BIN
src/Client/Mapper/.vs/ProjectEvaluation/mapper.metadata.v7.bin
Normal file
BIN
src/Client/Mapper/.vs/ProjectEvaluation/mapper.metadata.v7.bin
Normal file
Binary file not shown.
BIN
src/Client/Mapper/.vs/ProjectEvaluation/mapper.projects.v7.bin
Normal file
BIN
src/Client/Mapper/.vs/ProjectEvaluation/mapper.projects.v7.bin
Normal file
Binary file not shown.
@@ -5,28 +5,6 @@ namespace Mapper
|
||||
{
|
||||
public class Map
|
||||
{
|
||||
private Coordinate bottomLeft, bottomRight;
|
||||
|
||||
public Map(Coordinate bottomLeft, Coordinate bottomRight)
|
||||
{
|
||||
this.bottomLeft = bottomLeft;
|
||||
this.bottomRight = bottomRight;
|
||||
Console.Write(testPathPlanner);
|
||||
}
|
||||
|
||||
public List<Point> testPathPlanner()
|
||||
{
|
||||
CoveragePathPlanner planner = new CoveragePathPlanner(500, 500);
|
||||
|
||||
List<Obstacle> obstacles = new List<Obstacle>
|
||||
{
|
||||
new Obstacle { X = 100, Y = 100, Width = 50, Height = 50 },
|
||||
new Obstacle { X = 200, Y = 200, Width = 100, Height = 100 },
|
||||
new Obstacle { X = 300, Y = 300, Width = 150, Height = 150 }
|
||||
};
|
||||
|
||||
return planner.PlanPath(obstacles);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,24 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\tosl1\\source\\repos\\Roommapper\\src\\Client\\RobotController\\",
|
||||
"Documents": [],
|
||||
"WorkspaceRootPath": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\robotcontroller\\ultrasonic.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|solutionrelative:ultrasonic.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\robotcontroller\\coordinate.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|solutionrelative:coordinate.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\robotcontroller\\measurement.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|solutionrelative:measurement.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\client\\robotcontroller\\gyrosensor.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{8962460F-9112-4A79-9B40-35CA420C98C6}|RobotController.csproj|solutionrelative:gyrosensor.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
@@ -9,11 +26,63 @@
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": -1,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Ultrasonic.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Ultrasonic.cs",
|
||||
"RelativeDocumentMoniker": "Ultrasonic.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Ultrasonic.cs",
|
||||
"RelativeToolTip": "Ultrasonic.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA0AAAAfAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-13T19:25:01.727Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Coordinate.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Coordinate.cs",
|
||||
"RelativeDocumentMoniker": "Coordinate.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Coordinate.cs",
|
||||
"RelativeToolTip": "Coordinate.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAABIAAAAFAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-13T20:22:20.968Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"Title": "GyroSensor.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\GyroSensor.cs",
|
||||
"RelativeDocumentMoniker": "GyroSensor.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\GyroSensor.cs",
|
||||
"RelativeToolTip": "GyroSensor.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-13T20:22:19.326Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "Measurement.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Measurement.cs",
|
||||
"RelativeDocumentMoniker": "Measurement.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\Client\\RobotController\\Measurement.cs",
|
||||
"RelativeToolTip": "Measurement.cs",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAqwBMAAAAFAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-09T17:39:17.31Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/CoveragePathPlanner/.vs/CoveragePathPlanner/v17/.suo
Normal file
BIN
src/CoveragePathPlanner/.vs/CoveragePathPlanner/v17/.suo
Normal file
Binary file not shown.
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\CoveragePathPlanner\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{19337BCA-6374-4DAE-90D4-38CF1D236D30}|CoveragePathPlanner.csproj|c:\\users\\tom\\source\\repos\\roommapper\\src\\coveragepathplanner\\coveragepathplanner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{19337BCA-6374-4DAE-90D4-38CF1D236D30}|CoveragePathPlanner.csproj|solutionrelative:coveragepathplanner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "CoveragePathPlanner.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\CoveragePathPlanner\\CoveragePathPlanner.cs",
|
||||
"RelativeDocumentMoniker": "CoveragePathPlanner.cs",
|
||||
"ToolTip": "C:\\Users\\Tom\\source\\repos\\Roommapper\\src\\CoveragePathPlanner\\CoveragePathPlanner.cs",
|
||||
"RelativeToolTip": "CoveragePathPlanner.cs",
|
||||
"ViewState": "AQIAAGMAAAAAAAAAAAA3wA0AAAAeAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-06-09T17:04:53.416Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
public class CoveragePathPlanner
|
||||
@@ -6,12 +7,14 @@ public class CoveragePathPlanner
|
||||
private int _width;
|
||||
private int _height;
|
||||
private List<Cell> _cells;
|
||||
private List<Obstacle> _obstacles;
|
||||
|
||||
public CoveragePathPlanner(int width, int height)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
_cells = new List<Cell>();
|
||||
_obstacles = new List<Obstacle>();
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
@@ -22,16 +25,36 @@ public class CoveragePathPlanner
|
||||
}
|
||||
}
|
||||
|
||||
public List<Point> PlanPath(List<Obstacle> obstacles)
|
||||
public void AddObstacleRectangle(int x, int y, int width, int height)
|
||||
{
|
||||
_obstacles.Add(new Obstacle { X = x, Y = y, Width = width, Height = height, IsRectangle = true });
|
||||
}
|
||||
|
||||
public void AddObstacleCell(int x, int y)
|
||||
{
|
||||
_obstacles.Add(new Obstacle { X = x, Y = y, Width = 0, Height = 0, IsRectangle = false });
|
||||
}
|
||||
|
||||
public List<Point> PlanPath()
|
||||
{
|
||||
// Add obstacles to the grid
|
||||
foreach (Obstacle obstacle in obstacles)
|
||||
foreach (Obstacle obstacle in _obstacles)
|
||||
{
|
||||
foreach (Cell cell in _cells)
|
||||
{
|
||||
if (cell.IsWithinObstacle(obstacle))
|
||||
if (obstacle.IsRectangle)
|
||||
{
|
||||
cell.IsObstacle = true;
|
||||
if (cell.IsWithinObstacle(obstacle))
|
||||
{
|
||||
cell.IsObstacle = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cell.X == obstacle.X && cell.Y == obstacle.Y)
|
||||
{
|
||||
cell.IsObstacle = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +79,7 @@ public class CoveragePathPlanner
|
||||
while (currentCell != null)
|
||||
{
|
||||
path.Add(new Point(currentCell.X, currentCell.Y));
|
||||
currentCell = currentCell.Parent;
|
||||
currentCell = currentCell.Parent!;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
@@ -92,6 +115,7 @@ public class Obstacle
|
||||
public int Y { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public bool IsRectangle { get; set; }
|
||||
}
|
||||
|
||||
public class Cell
|
||||
@@ -101,7 +125,7 @@ public class Cell
|
||||
public bool IsObstacle { get; set; }
|
||||
public bool IsVisited { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public Cell Parent { get; set; }
|
||||
public Cell? Parent { get; set; }
|
||||
|
||||
public bool IsWithinObstacle(Obstacle obstacle)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CoveragePathPlanner\CoveragePathPlanner.csproj" />
|
||||
<ProjectReference Include="..\LibParse\LibParse.csproj" />
|
||||
<ProjectReference Include="..\LibServer\LibServer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,7 +2,9 @@ using Cassandra;
|
||||
using LibParse.Json;
|
||||
using LibServer.Http;
|
||||
using LibServer.Router;
|
||||
using Newtonsoft.Json;
|
||||
using RobotControlServer.JsonClasses;
|
||||
using System.Drawing;
|
||||
|
||||
namespace RobotControlServer.Routes;
|
||||
|
||||
@@ -21,8 +23,19 @@ public class RoutePlan: IRoute {
|
||||
}
|
||||
|
||||
// ParsedBody?.objects = [[0,1],[0,2],...]
|
||||
// Implement path planning algorithm
|
||||
// var path;
|
||||
|
||||
// New instance of CPP with a 500x500 grid || where 0,0 = top-left and 499, 499 = bottom-right
|
||||
CoveragePathPlanner planner = new CoveragePathPlanner(500, 500);
|
||||
|
||||
// Add obstacles cell by cell
|
||||
foreach (var obj in parsedBody?.objects)
|
||||
{
|
||||
planner.AddObstacleCell(obj[0], obj[1]);
|
||||
}
|
||||
|
||||
List<Point> PlanPath = planner.PlanPath();
|
||||
// Don't know if this is needed here or just do List<Point> path = planner.PlanPath(obstacles);?
|
||||
string path = JsonConvert.SerializeObject(PlanPath);
|
||||
|
||||
// Return success message with the path
|
||||
return new HttpResponse($"{{\"message\":\"success\",\"path\":\"{path}\"}}");
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user