Controller restart by switch_controller (minimal implementation) #1592
+1,642
−120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 005a79f 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:
CreateRequestResult
toCheckDeActivateRequestResult
and moved its definition from inside switch_controller to within the class definition in the header (private).clear_chained_mode_request
from inside switch_controller to a member function, and changed the part of clear_requests that performed the same processing to this function call.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:
deactivate_request
andactivate_request
to ensure requests for restart (deactivate first, then activate) are not rejected as invalid requests.chained_mode_request
duringmanage_switch
to process them in the order of from and to.reference_interfaces
can be used appropriately when the following controller is activated immediately after being deactivated, modified thedeactivate_controllers
function not to executemake_controller_reference_interfaces_unavailable
during restart requests.I made the following changes to the test implementation:
test_controller
test_chainable_controller
fix typo and unnecessary semicolon
This commit contains minor fixes.