Example 10: Industrial robot with GPIO interfaces
This demo shows how to interact with GPIO interfaces.
The RRBot URDF files can be found in the description/urdf
folder.
To check that RRBot descriptions are working properly use following launch commands
ros2 launch ros2_control_demo_example_10 view_robot.launch.py
To start RRBot example open a terminal, source your ROS2-workspace and execute its launch file with
ros2 launch ros2_control_demo_example_10 rrbot.launch.py
The launch file loads and starts the robot hardware and controllers.
Check if the hardware interface loaded properly, by opening another terminal and executing
ros2 control list_hardware_interfaces
command interfaces flange_analog_IOs/analog_output1 [available] [claimed] flange_vacuum/vacuum [available] [claimed] joint1/position [available] [claimed] joint2/position [available] [claimed] state interfaces flange_analog_IOs/analog_input1 flange_analog_IOs/analog_input2 flange_analog_IOs/analog_output1 flange_vacuum/vacuum joint1/position joint2/position
In contrast to the RRBot of example_1, you see in addition to the joints now also GPIO interfaces.
Check if controllers are running by
ros2 control list_controllers
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active gpio_controller [ros2_control_demo_example_10/GPIOController] active forward_position_controller[forward_command_controller/ForwardCommandController] active
If you get output from above you can subscribe to the
/gpio_controller/inputs
topic published by the GPIO Controller using ROS 2 CLI interface:ros2 topic echo /gpio_controller/inputs
interface_names: - flange_analog_IOs/analog_output1 - flange_analog_IOs/analog_input1 - flange_analog_IOs/analog_input2 - flange_vacuum/vacuum values: - 0.0 - 1199574016.0 - 1676318848.0 - 0.0
Now you can send commands to the GPIO Controller using ROS 2 CLI interface:
ros2 topic pub /gpio_controller/commands std_msgs/msg/Float64MultiArray "{data: [0.5,0.7]}"
You should see a change in the
/gpio_controller/inputs
topic and a different output in the terminal where launch file is started, e.g.[RRBotSystemWithGPIOHardware]: Got command 0.5 for GP output 0! [RRBotSystemWithGPIOHardware]: Got command 0.7 for GP output 1!
Files used for this demos
Launch file: rrbot.launch.py
Controllers yaml: rrbot_controllers.yaml
URDF file: rrbot.urdf.xacro
Description: rrbot_description.urdf.xacro
ros2_control
tag: rrbot.ros2_control.xacro
RViz configuration: rrbot.rviz
Hardware interface plugin: rrbot.cpp
GPIO controller: gpio_controller.cpp
Controllers from this demo
Joint State Broadcaster
(ros2_controllers repository): docForward Command Controller
(ros2_controllers repository): doc