-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Update obstacle layer usage of max ranges #5697
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
base: main
Are you sure you want to change the base?
Update obstacle layer usage of max ranges #5697
Conversation
845dced to
be10620
Compare
|
@sd-kudan, your PR has failed to build. Please check CI outputs and resolve issues. |
|
Can you rebase / pull in main (we squash merge anyways) to get CI to turn over? I want to see the tests pass before I dig in. I'm going to need to really dive into code surrounding this for a full review since its a big change with subtle potential issues, so before I do that I want to make sure automated testing doesn't already flag issues that makes my time unnecessary :-) |
Signed-off-by: Simon Dathan <simon.dathan@kudan.eu>
Signed-off-by: Simon Dathan <simon.dathan@kudan.eu>
Signed-off-by: Simon Dathan <simon.dathan@kudan.eu>
Signed-off-by: Simon Dathan <simon.dathan@kudan.eu>
be10620 to
cea3222
Compare
| unsigned int origin_cell_x; | ||
| unsigned int origin_cell_y; | ||
| worldToMap(obs.origin_.x, obs.origin_.y, origin_cell_x, origin_cell_y); | ||
| unsigned int point_cell_x; | ||
| unsigned int point_cell_y; | ||
| worldToMap(px, py, point_cell_x, point_cell_y); | ||
| int delta_x = point_cell_x - origin_cell_x; | ||
| int delta_y = point_cell_y - origin_cell_y; | ||
| unsigned int max_delta = std::max(std::abs(delta_x), std::abs(delta_y)); |
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.
This needs to compute the L2 distance (squared or unsquared) - just takign the maximum of X or Y is not a valid distance calculation for range. I think you're misunderstanding the raytraceLine / bresenham2D algorithm. We are marching in the X or Y direction but we do so scaled from the total length to march the L2 distance.
I think essentially the previous calculation should remain, but based on cell length rather than world coordinates.
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.
Thanks for taking a look - have updated to use squared distance.
| // Calculate the distance to the endpoint in cells to limit the maximum length of the raytrace | ||
| // and avoid clearing the endpoint cell. | ||
| int delta_x = x1 - x0; | ||
| int delta_y = y1 - y0; | ||
| unsigned int cell_dist_to_endpoint = std::max(std::abs(delta_x), std::abs(delta_y)); | ||
| if (cell_dist_to_endpoint < 1) { | ||
| continue; | ||
| } | ||
| cell_raytrace_max_range = std::min(cell_raytrace_max_range, cell_dist_to_endpoint - 1); |
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.
All marking is done after all clearing, so this shouldn't be necessary.
navigation2/nav2_costmap_2d/plugins/obstacle_layer.cpp
Lines 520 to 526 in cea3222
| for (const auto & clearing_observation : clearing_observations) { | |
| raytraceFreespace(*clearing_observation, min_x, min_y, max_x, max_y); | |
| } | |
| // place the new obstacles into a priority queue... each with a priority of zero to begin with | |
| for (const auto & observation : observations) { | |
| const Observation & obs = *observation; |
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.
This allows setting raytrace_max_range > obstacle_max_range which can help clear obstacles which are moving away from the sensor, without clearing stationary obstacles while moving away from them for example.
Signed-off-by: Simon Dathan <simon.dathan@kudan.eu>
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Basic Info
Description of contribution in a few bullet points
To address issue reported in #5476 of obstacles being cleared when reversing away from them, the following changes are made:
obstacle_max_rangeis done in grid cell space for consistency with the ray tracing free space check againstraytrace_max_rangeraytrace_max_range > obstacle_max_rangeDescription of documentation updates required from your changes
Description of how this change was tested
Demo
Before:
obstacle_layer_clearing.mp4
After:
obstacle_layer.mp4
Future work that may be required in bullet points
For Maintainers:
backport-*.