Skip to content

Fix - #5094 rotation shim stateful goal checking#5140

Merged
SteveMacenski merged 9 commits intoros-navigation:humblefrom
PrabhavSaxena:fix/rotation-shim-stateful-goal-checking
May 16, 2025
Merged

Fix - #5094 rotation shim stateful goal checking#5140
SteveMacenski merged 9 commits intoros-navigation:humblefrom
PrabhavSaxena:fix/rotation-shim-stateful-goal-checking

Conversation

@PrabhavSaxena
Copy link
Contributor

@PrabhavSaxena PrabhavSaxena commented May 9, 2025


Basic Info

Info Please fill out this column
Ticket(s) this addresses (add tickets here #5094 )
Primary OS tested on (Ubuntu)
Robotic platform tested on (gazebo simulation of Tally)
Does this PR contain AI generated software? (No)

Description of contribution in a few bullet points

  • Added a new plugin called position_goal_checker, which checks only the xy tolerance and ignores the yaw tolerance. Used the same plugin internally in Rotation Shim Controller.

Description of documentation updates required from your changes

  • Should I add position_goal_checker in the documentation, as it is a new plugin?

Description of how this change was tested

  • Validated RotationShimController in turtlebot simulation.

Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in docs.nav2.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

@PrabhavSaxena PrabhavSaxena changed the base branch from main to humble May 9, 2025 20:15
@mergify
Copy link
Contributor

mergify bot commented May 9, 2025

This pull request is in conflict. Could you fix it @PrabhavSaxena?

@mergify
Copy link
Contributor

mergify bot commented May 9, 2025

@PrabhavSaxena, all pull requests must be targeted towards the main development branch.
Once merged into main, it is possible to backport to @humble, but it must be in main
to have these changes reflected into new distributions.

@PrabhavSaxena PrabhavSaxena changed the title Fix/rotation shim stateful goal checking Fix - #5094 rotation shim stateful goal checking May 9, 2025
Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
@PrabhavSaxena PrabhavSaxena force-pushed the fix/rotation-shim-stateful-goal-checking branch from 96c0bdf to 9ddddfe Compare May 9, 2025 20:28
Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
@SteveMacenski
Copy link
Member

I don't think this works from the discussion in #5094 (comment) can you comment on that?

@SteveMacenski SteveMacenski added the question Further information is requested label May 9, 2025
@PrabhavSaxena
Copy link
Contributor Author

I don't think this works from the discussion in #5094 (comment) can you comment on that?

The issue occurs because the rotation shim controller uses position-only tolerance checking to decide when to switch to rotation mode. However, due to localization shifts, if the robot briefly moves outside the XY tolerance during rotation, it switches back to the primary controller, causing oscillation.

The change I've implemented uses the existing stateful behavior of goal_checker->isGoalReached().

  1. First check if the robot is within both XY and angular tolerances
  2. Remember when the robot has entered the goal region
  3. Continue to return true for subsequent calls, even with minor position shifts

This "memory" is exactly what's needed to solve the oscillation problem - once the controller enters rotation mode, it will stay there despite minor localization shifts.

One potential concern might be that isGoalReached() also checks orientation. For a more complete solution, we might need to:

  1. Either implement a truly position-only stateful check
  2. Or modify the withinPositionGoalTolerance to maintain its own state once position tolerance is met

I'd appreciate your guidance on which approach would better align with the architecture of Nav2.

@SteveMacenski
Copy link
Member

SteveMacenski commented May 9, 2025

Or modify the withinPositionGoalTolerance to maintain its own state once position tolerance is met

I think this is what we should do ultimately. The goal checker that is given to the controller from the server can be any plugin considering any number of criteria. We can't rely on its implementation for internal controller behavior. We could essentially create a "stateful position goal checker" style object (or even that literal new plugin that we directly instantiate and use internally) to use in the controller to meet this need.

Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
@PrabhavSaxena
Copy link
Contributor Author

PrabhavSaxena commented May 10, 2025

Or modify the withinPositionGoalTolerance to maintain its own state once position tolerance is met

I think this is what we should do ultimately. The goal checker that is given to the controller from the server can be any plugin considering any number of criteria. We can't rely on its implementation for internal controller behavior. We could essentially create a "stateful position goal checker" style object (or even that literal new plugin that we directly instantiate and use internally) to use in the controller to meet this need.

I have added the plugin to check the position only. I have also added rotation_shim to internally use the same. Let me know if this works

Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
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.

Last thing is that we need this PR to also target main so that Rolling, Jazzy, etc can have these changes also reflected. That way when you eventually upgrade, this is also included. All new features must be in main.

* @class PositionGoalChecker
* @brief Goal Checker plugin that only checks XY position, ignoring orientation
*/
class PositionGoalChecker : public nav2_core::GoalChecker
Copy link
Member

Choose a reason for hiding this comment

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

@PrabhavSaxena
Copy link
Contributor Author

Hi, I will resolve the comments right now, I had few questions about the same.

  1. Should I direct this PR to main branch (which requires some effort because I made this PR out of humble branch) or should I merge this PR (with humble) and create a new one which targets main branch. Or if there is some easier way to make my changes target the main branch.
  2. Should I remove the tools/utils.hpp file in nav2_rotation_shim_controller as we are no longer using the withinPositionGoalTolerance function?

Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
primary_controller_->setPlan(path);
if (position_goal_checker_) {
position_goal_checker_->reset();
}
Copy link
Member

Choose a reason for hiding this comment

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

For main we should also have the goal checker reset when we reset the controller (which happens at the end of a planning request https://github.com/ros-navigation/navigation2/blob/main/nav2_rotation_shim_controller/src/nav2_rotation_shim_controller.cpp#L401-L405)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@SteveMacenski
Copy link
Member

  1. Leave this PR and lets get this approved first. Then once its done, you should apply this to main (with a tweak I mention in a comment above) and we can merge all of them together
  2. Yes please unless you think it has reusability elsewhere :-)

Signed-off-by: PrabhavSaxena <prabhavsaxena2003@gmail.com>
@PrabhavSaxena
Copy link
Contributor Author

  1. Leave this PR and lets get this approved first. Then once its done, you should apply this to main (with a tweak I mention in a comment above) and we can merge all of them together

    1. Yes please unless you think it has reusability elsewhere :-)

cool, got it :)

…r.cpp

Signed-off-by: Steve Macenski <stevenmacenski@gmail.com>
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.

I look forward to the main PR :-)

@PrabhavSaxena
Copy link
Contributor Author

PrabhavSaxena commented May 15, 2025

I look forward to the main PR :-)

I created a PR for the same (Pull request 5162)

@SteveMacenski SteveMacenski merged commit ccc33c8 into ros-navigation:humble May 16, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants