cyberbotics / webots_ros2

Webots ROS 2 packages
Apache License 2.0
389 stars 141 forks source link

implemented perform_command_mode_switch override in Ros2ControlSystem #846

Open ralphieraccoon opened 10 months ago

ralphieraccoon commented 10 months ago

Description Reusing the solution from here for Gazebo to allow for multiple command interfaces. Implements the perform_command_mode_switch method override to set joint control methods when controllers are activated/deactivated. Can't work out how to detect if a command interface is claimed inside Ros2ControlSystem::init() so you either have to run switch_controllers once to call the function or start with a position controller.

Related Issues This pull request references the discussion #845 I started earlier.

Affected Packages

Tasks

Additional context Credit to @ksotebeer for the original PR for gazebo_ros2_control.

ralphieraccoon commented 9 months ago

I'm not sure if discovering which command interfaces are claimed inside Ros2ControlSystem::init() is possible since it doesn't provide access to the ResourceManager which has this function. To make it work might require changes to the ros2_control base class. I can take this PR out of draft as is and the problem could be solved at a later date, what would be best?

omichel commented 9 months ago

I would prefer that you test and eventually solve the problem in this PR, rather than committing something which is unfinished or buggy.

ralphieraccoon commented 9 months ago

I would prefer that you test and eventually solve the problem in this PR, rather than committing something which is unfinished or buggy.

That's fair, though at the moment I'm not sure the issue is fixable without alterations to ros2_control. The PR doesn't break existing functionality, if a single command interface is used it works the same as before, and the issue can be worked around by calling switch_controllers. If anyone has any suggestions on how to solve the issue, it would be greatly appreciated.