-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Path distance feature #5387
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?
Path distance feature #5387
Conversation
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
Great - so after these changes this should be usable to find the closest point on the path. Can you identify the places in the codebase today we check for such things (controller plugins, progress checkers, BT navigators, etc) and how we might use this utility? That seems like the next logical step to me.
Then, expose that feedback to the controller server, a new bt node to use this as well. Once all that is in place, the controller critics for MPPI/DWB would round it all off!
nav2_util/src/path_utils.cpp
Outdated
result.distance = std::numeric_limits<double>::max(); | ||
|
||
if (path.poses.size() < 2) { | ||
if (path.poses.empty()) { |
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.
Why is empty
in the size < 2
condition? It is probably better to break it into 2 independent conditions for clarity. Check if empty --> return, then check if size == 1 to return the first point. I prefer flattened code over nested node as a matter of readability.
|
||
PathSearchResult distance_from_path( | ||
const nav_msgs::msg::Path & path, | ||
const geometry_msgs::msg::PoseStamped & robot_pose, |
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.
Change robot_pose from PoseStamped to Pose. Add in the doxygen its expected that the robot pose is already transformed into the path's frame
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.
Or, check that the path frame == robot pose frame. If not, throw exception
aac9a09
to
7eb827a
Compare
@SteveMacenski sorry for late response. I made those changes you wanted. |
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Signed-off-by: silanus23 <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: silanus <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: silanus <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: silanus <[email protected]>
4361fe0
to
f419292
Compare
Signed-off-by: silanus23 <[email protected]>
Erased nav_2d_msgs from cmake Added publishing func to controller server Signed-off-by: silanus23 <[email protected]>
I changed util's cmake according to @mini-1235 's warning.
Adding clear costmap clearence is a future investment. |
Signed-off-by: silanus23 <[email protected]>
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.
Pull Request Overview
This PR implements path distance functionality to calculate the minimum distance between a robot's current pose and a path. The feature enables tracking the robot's deviation from a planned path and provides real-time tracking error information.
- Adds path utility functions to compute distance from robot pose to path segments with optional windowed search
- Implements tracking error computation and publishing in the controller server
- Introduces a new TrackingError message type for real-time path deviation monitoring
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
nav2_util/include/nav2_util/path_utils.hpp | Defines PathSearchResult struct and distance_from_path function interface |
nav2_util/src/path_utils.cpp | Implements core path distance calculation algorithm with windowed search |
nav2_util/include/nav2_util/geometry_utils.hpp | Adds distance_to_segment and cross_product_2d utility functions |
nav2_util/test/test_path_utils.cpp | Comprehensive test suite covering various path scenarios and edge cases |
nav2_msgs/msg/TrackingError.msg | New message type for tracking error data |
nav2_controller/include/nav2_controller/controller_server.hpp | Adds tracking error publishing capability to controller server |
nav2_controller/src/controller_server.cpp | Integrates path distance calculation and publishes tracking error messages |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
const double robot_vec_x = p.x - a.x; | ||
const double robot_vec_y = p.y - a.y; | ||
|
||
return (path_vec_x * robot_vec_y) - (path_vec_y * robot_vec_x); |
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.
[nitpick] Extra space after return
keyword should be removed for consistency with coding standards.
return (path_vec_x * robot_vec_y) - (path_vec_y * robot_vec_x); | |
return (path_vec_x * robot_vec_y) - (path_vec_y * robot_vec_x); |
Copilot uses AI. Check for mistakes.
{ | ||
for (int i = 0; i <= 10; ++i) {target_path.poses.push_back(createPoseStamped(i, 0.0));} | ||
for (int i = 9; i >= 0; --i) {target_path.poses.push_back(createPoseStamped(i, 0.0));} | ||
for (int i = 0; i <= 10; ++i) { |
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.
[nitpick] Multiple statements on single lines reduce readability. Consider formatting each loop body on separate lines.
for (int i = 0; i <= 10; ++i) { | |
for (int i = 0; i <= 10; ++i) { | |
target_path.poses.push_back(createPoseStamped(i, 0.0)); | |
} | |
for (int i = 9; i >= 0; --i) { | |
target_path.poses.push_back(createPoseStamped(i, 0.0)); | |
} | |
for (int i = 0; i <= 10; ++i) { |
Copilot uses AI. Check for mistakes.
Signed-off-by: silanus23 <[email protected]>
Hello @SteveMacenski First of all I am not trying to rush the proccess but to inform you about my current local progress so when you have time for my committed codes it will allign with your vision and we can move faster. About DWB Critics: I added the critics and a unit test. I have been able to create a case where that critic can create a diff here are the proof vids and parameters I used About Costmap Layer: I get results in here but incosistent. and to be honest I am not really sure about my expectations in here. First path is not getting a corridor but the second is answering. In addition sometimes I can not get response too. But when I do get response I think I get a decent corridor around the path ahead of robot. BT node: This started to work better with others giving less frequent fails and now able to recover faster. MPPI critic: This one is a bit problematic as mppi is using diff kind of trajectory units. So I either have to convert it (which kills entire philosphy) or create an overloaded function that uses it's input types. I would like to hear your guidance if there is a better and efficient approach. I missed 1 of your comments ( the 1 about doxygen of the util func) but I don't like too many tiny commits I will make it better in next commit. I commit as you give feedback so I can be in synch with you and we can progress step by step. I tried to find places to utilize added functions. I think maybe distance_to_segment can be used in someplace but it can optimize some places if used in place euclidean distance or optimization in planner side of the repo . I am really not sure about it. Maybe create an rviz2 plugin Thanks for your guidance and time from now. |
Basic Info
Description of contribution in a few bullet points
Only path utils as descripted in the issue. It is finding nearest part in the path and current or waited position of robot. It interpolates between points cause the expected nearest point is between points path most of the time. There are 2 versions global version is reccomended and local version can sometimes fail.
Description of documentation updates required from your changes
At this stage none needed.
Description of how this change was tested
I wrote diffirent trajectories. AI help came in here I used it to calculate the numbers. I have tested the local search with clover leaf and retracting windows too but it failed. This was actually expected as the local search is optimized version. I don't think those failings come from a logical issue but the limitations of the approach behind it.
Future work that may be required in bullet points
Future side of the it is planned as you reccomend. Next one will be about creating a new msg type and publishing it from controller_server.
BTW thanks for patience about my last PR as this is my first open source contribution. I am still learning.
For Maintainers:
backport-*
.