ros-controls / ros2_controllers

Generic robotic controllers to accompany ros2_control
https://control.ros.org
Apache License 2.0
356 stars 319 forks source link

[JTC] Add Parameter to Toggle State Setting on Activation #1231

Open KentaKato opened 2 months ago

KentaKato commented 2 months ago

This pull request introduces a new parameter in the JointTrajectoryController that enables toggling whether the last command interface value should be set as both the current_state and last_commanded_state upon activation.

Motivation

Consider a scenario where there is a transition from a JTC to another controller and back to a JTC. Due to the implementation specifics of the intermediary controller, it is possible that the command interface values from the first JTC remain. This can lead to dangerous situations where, upon reactivation, the second JTC inadvertently uses these stale command values to command the hardware.

To mitigate this risk, I have added an option within the JTC that ensures command values are reliably reset to reflect the current state upon activation, enhancing system safety.

KentaKato commented 1 month ago

Hi, I wanted to kindly ask if there’s a chance for this pull request to be reviewed. Any feedback would be greatly appreciated. Thank you!

destogl commented 1 month ago

Wait, I am not sure about this. Can you detail the scenario more. Are you using open loop?

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 80.35%. Comparing base (50036e1) to head (7b0ca32).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1231 +/- ## ========================================== - Coverage 80.36% 80.35% -0.01% ========================================== Files 105 105 Lines 9390 9394 +4 Branches 828 829 +1 ========================================== + Hits 7546 7549 +3 Misses 1570 1570 - Partials 274 275 +1 ``` | [Flag](https://app.codecov.io/gh/ros-controls/ros2_controllers/pull/1231/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_controllers/pull/1231/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | `80.35% <100.00%> (-0.01%)` | :arrow_down: | 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 with missing lines](https://app.codecov.io/gh/ros-controls/ros2_controllers/pull/1231?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls) | Coverage Δ | | |---|---|---| | [...ory\_controller/src/joint\_trajectory\_controller.cpp](https://app.codecov.io/gh/ros-controls/ros2_controllers/pull/1231?src=pr&el=tree&filepath=joint_trajectory_controller%2Fsrc%2Fjoint_trajectory_controller.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls#diff-am9pbnRfdHJhamVjdG9yeV9jb250cm9sbGVyL3NyYy9qb2ludF90cmFqZWN0b3J5X2NvbnRyb2xsZXIuY3Bw) | `84.03% <100.00%> (+0.19%)` | :arrow_up: | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/ros-controls/ros2_controllers/pull/1231/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ros-controls)
KentaKato commented 1 month ago

@destogl Thank you for your review!


We are not using open-loop control. We are creating a closed-loop controller called joint_impedance_controller. This controller only has the effort command_interface and does not have the pos/vel/acc command_interfaces.

Scenario:

  1. Activate JTC.
  2. Switch to joint_impedance_controller and change the arm's position.
    • At this point, the position command_interface is not updated from step 1.
  3. Switch to JTC again.
    • The position command_interface from the final position in step 1 remains. With the current implementation, this position gets set to state_current_ and last_command_state_.
KentaKato commented 1 month ago

@christophfroehlich Thank you for your review! I’ve added the note as you suggested. I appreciate your feedback!

bmagyar commented 3 weeks ago

@christophfroehlich , are we good?

KentaKato commented 1 week ago

@bmagyar @christophfroehlich friendly ping!