| github_url: | https://github.com/ros-controls/ros2_control_demos/blob/{REPOS_FILE_BRANCH}/example_15/doc/userdoc.rst |
|---|
This example shows how to integrate multiple robots under different controller manager instances.
Note
When running ros2 control CLI commands you have to use additional parameter with exact controller manager node name, i.e., -c /rrbot/controller_manager.
Launch the example with
ros2 launch ros2_control_demo_example_15 rrbot_namespace.launch.py- Command interfaces:
- joint1/position
- joint2/position
- State interfaces:
- joint1/position
- joint2/position
Available controllers: (nodes under namespace "/rrbot")
$ ros2 control list_controllers -c /rrbot/controller_manager
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active
forward_position_controller[forward_command_controller/ForwardCommandController] active
position_trajectory_controller[joint_trajectory_controller/JointTrajectoryController] inactiveCommanding the robot using a ForwardCommandController (name: /rrbot/forward_position_controller)
ros2 launch ros2_control_demo_example_15 test_forward_position_controller.launch.py publisher_config:=rrbot_namespace_forward_position_publisher.yamlAbort the command and switch controller to use JointTrajectoryController (name: /rrbot/position_trajectory_controller):
ros2 control switch_controllers -c /rrbot/controller_manager --deactivate forward_position_controller --activate position_trajectory_controllerCommanding the robot using JointTrajectoryController (name: /rrbot/position_trajectory_controller)
ros2 launch ros2_control_demo_example_15 test_joint_trajectory_controller.launch.py publisher_config:=rrbot_namespace_joint_trajectory_publisher.yamlFiles used for this demo:
- Launch file: rrbot_namespace.launch.py
- Controllers yaml: rrbot_namespace_controllers.yaml
- URDF file: rrbot.urdf.xacro
- Description: rrbot_description.urdf.xacro
ros2_controltag: rrbot.ros2_control.xacro
- RViz configuration: rrbot.rviz
- Test nodes goals configuration:
- Hardware interface plugin: rrbot.cpp
Note
When running ros2 control CLI commands you have to use additional parameter with exact controller manager node name, e.g., -c /rrbot_1/controller_manager or -c /rrbot_2/controller_manager.
Launch the example with
ros2 launch ros2_control_demo_example_15 multi_controller_manager_example_two_rrbots.launch.pyYou should see two robots in RViz:
rrbot_1 namespace:
- Command interfaces:
- rrbot_1_joint1/position
- rrbot_1_joint2/position
- State interfaces:
- rrbot_1_joint1/position
- rrbot_1_joint2/position
rrbot_2 namespace:
- Command interfaces:
- rrbot_2_joint1/position
- rrbot_2_joint2/position
- State interfaces:
- rrbot_2_joint1/position
- rrbot_2_joint2/position
Available controllers (nodes under namespace /rrbot_1 and /rrbot_2):
$ ros2 control list_controllers -c /rrbot_1/controller_manager
position_trajectory_controller[joint_trajectory_controller/JointTrajectoryController] inactive
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active
forward_position_controller[forward_command_controller/ForwardCommandController] active
$ ros2 control list_controllers -c /rrbot_2/controller_manager
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active
position_trajectory_controller[joint_trajectory_controller/JointTrajectoryController] inactive
forward_position_controller[forward_command_controller/ForwardCommandController] activeCommanding the robots using the forward_position_controller (of type ForwardCommandController)
ros2 launch ros2_control_demo_example_15 test_multi_controller_manager_forward_position_controller.launch.pySwitch controller to use the position_trajectory_controller (of type JointTrajectoryController) - alternatively start main launch file with argument robot_controller:=position_trajectory_controller:
ros2 control switch_controllers -c /rrbot_1/controller_manager --deactivate forward_position_controller --activate position_trajectory_controller
ros2 control switch_controllers -c /rrbot_2/controller_manager --deactivate forward_position_controller --activate position_trajectory_controllerCommanding the robots using the now activated position_trajectory_controller:
ros2 launch ros2_control_demo_example_15 test_multi_controller_manager_joint_trajectory_controller.launch.pyFiles used for this demo:
- Launch file: multi_controller_manager_example_two_rrbots.launch.py
- Controllers yaml: - multi_controller_manager_rrbot_generic_controllers.yaml
- URDF file: rrbot.urdf.xacro
- Description: rrbot_description.urdf.xacro
ros2_controltag: rrbot.ros2_control.xacro
- RViz configuration: rrbot.rviz
- Test nodes goals configuration:
- Hardware interface plugin: rrbot.cpp
Joint State Broadcaster(ros2_controllers repository): docForward Command Controller(ros2_controllers repository): docJoint Trajectory Controller(ros2_controllers repository): doc
