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

Add logic to Ros2ControlManager to match ros2_control #3332

Merged
merged 13 commits into from
Feb 12, 2025

Conversation

pac48
Copy link
Contributor

@pac48 pac48 commented Feb 10, 2025

Description

The logic for the chained controllers still does not match the expectation of ROS2 control. This PR makes a few changes:

  1. Activation/deactivation is expected to be disjoint. For example, if controller B is a dependency of A (A chains to B) but controller B is also a dependency of C (B chains to B), then the switch from A->B to C->B would cause B to be in both the activation and deactivate list. This causes ROS2 control to through an error and reject the switch. The simplifyControllerActivationDeactivation function adds the logic needed to avoid this from happening.
  2. The valid transitions for chained controllers depend asymmetrically on whether the controller is being started or stopped. If A chained to B, then when A is started, B should be automatically started. B is allowed to be started and stopped on its own if A is not running. However, if both A and B are running, B cannot be shut down alone, both must be shut down together or A alone.
  3. Lastly, ROS 2 control should not be told to shut down controllers that are not running or start controllers that are already running. Doing so can cause an error. A check is added to only start controllers that are not already running.

@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 98.01980% with 2 lines in your changes missing coverage. Please review.

Project coverage is 45.83%. Comparing base (7db0bd4) to head (3a4eae6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ontrol_interface/src/controller_manager_plugin.cpp 94.60% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3332      +/-   ##
==========================================
- Coverage   45.97%   45.83%   -0.13%     
==========================================
  Files         716      717       +1     
  Lines       62477    62574      +97     
  Branches     7564     7564              
==========================================
- Hits        28715    28675      -40     
- Misses      33594    33731     +137     
  Partials      168      168              

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

@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch from 42463c1 to 3dc2995 Compare February 10, 2025 20:26
@pac48 pac48 marked this pull request as ready for review February 10, 2025 20:26
@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch from 3dc2995 to db1a7d8 Compare February 10, 2025 20:31
@pac48 pac48 requested a review from dyackzan February 10, 2025 20:31
@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch 2 times, most recently from d67c296 to 8e7dd31 Compare February 10, 2025 20:49
@pac48 pac48 requested a review from sjahr February 10, 2025 21:47
@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch 2 times, most recently from 618ec3a to 0164264 Compare February 10, 2025 23:17
@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch from 0164264 to 33a9708 Compare February 10, 2025 23:21
Copy link
Contributor

@sjahr sjahr left a comment

Choose a reason for hiding this comment

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

How can this be tested / can we add very basic unittesting to make this code more robust (not blocking this PR)?

The test failures are cause by flacky unittests.

@pac48 pac48 requested a review from sjahr February 11, 2025 16:58
@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch from 1452fa3 to 9db62e5 Compare February 11, 2025 17:09
@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch from f060e31 to 704dd4e Compare February 11, 2025 17:22
@pac48 pac48 requested a review from griswaldbrooks February 11, 2025 22:53
Copy link
Contributor

@griswaldbrooks griswaldbrooks left a comment

Choose a reason for hiding this comment

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

Ok, done with comments about C++. I'm not qualified to review the functional aspects of this code.

Signed-off-by: Paul Gesel <[email protected]>
@sea-bass sea-bass added the backport-humble Mergify label that triggers a PR backport to Humble label Feb 12, 2025
@sea-bass sea-bass added the backport-jazzy Mergify label that triggers a PR backport to Jazzy label Feb 12, 2025
Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

LGTM -- I'll wait until this one is merged before releasing Jazzy/Rolling (sadly I already released Humble like a day or 2 ago)

@sea-bass
Copy link
Contributor

Huh, somehow there are clang-tidy fixes being suggested

@pac48 pac48 requested a review from sea-bass February 12, 2025 14:59
Signed-off-by: Paul Gesel <[email protected]>
@pac48 pac48 force-pushed the pr-more-controller-manager-logic branch from 11dded3 to 2d91d45 Compare February 12, 2025 15:06
@sjahr sjahr enabled auto-merge February 12, 2025 15:49
@sea-bass
Copy link
Contributor

@griswaldbrooks you may resolve your own comments now 🤣

@sjahr sjahr added this pull request to the merge queue Feb 12, 2025
Merged via the queue into moveit:main with commit dbf07b1 Feb 12, 2025
9 checks passed
mergify bot pushed a commit that referenced this pull request Feb 12, 2025
* Add logic to Ros2ControlManager to match ros2_control

Signed-off-by: Paul Gesel <[email protected]>

* Add Ros2ControlManager test

Signed-off-by: Paul Gesel <[email protected]>

* move simplifyControllerActivationDeactivation to function and add doxygen

Signed-off-by: Paul Gesel <[email protected]>

* move queue.pop_back up

Signed-off-by: Paul Gesel <[email protected]>

* Update moveit_plugins/moveit_ros_control_interface/src/controller_manager_plugin.cpp

Co-authored-by: Sebastian Castro <[email protected]>

* Update moveit_plugins/moveit_ros_control_interface/src/controller_manager_plugin.cpp

Co-authored-by: Sebastian Castro <[email protected]>

* Update moveit_plugins/moveit_ros_control_interface/src/controller_manager_plugin.cpp

Co-authored-by: Sebastian Castro <[email protected]>

* pr feedback

Signed-off-by: Paul Gesel <[email protected]>

* clang fixes

Signed-off-by: Paul Gesel <[email protected]>

---------

Signed-off-by: Paul Gesel <[email protected]>
Co-authored-by: Sebastian Castro <[email protected]>
Co-authored-by: Sebastian Jahr <[email protected]>
(cherry picked from commit dbf07b1)

# Conflicts:
#	moveit_plugins/moveit_ros_control_interface/CMakeLists.txt
#	moveit_plugins/moveit_ros_control_interface/src/controller_manager_plugin.cpp
mergify bot pushed a commit that referenced this pull request Feb 12, 2025
* Add logic to Ros2ControlManager to match ros2_control

Signed-off-by: Paul Gesel <[email protected]>

* Add Ros2ControlManager test

Signed-off-by: Paul Gesel <[email protected]>

* move simplifyControllerActivationDeactivation to function and add doxygen

Signed-off-by: Paul Gesel <[email protected]>

* move queue.pop_back up

Signed-off-by: Paul Gesel <[email protected]>

* Update moveit_plugins/moveit_ros_control_interface/src/controller_manager_plugin.cpp

Co-authored-by: Sebastian Castro <[email protected]>

* Update moveit_plugins/moveit_ros_control_interface/src/controller_manager_plugin.cpp

Co-authored-by: Sebastian Castro <[email protected]>

* Update moveit_plugins/moveit_ros_control_interface/src/controller_manager_plugin.cpp

Co-authored-by: Sebastian Castro <[email protected]>

* pr feedback

Signed-off-by: Paul Gesel <[email protected]>

* clang fixes

Signed-off-by: Paul Gesel <[email protected]>

---------

Signed-off-by: Paul Gesel <[email protected]>
Co-authored-by: Sebastian Castro <[email protected]>
Co-authored-by: Sebastian Jahr <[email protected]>
(cherry picked from commit dbf07b1)
@griswaldbrooks
Copy link
Contributor

How so?

@sea-bass
Copy link
Contributor

How so?

Damn, you got double sniped. I'm sorry :(

sea-bass pushed a commit that referenced this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble Mergify label that triggers a PR backport to Humble backport-jazzy Mergify label that triggers a PR backport to Jazzy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants