You're reading the documentation for a development version. For the latest released version, please have a look at Jazzy.
Example 14: Modular robot with actuators not providing states
The example shows how to implement robot hardware with separate communication to each actuator as well as separate sensors for position feedback:
The communication is done on actuator level using proprietary or standardized API (e.g., canopen_402, Modbus, RS232, RS485).
Data for all actuators and sensors is exchanged separately from each other
Examples: Arduino-based-robots, custom robots
This is implemented with hardware interfaces of type hardware_interface::ActuatorInterface
and hardware_interface::SensorInterface
.
Note
The commands below are given for a local installation of this repository and its dependencies as well as for running them from a docker container. For more information on the docker usage see Using Docker.
Tutorial steps
To check that RRBot descriptions are working properly use following launch commands
ros2 launch ros2_control_demo_example_14 view_robot.launch.py
Note
Getting the following output in terminal is OK:
Warning: Invalid frame ID "odom" passed to canTransform argument target_frame - frame does not exist
. This happens becausejoint_state_publisher_gui
node need some time to start. Thejoint_state_publisher_gui
provides a GUI to generate a random configuration for rrbot. It is immediately displayed in RViz.To start RRBot example open a terminal, source your ROS2-workspace and execute its launch file with
ros2 launch ros2_control_demo_example_14 rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.launch.py
The launch file loads and starts the robot hardware, controllers and opens RViz. In starting terminal you will see a lot of output from the hardware implementation showing its internal states. This is only of exemplary purposes and should be avoided as much as possible in a hardware interface implementation.
If you can see two orange and one yellow rectangle in in RViz everything has started properly. Still, to be sure, let’s introspect the control system before moving RRBot.
Check if the hardware interface loaded properly, by opening another terminal and executing
ros2 control list_hardware_interfaces
command interfaces joint1/position [available] [claimed] joint2/position [available] [claimed] state interfaces joint1/position joint2/position
Marker
[claimed]
by command interfaces means that a controller has access to command RRBot.Now, let’s introspect the hardware components with
ros2 control list_hardware_components
There are four hardware components, one for each actuator and one for each sensor:
Hardware Component 1 name: RRBotModularJoint2 type: actuator plugin name: ros2_control_demo_example_14/RRBotActuatorWithoutFeedback state: id=3 label=active command interfaces joint2/velocity [available] [claimed] Hardware Component 2 name: RRBotModularJoint1 type: actuator plugin name: ros2_control_demo_example_14/RRBotActuatorWithoutFeedback state: id=3 label=active command interfaces joint1/velocity [available] [claimed] Hardware Component 3 name: RRBotModularPositionSensorJoint2 type: sensor plugin name: ros2_control_demo_example_14/RRBotSensorPositionFeedback state: id=3 label=active command interfaces Hardware Component 4 name: RRBotModularPositionSensorJoint1 type: sensor plugin name: ros2_control_demo_example_14/RRBotSensorPositionFeedback state: id=3 label=active command interfaces
Check if controllers are running
ros2 control list_controllers
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active forward_velocity_controller[forward_command_controller/ForwardCommandController] active
If you get output from above you can send commands to Forward Command Controller:
ros2 topic pub /forward_velocity_controller/commands std_msgs/msg/Float64MultiArray "data: - 5 - 5"
You should now see orange and yellow blocks moving in RViz. Also, you should see changing states in the terminal where launch file is started, e.g.
[ros2_control_node-1] [INFO] [1728858168.276013464] [controller_manager.resource_manager.hardware_component.actuator.RRBotModularJoint1]: Writing... [ros2_control_node-1] Writing command: 5.00 [ros2_control_node-1] Sending data command: 5 [ros2_control_node-1] [ros2_control_node-1] [INFO] [1728858168.776052116] [controller_manager.resource_manager.hardware_component.actuator.RRBotModularJoint2]: Writing... [ros2_control_node-1] Writing command: 5.00 [ros2_control_node-1] Sending data command: 5 [ros2_control_node-1] [ros2_control_node-1] [INFO] [1728858169.275878132] [controller_manager.resource_manager.hardware_component.sensor.RRBotModularPositionSensorJoint1]: Reading... [ros2_control_node-1] Got measured velocity 5.00 [ros2_control_node-1] Got state 0.34 for joint 'joint1' [ros2_control_node-1] [ros2_control_node-1] [INFO] [1728858169.775863217] [controller_manager.resource_manager.hardware_component.sensor.RRBotModularPositionSensorJoint2]: Reading... [ros2_control_node-1] Got measured velocity 5.00 [ros2_control_node-1] Got state 0.29 for joint 'joint2' [ros2_control_node-1]
Files used for this demos
Launch file: rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.launch.py
Controllers yaml: rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.yaml
URDF: rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.urdf.xacro
Description: rrbot_description.urdf.xacro
ros2_control
URDF tag: rrbot_modular_actuators_without_feedback_sensors_for_position_feedback.ros2_control.xacro
RViz configuration: rrbot.rviz
Hardware interface plugins:
Controllers from this demo
Joint State Broadcaster
(ros2_controllers repository): docForward Command Controller
(ros2_controllers repository): doc