Switching between controllers with ros_control / controller_manager
Is there an easy way to switch between different controllers for a single resource?
I would like to control a joint of my Gazebo model either by effort_controllers/JointPositionController
or effort_controllers/JointEffortController
. I want to switch between these controllers during runtime by pressing a joystick button.
Right now, I make 4 service calls:
- Stop the current controller (by calling
controller_manager/switch_controller
) - Unload the current controller (by calling
controller_manager/unload_controller
) - Load the new controller (by calling
controller_manager/load_controller
) - Start the new controller (by calling
controller_manager/switch_controller
again)
Is there an easier way to do that, like loading both controllers at the same time and only start/stop the corresponding controllers by a single switch_controller
call? As the SwitchController Service has parameters for both start_controllers and stop_controllers, this seems to be supported somehow. But if I try to spawn both controllers in a launch file, I get a "resource conflict" error.