-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Graceful Controller] Fix Incorrect Motion Target Heading output by controller #5530
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
[Graceful Controller] Fix Incorrect Motion Target Heading output by controller #5530
Conversation
Signed-off-by: Sakshay Mahna <[email protected]>
@SakshayMahna, your PR has failed to build. Please check CI outputs and resolve issues. |
nav2_util/src/controller_utils.cpp
Outdated
point.y - prev_pose_it->pose.position.y, | ||
point.x - prev_pose_it->pose.position.x); | ||
|
||
// Path tangent vector (prev -> goal) |
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.
Can you explain the logic here? I wonder if there's a more straight forward way... A hand-drawn diagram might be insightful
Can I have a general idea of how the motion target heading affects the performance of the Graceful Controller? Then I will know what to focus on other than the visualization issue. At a quick glance, I think it is being used here navigation2/nav2_graceful_controller/include/nav2_graceful_controller/ego_polar_coords.hpp Lines 66 to 67 in 547820f
|
The problem was that the calculated We calculate two vectors
We take their dot product to determine if they face in the same direction, and adjust the yaw value accordingly (adding As per what I understand the orientation of the next point is factored into the control equation, and affects the trajectory the robot takes. Here is the paper: https://web.eecs.umich.edu/~kuipers/papers/Park-icra-11.pdf |
Perhaps a dumb question, but isn't the point on the path? Therefore we can simply use:
Since the angle should always be the same regardless? |
I can try that, but I think the problem may still persist. What I understand (correct me if I am wrong), the scenario that @mini-1235 described is taking place due to the output range of atan2 ( |
This is solving the issue. I am not seeing any problems which were pointed out earlier. Yes, it should work (my bad) because in the code I pushed now, we are comparing with I will push this. But I don't fully understand the reason, because |
Signed-off-by: Sakshay Mahna <[email protected]>
@SakshayMahna, your PR has failed to build. Please check CI outputs and resolve issues. |
Sorry for the late response, I was validating the changes here together with #5446, and I also took a deeper look into this problem today The problem seems to be in these lines: navigation2/nav2_util/src/controller_utils.cpp Lines 62 to 83 in d36bdd1
Where we previously have: auto goal_pose_it = std::find_if(
transformed_plan.poses.begin(), transformed_plan.poses.end(), [&](const auto & ps) {
return hypot(ps.pose.position.x, ps.pose.position.y) >= lookahead_dist;
}); If I revert these lines, then atan(point-prev) also works I throw a log when the yaw jumps and points to the wrong direction:
![]() This assumption seems to fail in this case navigation2/nav2_util/src/controller_utils.cpp Lines 116 to 120 in d36bdd1
I also took a look on #5003, but I could not find the discussion for these lines changed |
Ah, so this fails because the lookahead distance is no longer computed via the L2 distance but now integrated distance. That is subtle. This probably means that we're getting the incorrect exact lookahead distanced point in both use cases, yes? |
Welp, that's not good. @SakshayMahna what do you think? 🙃 |
Makes sense, that's why using the goal point instead of lookahead point corrects the orientation. |
I think I understand what is happening now.
auto goal_pose_it = std::find_if(
transformed_plan.poses.begin(), transformed_plan.poses.end(), [&](const auto & ps) {
return hypot(ps.pose.position.x, ps.pose.position.y) >= lookahead_dist;
}); However, now we are using accumulated path distance, not the straight line L2 distance from the origin. That is why the |
Yup, that's my understanding too! Is this something you're open to contributing? I think this should be relatively straight forward as well - we could do something a bit more straight forward in linear interpolation? @vinnnyr I know this was something your company was interested in for RPP which is now shared. Can you provide some feedback if removing I would categorize this problem right now as pretty urgent since the current state of the code is broken. If someone wasn't going to make a change this week to fix this issue, I would consider reverting the original PR for enabling the path integral distance until such a time this is addressed (though not my preference!) |
Yes sure, this seems doable, probably over this weekend. Or we can retain the |
Great!
I suppose I'd rather a final solution, but this does help, so there's some value in a temporary stop-gap. If a solution would come early next week, we could wait instead. This isn't just problematic for the orientation but also selects the wrong point as well.
I'm not sure how we'd distinguish it for RPP vs Graceful, but that is an option. I don't think there'll be appreciable changes in the behavior so I think we could make it a global update. Also RPP now does integrated path distances too, no? We just don't see the breakage for RPP because it doesn't care about the orientation. |
Yes, RPP also uses integrated path distances now. And RPP does not use orientation so no problem for that. |
320d7d3
to
8ceba02
Compare
Signed-off-by: Sakshay Mahna <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 10 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Teamwork makes the dream work; @mini-1235 does this resolve the issue for you? |
I'm pinging @vinnnyr to test since I think this impacts his work so as a sanity check of a deployed user |
Sorry I see this in my inbox but i’ve been out for the past few days.I expect to get back tomorrow so I can take a look then!On Oct 6, 2025, at 16:40, Steve Macenski ***@***.***> wrote:SteveMacenski left a comment (ros-navigation/navigation2#5530)
I'm pinging @vinnnyr to test since I think this impacts his work so as a sanity check of a deployed user
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Yes, I tested this with tb4, and it solves my issue |
Signed-off-by: Sakshay Mahna <[email protected]>
@SakshayMahna, your PR has failed to build. Please check CI outputs and resolve issues. |
Replacing the circular interpolation is OK from our perspective conceptually if it no longer makes sense. |
Making sure forward and reversing works with these changes (and the previous ones that this is fixing) is pretty key, I agree |
I checked with the earlier code, and briefly went through the Graceful Controller paper. I checked with the current code and the previous code (before the interpolation) it seems to be working fine. Is it failing in some case? Or anything that I am missing? |
I am trying feasible planners with graceful controller, here is my config:
Before #5003, I can see both A and B when reversing 2025-10-09.02-45-37.mp4After #5003 and this PR, I can only see A 2025-10-09.02-49-19.mp4
If this is the case, I believe we can go ahead and merge this PR! |
Thanks @SakshayMahna for the follow up and iteration here! Nav2 only works because of great contributors like you and @mini-1235 :-) |
…ontroller (ros-navigation#5530) * Fix graceful controller lookahead bug Signed-off-by: Sakshay Mahna <[email protected]> * Shorten logic with goal_pose Signed-off-by: Sakshay Mahna <[email protected]> * Add Linear Interpolation Fix Signed-off-by: Sakshay Mahna <[email protected]> * Update const double and comments Signed-off-by: Sakshay Mahna <[email protected]> --------- Signed-off-by: Sakshay Mahna <[email protected]>
…ontroller (ros-navigation#5530) * Fix graceful controller lookahead bug Signed-off-by: Sakshay Mahna <[email protected]> * Shorten logic with goal_pose Signed-off-by: Sakshay Mahna <[email protected]> * Add Linear Interpolation Fix Signed-off-by: Sakshay Mahna <[email protected]> * Update const double and comments Signed-off-by: Sakshay Mahna <[email protected]> --------- Signed-off-by: Sakshay Mahna <[email protected]>
Basic Info
Description of contribution in a few bullet points
Due to yaw value discontinuity, graceful controller was giving incorrect motion target heading. This PR fixes the discontinuity, by allowing continuous values of yaw in the direction of robot.
Description of documentation updates required from your changes
No
Description of how this change was tested
Tested multiple times on simulation.
Future work that may be required in bullet points
No
For Maintainers:
backport-*
.