ros-controls / ros2_control

Generic and simple controls framework for ROS 2
https://control.ros.org
Apache License 2.0
433 stars 272 forks source link

Controller restart by switch_controller (minimal implementation) #1592

Open TakashiSato opened 1 week ago

TakashiSato commented 1 week ago

This PR is related to #1568. Unlike it, this focuses on implementing the new restart controllers feature while minimizing changes to the master branch code. Additionally, this PR depends on #1591 and is expected to be merged after #1591 is merged.

Note: To focus on meaningful changes, it is recommended to compare the code using "hide whitespace" mode as follows. https://github.com/ros-controls/ros2_control/compare/master...TakashiSato:ros2_control:feature/restart_controllers_minimal?diff=split&w=1

Explanation code changes

Since comparing the final code changes with the master branch is complicated due to the large number of changes, I'll explain the key points of each change in the order of the commits. The changes up to commit number 005a79fb7b961d3237e1b02b3edf0521ed866b61 are included in #1591, so I will only address the commits after that.

1. refactor (de)activate request checkrefactor (de)activate request check

In this commit, the following refactoring was performed:

2. add to support restart operations in switch_controller by specifying the same controller name in the start/stop requests

This commit implements the restart controllers feature and its tests.

To achieve the behavior of restart (deactivating first and then activating), I mainly made changes in the followings:

I made the following changes to the test implementation:

fix typo and unnecessary semicolon

This commit contains minor fixes.

codecov[bot] commented 4 days ago

Codecov Report

Attention: Patch coverage is 98.72123% with 5 lines in your changes missing coverage. Please review.

Project coverage is 88.36%. Comparing base (fbb893b) to head (4dbe584). Report is 7 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1592 +/- ## ========================================== + Coverage 87.70% 88.36% +0.66% ========================================== Files 102 105 +3 Lines 8704 8262 -442 Branches 780 675 -105 ========================================== - Hits 7634 7301 -333 + Misses 790 720 -70 + Partials 280 241 -39 ``` | [Flag](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | `88.36% <98.72%> (+0.66%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | Coverage Δ | | |---|---|---| | [.../include/controller\_manager/controller\_manager.hpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Finclude%2Fcontroller_manager%2Fcontroller_manager.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL2luY2x1ZGUvY29udHJvbGxlcl9tYW5hZ2VyL2NvbnRyb2xsZXJfbWFuYWdlci5ocHA=) | `100.00% <ø> (ø)` | | | [...chainable\_controller/test\_chainable\_controller.cpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_chainable_controller%2Ftest_chainable_controller.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9jaGFpbmFibGVfY29udHJvbGxlci90ZXN0X2NoYWluYWJsZV9jb250cm9sbGVyLmNwcA==) | `85.24% <100.00%> (+1.03%)` | :arrow_up: | | [...chainable\_controller/test\_chainable\_controller.hpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_chainable_controller%2Ftest_chainable_controller.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9jaGFpbmFibGVfY29udHJvbGxlci90ZXN0X2NoYWluYWJsZV9jb250cm9sbGVyLmhwcA==) | `100.00% <ø> (ø)` | | | [...r\_manager/test/test\_controller/test\_controller.cpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_controller%2Ftest_controller.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9jb250cm9sbGVyL3Rlc3RfY29udHJvbGxlci5jcHA=) | `95.45% <100.00%> (+0.71%)` | :arrow_up: | | [...r\_manager/test/test\_controller/test\_controller.hpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_controller%2Ftest_controller.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9jb250cm9sbGVyL3Rlc3RfY29udHJvbGxlci5ocHA=) | `100.00% <ø> (ø)` | | | [...ller\_with\_command/test\_controller\_with\_command.hpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_controller_with_command%2Ftest_controller_with_command.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9jb250cm9sbGVyX3dpdGhfY29tbWFuZC90ZXN0X2NvbnRyb2xsZXJfd2l0aF9jb21tYW5kLmhwcA==) | `100.00% <100.00%> (ø)` | | | [...t\_controllers\_chaining\_with\_controller\_manager.cpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_controllers_chaining_with_controller_manager.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9jb250cm9sbGVyc19jaGFpbmluZ193aXRoX2NvbnRyb2xsZXJfbWFuYWdlci5jcHA=) | `99.32% <100.00%> (+0.47%)` | :arrow_up: | | [...ontroller\_manager/test/test\_restart\_controller.cpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_restart_controller.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9yZXN0YXJ0X2NvbnRyb2xsZXIuY3Bw) | `100.00% <100.00%> (ø)` | | | [...ller\_with\_command/test\_controller\_with\_command.cpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Ftest%2Ftest_controller_with_command%2Ftest_controller_with_command.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3Rlc3QvdGVzdF9jb250cm9sbGVyX3dpdGhfY29tbWFuZC90ZXN0X2NvbnRyb2xsZXJfd2l0aF9jb21tYW5kLmNwcA==) | `88.23% <88.23%> (ø)` | | | [controller\_manager/src/controller\_manager.cpp](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592?src=pr&el=tree&filepath=controller_manager%2Fsrc%2Fcontroller_manager.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-Y29udHJvbGxlcl9tYW5hZ2VyL3NyYy9jb250cm9sbGVyX21hbmFnZXIuY3Bw) | `72.48% <94.82%> (-2.08%)` | :arrow_down: | ... and [7 files with indirect coverage changes](https://app.codecov.io/gh/ros-controls/ros2_control/pull/1592/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls)
mergify[bot] commented 2 days ago

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