Skip to content
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

RPP Dexory tweaks #4140

Merged
merged 6 commits into from
Mar 15, 2024
Merged

RPP Dexory tweaks #4140

merged 6 commits into from
Mar 15, 2024

Conversation

doisyg
Copy link
Contributor

@doisyg doisyg commented Feb 23, 2024


Basic Info

Info Please fill out this column
Ticket(s) this addresses Similar to #3788 (comment)
Primary OS tested on Ubuntu
Robotic platform tested on Dexory Robot
Does this PR contain AI generated software? NO

Description of contribution in a few bullet points

This is me finally contributing back after rebasing and testing with latest main the RPP tweaks that we have been using for months in production.
Warning, we only use RPP for linear paths, so caution when generalizing the usage of the added feature.

  • New behavior controlled by a new parameter interpolate_curvature_after_goal (default false) that interpolates a carrot after the goal in order to maintain a constant curvature lookahead distance. This is to avoid instabilities at the end of the path on the generation of the angular speed. The carrot used for the linear speed computation stays the same.
    • Interpolation is based on the orientation of the vector formed by the last 2 poses of the path. Hence paths of length 1 are rejected when interpolate_curvature_after_goal is true. It required to modify a bit the path handler logic to be sure to keep at least 2 poses on the pruned plan.
    • It can be used only when use_fixed_curvature_lookahead: true
    • Publish curvature_lookahead_point similarly to lookahead_point for visualisation
2024-02-23.16-18-43.mp4
  • Fix conflict between use_rotate_to_heading and allow_reversing (added x_vel_sign parameter to shouldRotateToPath for that). So use_rotate_to_heading can now be used backward.

These 2 tweaks are a bit intertwined, hence contributing them together. This may be partially redundant with #3788 @james-ward

Description of documentation updates required from your changes


Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in navigation.ros.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

@SteveMacenski
Copy link
Member

@james-ward can you look at this and confirm its a suitable alternative? If so, I can fix up a small number of pendantic things I'd like to change here (remove AMCL dependency...) and merge it. Or if there are elements of your PR you think need to still be here, let me know and I can make sure to review them both as a pair

@james-ward
Copy link
Contributor

@james-ward can you look at this and confirm its a suitable alternative? If so, I can fix up a small number of pendantic things I'd like to change here (remove AMCL dependency...) and merge it. Or if there are elements of your PR you think need to still be here, let me know and I can make sure to review them both as a pair

LGTM. This is essentially what I had - the only difference is that I didn't force the path to always contain at least two points, as I wasn't sure if this would break some other behaviour (ie maybe the pruning of already passed points was necessary for correct behaviour of something else.) If that is not the case, this PR is good for me.

I can test on our platforms if the two of you wish, but I can't do that until later in the week.

@james-ward
Copy link
Contributor

The only other thing is that you might want to adapt the new test I wrote on my branch for the actual act of projecting off the end of the path?
james-ward@e9dd766

@SteveMacenski
Copy link
Member

Great! @doisyg can you add that and rebase on main, that should make CI fully turn over

@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.5)
project(nav2_regulated_pure_pursuit_controller)

find_package(ament_cmake REQUIRED)
find_package(nav2_amcl REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO Me: remove AMCL dep and use angles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah forgot about than one and your eyes when you saw that we are still using the good old amcl angles utils

@@ -90,6 +90,7 @@ Note: The maximum allowed time to collision is thresholded by the lookahead poin
| `rotate_to_heading_min_angle` | The difference in the path orientation and the starting robot orientation to trigger a rotate in place, if `use_rotate_to_heading` is enabled. |
| `max_angular_accel` | Maximum allowable angular acceleration while rotating to heading, if enabled |
| `max_robot_pose_search_dist` | Maximum integrated distance along the path to bound the search for the closest pose to the robot. This is set by default to the maximum costmap extent, so it shouldn't be set manually unless there are loops within the local costmap. |
| `interpolate_curvature_after_goal` | Needs use_fixed_curvature_lookahead to be true. Interpolate a carrot after the goal dedicated to the curvate calculation (to avoid oscilaltions at the end of the path) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for @doisyg @james-ward : Do you feel there's any reason to make this a parameterization or always be in play?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should always be in play - for two reasons.
First, it preserves the user's intent when they set the minimum carrot distance.
Second, it only engages in the last segment and fixes bad control behaviour - I don't see a downside to having it running.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doisyg if you agree, you can remove the param and make it the always-on behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On that one, I would be a bit conservative and keep it as a parameter for a while, then changing it later to default true, and finally then removing it. A bit like with the former use_interpolation.
I am only very confident for straight path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@james-ward can you give this a whirl and let us know what you think? He's testing this on straight-line paths in warehouses, so they don't end on curves (they use other algorithms for free space controlling). If so, we can simplify this a bit

@doisyg
Copy link
Contributor Author

doisyg commented Feb 27, 2024

Great! @doisyg can you add that and rebase on main, that should make CI fully turn over

Yes! @james-ward just the test of that commit james-ward@e9dd766, or all the added tests in your branch ?

@james-ward
Copy link
Contributor

Great! @doisyg can you add that and rebase on main, that should make CI fully turn over

Yes! @james-ward just the test of that commit james-ward@e9dd766, or all the added tests in your branch ?

I think only that commit is relevant. The others were for internal functions that I created.

@SteveMacenski
Copy link
Member

I took a look, beyond the parameter remark, I think this is good to go. Once merged, I'll remove the AMCL bits myself.

Without parameter:

  • Just need you to do the migration guide entry (add that gif!)

With parameter

  • Without parameter instructions and ...
  • Param guide entry for the RPP param

@doisyg
Copy link
Contributor Author

doisyg commented Feb 28, 2024

Rebased on main and added / adapted your test @james-ward (testing full quadrant and no single pose path as we reject them now).
If all good, will do the documentation asap

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 81.08108% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 89.87%. Comparing base (d509fbf) to head (a3b230b).
Report is 7 commits behind head on main.

❗ Current head a3b230b differs from pull request most recent head 994351e. Consider uploading reports for the commit 994351e to get more accurate results

Files Patch % Lines
...ntroller/src/regulated_pure_pursuit_controller.cpp 84.00% 4 Missing ⚠️
..._pure_pursuit_controller/src/parameter_handler.cpp 77.77% 2 Missing ⚠️
...lated_pure_pursuit_controller/src/path_handler.cpp 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4140      +/-   ##
==========================================
- Coverage   90.01%   89.87%   -0.15%     
==========================================
  Files         432      432              
  Lines       19406    19431      +25     
==========================================
- Hits        17469    17463       -6     
- Misses       1937     1968      +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@doisyg
Copy link
Contributor Author

doisyg commented Feb 29, 2024

Docs: ros-navigation/docs.nav2.org#530

@SteveMacenski
Copy link
Member

LGTM pending doc fix and if @james-ward responds to #4140 (comment)

@james-ward
Copy link
Contributor

LGTM pending doc fix and if @james-ward responds to #4140 (comment)

I'll give it a run this afternoon.

@james-ward
Copy link
Contributor

I'm afraid I wasn't able to test this. We've had to run my patch up until now to make our platforms drivable, and the mainline has diverged enough that this wasn't just a simple update, keeping the other plugins and configs the same. I could not get the platform to move at all.

I will have another look on Monday.

@SteveMacenski
Copy link
Member

SteveMacenski commented Mar 1, 2024

Thanks, I really appreciate your time here. Making sure all the stakeholders are happy and not going to come back in 3 weeks because we made an error saves us all frustration by having to context switch back 😄

@james-ward
Copy link
Contributor

james-ward commented Mar 4, 2024

This PR does have the effect of projecting the carrot, but it is not smooth. There are big jumps in the projected position. So it isn't keeping the look ahead distance constant as is desired.
carrot_short.webm

Above video is live from our platform.

This is because the current robot position is assumed to be the second last pose in the path (https://github.com/ros-planning/navigation2/blob/a3b230bb0ed0adac1b4ebb976437eb9e8b7a568e/nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp#L354), not its actual position. So the carrot will jump ahead by the spacing of the poses in the path. For big spacings this will result in jumpy carrot movement.

@doisyg
Copy link
Contributor Author

doisyg commented Mar 4, 2024

Hi @james-ward, fair enough, we have been using paths/plans with small spacing, hence it works smoothly for us.

auto current_robot_pose_it = transformed_plan.poses.begin(); is maybe not the best name as it is the first pose of the pruned plan, not the real robot pose. It is used here only to compute the curvature carrot distance to interpolate after the goal.
We don't want to use the real robot pose for that in order to have a stable carrot, but the closest path pose, which should be the first pose of the pruned plan. However, as you pointed, the accuracy of using the first pose of the pruned plan is limited by the plan pose density.

An easy workaround would be to use a denser plan. A full solution will be to interpolate between the pose of the plan. Maybe as a separate PR on top of this one ? WDYT ?

@james-ward
Copy link
Contributor

The robot position is (0,0) because the PathHandler keeps translating and pruning the path so that it is relative to the robot.

So before the last segment, calling circleSegmentIntersection gets the point on the current segment that is exactly the look ahead distance away from the current robot position.

But this PR introduces different behaviour in the last segment. It finds the length of the last segment, subtracts it from the look ahead distance and then projects the carrot past the segment end by the remaining amount. For a robot at/very near the goal pose, the actual look ahead will end up being the desired lookahead minus the last segment length.

I think that because you force the controller to not drop the second last pose in the path even when the robot has passed it, you could just call the circleSegmentIntersection method on the last segment and it would work. (I think the maths doesn't actually distinguish between finite segments and infinite lines). But failing that, do what I did in my proposed solution and project the segment an additional distance equal to the look ahead and then do the intersection. This would ensure that the extended segment is longer than the look ahead and an intersection with the circle is guaranteed.

@james-ward
Copy link
Contributor

@doisyg I have made the changes necessary to keep the carrot at the correct look ahead distance. It clearly wasn't correct before as the tests were looking for distances that were different from the look ahead distance.

My commit is here:
james-ward@1a8b5b3

@SteveMacenski
Copy link
Member

SteveMacenski commented Mar 7, 2024

Do we suppose that closes the loop on this feature? I'm defaulting to whatever you both come to an agreement on for this one - I trust your opinions 😄

@james-ward
Copy link
Contributor

Do we suppose that closes the loop on this feature? I'm defaulting to whatever you both come to an agreement on for this one - I trust your opinions 😄

It does from my point of view. I have been running that latest patch since last week and it is good for us.

@SteveMacenski
Copy link
Member

@doisyg I know you're in Florida, so take your time, but let me know and push the update if appropriate! 😄

Copy link
Contributor

mergify bot commented Mar 13, 2024

@doisyg, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@doisyg
Copy link
Contributor Author

doisyg commented Mar 13, 2024

Thanks a lot @james-ward @SteveMacenski for you patience, and sorry that my iterations are a bit slow.
Pushed your commit, fixed lint and tested in simulation, looks good to go.

Guillaume Doisy and others added 6 commits March 13, 2024 18:02
Signed-off-by: Guillaume Doisy <[email protected]>
Signed-off-by: Guillaume Doisy <[email protected]>
This guarantees that the look ahead distance is maintained

Signed-off-by: James Ward <[email protected]>
Signed-off-by: Guillaume Doisy <[email protected]>
@doisyg
Copy link
Contributor Author

doisyg commented Mar 13, 2024

and rebased on main

Copy link
Contributor

mergify bot commented Mar 13, 2024

@doisyg, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@SteveMacenski
Copy link
Member

@james-ward we all happy with this now? Can you give it one last whirl around? Then we can merge!

@james-ward
Copy link
Contributor

@james-ward we all happy with this now? Can you give it one last whirl around? Then we can merge!

I'll try it this morning. Stand by...

@james-ward
Copy link
Contributor

Have confirmed it is good on our platform.

Send it!!

Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doisyg I don't see when reject_unit_path is ever used. Can this be removed?

Otherwise LGTM and I can come through afterwards on replacing the AMCL dependency

@SteveMacenski SteveMacenski merged commit db974ea into ros-navigation:main Mar 15, 2024
7 of 9 checks passed
ajtudela pushed a commit to grupo-avispa/navigation2 that referenced this pull request Apr 19, 2024
* RPP Dexory tweaks

Signed-off-by: Guillaume Doisy <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp

Signed-off-by: Steve Macenski <[email protected]>

* projectCarrotPastGoal test

Signed-off-by: Guillaume Doisy <[email protected]>

* Use circleSegmentIntersection when projecting past end of path

This guarantees that the look ahead distance is maintained

Signed-off-by: James Ward <[email protected]>

* lint

Signed-off-by: Guillaume Doisy <[email protected]>

---------

Signed-off-by: Guillaume Doisy <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Signed-off-by: James Ward <[email protected]>
Co-authored-by: Guillaume Doisy <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
Co-authored-by: James Ward <[email protected]>
enricosutera pushed a commit to enricosutera/navigation2 that referenced this pull request May 19, 2024
* RPP Dexory tweaks

Signed-off-by: Guillaume Doisy <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp

Signed-off-by: Steve Macenski <[email protected]>

* projectCarrotPastGoal test

Signed-off-by: Guillaume Doisy <[email protected]>

* Use circleSegmentIntersection when projecting past end of path

This guarantees that the look ahead distance is maintained

Signed-off-by: James Ward <[email protected]>

* lint

Signed-off-by: Guillaume Doisy <[email protected]>

---------

Signed-off-by: Guillaume Doisy <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Signed-off-by: James Ward <[email protected]>
Co-authored-by: Guillaume Doisy <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
Co-authored-by: James Ward <[email protected]>
Signed-off-by: enricosutera <[email protected]>
Marc-Morcos pushed a commit to Marc-Morcos/navigation2 that referenced this pull request Jul 4, 2024
* RPP Dexory tweaks

Signed-off-by: Guillaume Doisy <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp

Signed-off-by: Steve Macenski <[email protected]>

* projectCarrotPastGoal test

Signed-off-by: Guillaume Doisy <[email protected]>

* Use circleSegmentIntersection when projecting past end of path

This guarantees that the look ahead distance is maintained

Signed-off-by: James Ward <[email protected]>

* lint

Signed-off-by: Guillaume Doisy <[email protected]>

---------

Signed-off-by: Guillaume Doisy <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Signed-off-by: James Ward <[email protected]>
Co-authored-by: Guillaume Doisy <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
Co-authored-by: James Ward <[email protected]>
Manos-G pushed a commit to Manos-G/navigation2 that referenced this pull request Aug 1, 2024
* RPP Dexory tweaks

Signed-off-by: Guillaume Doisy <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp

Signed-off-by: Steve Macenski <[email protected]>

* projectCarrotPastGoal test

Signed-off-by: Guillaume Doisy <[email protected]>

* Use circleSegmentIntersection when projecting past end of path

This guarantees that the look ahead distance is maintained

Signed-off-by: James Ward <[email protected]>

* lint

Signed-off-by: Guillaume Doisy <[email protected]>

---------

Signed-off-by: Guillaume Doisy <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Signed-off-by: James Ward <[email protected]>
Co-authored-by: Guillaume Doisy <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
Co-authored-by: James Ward <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants