An class to compute the coverage path based on a minimum-spanning-tree (MST). More...
#include <mst_path.h>
Public Member Functions | |
bool | generate_path (geometry_msgs::Point start) |
Generate all way points for the path. More... | |
nav_msgs::Path | get_path () |
Get the complete path. More... | |
geometry_msgs::Point | get_waypoint (geometry_msgs::Point position, double tolerance) |
Get the current waypoint and possibly select next waypoint, if close enough. More... | |
void | initialize_graph (nav_msgs::OccupancyGrid gridmap, bool vertical=false, bool connect4=true) |
Initialize the internal graph structure that represents the area division. More... | |
void | initialize_map (geometry_msgs::Point origin, double rotation, double width, double height) |
Initialize properties of the area to be covered. More... | |
void | initialize_tree (vector< edge > mst) |
Remove edges of the graph that overlap with the tree. More... | |
mst_path () | |
Constructor. More... | |
void | reduce () |
Remove waypoints that are within straight line segments of the path. Only keep turning points of the path. More... | |
bool | valid () |
Check whether the current waypoint index is valid. More... | |
Private Member Functions | |
void | add_edge (int from, int to, int cost) |
Add an edge to the tree graph. More... | |
double | dist (geometry_msgs::Point p1, geometry_msgs::Point p2) |
Calculate the distance between two points. More... | |
geometry_msgs::Point | get_wp (int offset=0) |
Get the current way point. More... | |
void | remove_edge (edge e) |
Remove an edge from the tree graph. More... | |
Private Attributes | |
unordered_set< edge, hash_edge > | edges |
Priority queue of edge objects sorted by cost. More... | |
double | height |
Height of the area to cover. More... | |
nav_msgs::OccupancyGrid | map |
The grid map that needs to be covered by the MST path. More... | |
vector< unordered_set< int > > | nodes |
The sets of connected vertices. More... | |
geometry_msgs::Point | origin |
Coordinate of the bottom left bounding point of the area. More... | |
deque< geometry_msgs::Point > | path |
The boustrophedon path. More... | |
double | rotation |
The rotation of the map. More... | |
bool | vertical |
Whether the sweeping pattern is vertical or horizontal. More... | |
double | width |
Width of the area to cover. More... | |
int | wp |
The current way point. More... | |
An class to compute the coverage path based on a minimum-spanning-tree (MST).
Definition at line 22 of file mst_path.h.
mst_path::mst_path | ( | ) |
Constructor.
Definition at line 3 of file mst_path.cpp.
|
private |
Add an edge to the tree graph.
from | The starting vertex. |
to | The ending vertex. |
cost | The cost of the edge. |
Definition at line 269 of file mst_path.cpp.
|
private |
Calculate the distance between two points.
p1 | The first point. |
p2 | The second point. |
Definition at line 280 of file mst_path.cpp.
bool mst_path::generate_path | ( | geometry_msgs::Point | start | ) |
Generate all way points for the path.
start | The current position of the CPS. |
Definition at line 7 of file mst_path.cpp.
nav_msgs::Path mst_path::get_path | ( | ) |
Get the complete path.
Definition at line 101 of file mst_path.cpp.
geometry_msgs::Point mst_path::get_waypoint | ( | geometry_msgs::Point | position, |
double | tolerance | ||
) |
Get the current waypoint and possibly select next waypoint, if close enough.
position | The current position of the CPS. |
tolerance | The distance to the current waypoint below which the next waypoint is selected. |
Definition at line 123 of file mst_path.cpp.
|
private |
Get the current way point.
offset | The index offset to the current waypoint. |
Definition at line 285 of file mst_path.cpp.
void mst_path::initialize_graph | ( | nav_msgs::OccupancyGrid | gridmap, |
bool | vertical = false , |
||
bool | connect4 = true |
||
) |
Initialize the internal graph structure that represents the area division.
graph | gridmap The grid map for which the paths are generated. |
vertical | Whether the sweeping pattern is vertical or horizontal. Default horizontal. |
connect4 | Whether only the von Neumann neighborhood is considered. Default true. |
Definition at line 139 of file mst_path.cpp.
void mst_path::initialize_map | ( | geometry_msgs::Point | origin, |
double | rotation, | ||
double | width, | ||
double | height | ||
) |
Initialize properties of the area to be covered.
origin | Coordinate of the bottom left point of the area. |
rotation | The angle by which the map has been rotated. |
width | The width of the area. |
height | The height of the area. |
Definition at line 201 of file mst_path.cpp.
void mst_path::initialize_tree | ( | vector< edge > | mst | ) |
Remove edges of the graph that overlap with the tree.
mst | The edges that define the tree. |
Definition at line 216 of file mst_path.cpp.
void mst_path::reduce | ( | ) |
Remove waypoints that are within straight line segments of the path. Only keep turning points of the path.
Definition at line 243 of file mst_path.cpp.
|
private |
Remove an edge from the tree graph.
e | The edge to remove. |
Definition at line 302 of file mst_path.cpp.
bool mst_path::valid | ( | ) |
Check whether the current waypoint index is valid.
Definition at line 264 of file mst_path.cpp.
Priority queue of edge objects sorted by cost.
Definition at line 123 of file mst_path.h.
|
private |
Height of the area to cover.
Definition at line 158 of file mst_path.h.
|
private |
The grid map that needs to be covered by the MST path.
Definition at line 133 of file mst_path.h.
|
private |
The sets of connected vertices.
Definition at line 128 of file mst_path.h.
|
private |
Coordinate of the bottom left bounding point of the area.
Definition at line 143 of file mst_path.h.
|
private |
The boustrophedon path.
Definition at line 118 of file mst_path.h.
|
private |
The rotation of the map.
Definition at line 148 of file mst_path.h.
|
private |
Whether the sweeping pattern is vertical or horizontal.
Definition at line 163 of file mst_path.h.
|
private |
Width of the area to cover.
Definition at line 153 of file mst_path.h.
|
private |
The current way point.
Definition at line 138 of file mst_path.h.