-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Galactic code review #29
Changes from 7 commits
b47bc13
5abd2dc
ea7caac
25fcd01
6c6a686
1317919
406ce4a
6353245
a343360
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,18 +46,11 @@ namespace full_coverage_path_planner | |
|
||
// create a message for the plan | ||
nav_msgs::msg::Path gui_path; | ||
gui_path.poses.resize(path.size()); | ||
|
||
if (!path.empty()) | ||
{ | ||
gui_path.header.frame_id = path[0].header.frame_id; | ||
gui_path.header.stamp = path[0].header.stamp; | ||
} | ||
|
||
// Extract the plan in world co-ordinates, we assume the path is all in the same frame | ||
for (unsigned int i = 0; i < path.size(); i++) | ||
gui_path.header.frame_id = path[0].header.frame_id; | ||
gui_path.header.stamp = path[0].header.stamp; | ||
for (const auto pose : path) | ||
{ | ||
gui_path.poses[i] = path[i]; | ||
gui_path.poses.push_back(pose); | ||
} | ||
|
||
plan_pub_->publish(gui_path); | ||
|
@@ -69,9 +62,8 @@ namespace full_coverage_path_planner | |
{ | ||
geometry_msgs::msg::PoseStamped new_goal; | ||
std::list<Point_t>::const_iterator it, it_next, it_prev; | ||
int dx_now, dy_now, dx_next, dy_next, move_dir_now = 0, move_dir_next = 0; | ||
bool do_publish = false; | ||
float orientation = eDirNone; | ||
float orientation = dir::none; | ||
RCLCPP_INFO(rclcpp::get_logger("FullCoveragePathPlanner"), "Received goalpoints with length: %lu", goalpoints.size()); | ||
if (goalpoints.size() > 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate more on your previous comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! Early-outs make the code more readable by handling the exceptions in a short block at the top.
Can be replaced by:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here it looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it... in our case the function does not return right after the else condition, so we can not early-out. I can switch the order to at least show the especial case first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aaah, I thought it did! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a similar note. I think the node dies if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep.. will add that one |
||
{ | ||
|
@@ -82,6 +74,10 @@ namespace full_coverage_path_planner | |
it_prev = it; | ||
it_prev--; | ||
|
||
int dx_now; | ||
int dy_now; | ||
int dx_next; | ||
int dy_next; | ||
// Check for the direction of movement | ||
if (it == goalpoints.begin()) | ||
{ | ||
|
@@ -102,8 +98,8 @@ namespace full_coverage_path_planner | |
// 0 + 1*2 = 2 | ||
// -1 + 0*2 = -1 | ||
// 0 + -1*2 = -2 | ||
move_dir_now = dx_now + dy_now * 2; | ||
move_dir_next = dx_next + dy_next * 2; | ||
int move_dir_now = dx_now + dy_now * 2; | ||
int move_dir_next = dx_next + dy_next * 2; | ||
|
||
// Check if this points needs to be published (i.e. a change of direction or first or last point in list) | ||
do_publish = move_dir_next != move_dir_now || it == goalpoints.begin() || | ||
|
@@ -118,19 +114,19 @@ namespace full_coverage_path_planner | |
// Calculate desired orientation to be in line with movement direction | ||
switch (move_dir_now) | ||
{ | ||
case eDirNone: | ||
case dir::none: | ||
// Keep orientation | ||
break; | ||
case eDirRight: | ||
case dir::right: | ||
orientation = 0; | ||
break; | ||
case eDirUp: | ||
case dir::up: | ||
orientation = M_PI / 2; | ||
break; | ||
case eDirLeft: | ||
case dir::left: | ||
orientation = M_PI; | ||
break; | ||
case eDirDown: | ||
case dir::down: | ||
orientation = M_PI * 1.5; | ||
break; | ||
} | ||
|
@@ -191,8 +187,6 @@ namespace full_coverage_path_planner | |
geometry_msgs::msg::PoseStamped const &realStart, | ||
Point_t &scaledStart) | ||
{ | ||
size_t ix; | ||
size_t iy; | ||
size_t nodeRow; | ||
size_t nodeColl; | ||
size_t nodeSize = dmax(floor(toolRadius / cpp_costmap->getResolution()), 1); // Size of node in pixels/units | ||
|
@@ -217,18 +211,18 @@ namespace full_coverage_path_planner | |
floor(cpp_costmap->getSizeInCellsY() / tile_size_))); | ||
|
||
// Scale grid | ||
for (iy = 0; iy < nRows; iy = iy + nodeSize) | ||
for (size_t iy = 0; iy < nRows; iy = iy + nodeSize) | ||
{ | ||
std::vector<bool> gridRow; | ||
for (ix = 0; ix < nCols; ix = ix + nodeSize) | ||
for (size_t ix = 0; ix < nCols; ix = ix + nodeSize) | ||
{ | ||
bool nodeOccupied = false; | ||
for (nodeRow = 0; (nodeRow < robotNodeSize) && ((iy + nodeRow) < nRows) && (nodeOccupied == false); ++nodeRow) | ||
{ | ||
for (nodeColl = 0; (nodeColl < robotNodeSize) && ((ix + nodeColl) < nCols); ++nodeColl) | ||
{ | ||
int index_grid = dmax((iy + nodeRow - ceil(static_cast<float>(robotNodeSize - nodeSize) / 2.0)) * nCols + (ix + nodeColl - ceil(static_cast<float>(robotNodeSize - nodeSize) / 2.0)), 0); | ||
if (cpp_costmap_data[index_grid] > 65) | ||
if (cpp_costmap_data[index_grid] > COVERAGE_COST) | ||
{ | ||
nodeOccupied = true; | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum class dir