|
| 1 | +*************************************************** |
| 2 | +Example 4: Industrial robot with integrated sensor |
| 3 | +*************************************************** |
| 4 | + |
| 5 | +This example shows how a sensor can be integrated in a hardware interface of system-type: |
| 6 | +A 2D Force-Torque Sensor (FTS) is simulated by generating random sensor readings. |
| 7 | + |
| 8 | +1. To check that *RRBot* descriptions are working properly use following launch commands |
| 9 | + |
| 10 | + .. code-block:: shell |
| 11 | +
|
| 12 | + ros2 launch ros2_control_demo_example_4 view_robot.launch.py |
| 13 | +
|
| 14 | + **NOTE**: Getting the following output in terminal is OK: ``Warning: Invalid frame ID "odom" passed to canTransform argument target_frame - frame does not exist``. |
| 15 | + This happens because ``joint_state_publisher_gui`` node need some time to start. |
| 16 | + The ``joint_state_publisher_gui`` provides a GUI to generate a random configuration for rrbot. It is immediately displayed in *RViz*. |
| 17 | + |
| 18 | + |
| 19 | +2. To start *RRBot* example open a terminal, source your ROS2-workspace and execute its launch file with |
| 20 | + |
| 21 | + .. code-block:: shell |
| 22 | +
|
| 23 | + ros2 launch ros2_control_demo_example_4 rrbot_system_with_sensor.launch.py |
| 24 | +
|
| 25 | + The launch file loads and starts the robot hardware, controllers and opens *RViz*. |
| 26 | + In starting terminal you will see a lot of output from the hardware implementation showing its internal states. |
| 27 | + This is only of exemplary purposes and should be avoided as much as possible in a hardware interface implementation. |
| 28 | + |
| 29 | + If you can see two orange and one yellow rectangle in in *RViz* everything has started properly. |
| 30 | + Still, to be sure, let's introspect the control system before moving *RRBot*. |
| 31 | + |
| 32 | +3. Check if the hardware interface loaded properly, by opening another terminal and executing |
| 33 | + |
| 34 | + .. code-block:: shell |
| 35 | +
|
| 36 | + ros2 control list_hardware_interfaces |
| 37 | +
|
| 38 | + .. code-block:: shell |
| 39 | +
|
| 40 | + command interfaces |
| 41 | + joint1/position [available] [claimed] |
| 42 | + joint2/position [available] [claimed] |
| 43 | + state interfaces |
| 44 | + joint1/position |
| 45 | + joint2/position |
| 46 | + tcp_fts_sensor/force.x |
| 47 | + tcp_fts_sensor/torque.z |
| 48 | +
|
| 49 | + Marker ``[claimed]`` by command interfaces means that a controller has access to command *RRBot*. |
| 50 | + |
| 51 | +4. Check is controllers are running |
| 52 | + |
| 53 | + .. code-block:: shell |
| 54 | +
|
| 55 | + ros2 control list_controllers |
| 56 | +
|
| 57 | + .. code-block:: shell |
| 58 | +
|
| 59 | + joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active |
| 60 | + fts_broadcaster [force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster] active |
| 61 | + forward_position_controller[forward_command_controller/ForwardCommandController] active |
| 62 | +
|
| 63 | +5. If you get output from above you can send commands to *Forward Command Controller*, either: |
| 64 | + |
| 65 | + #. Manually using ros2 cli interface. |
| 66 | + |
| 67 | + .. code-block:: shell |
| 68 | +
|
| 69 | + ros2 topic pub /forward_position_controller/commands std_msgs/msg/Float64MultiArray "data: |
| 70 | + - 0.5 |
| 71 | + - 0.5" |
| 72 | +
|
| 73 | + #. Or you can start a demo node which sends two goals every 5 seconds in a loop |
| 74 | + |
| 75 | + .. code-block:: shell |
| 76 | +
|
| 77 | + ros2 launch ros2_control_demo_example_4 test_forward_position_controller.launch.py |
| 78 | +
|
| 79 | + You should now see orange and yellow blocks moving in *RViz*. |
| 80 | + Also, you should see changing states in the terminal where launch file is started, e.g. |
| 81 | + |
| 82 | + .. code-block:: shell |
| 83 | +
|
| 84 | + [RRBotSystemWithSensorHardware]: Got command 0.50000 for joint 0! |
| 85 | + [RRBotSystemWithSensorHardware]: Got command 0.50000 for joint 1! |
| 86 | +
|
| 87 | +6. Access wrench data from 2D FTS via |
| 88 | + |
| 89 | + .. code-block:: shell |
| 90 | +
|
| 91 | + ros2 topic echo /fts_broadcaster/wrench |
| 92 | +
|
| 93 | + shows the random generated sensor values, republished by *Force Torque Sensor Broadcaster* as |
| 94 | + ``geometry_msgs/msg/WrenchStamped`` message |
| 95 | + |
| 96 | + .. code-block:: shell |
| 97 | +
|
| 98 | + header: |
| 99 | + stamp: |
| 100 | + sec: 1676444704 |
| 101 | + nanosec: 332221422 |
| 102 | + frame_id: tool_link |
| 103 | + wrench: |
| 104 | + force: |
| 105 | + x: 2.946532964706421 |
| 106 | + y: .nan |
| 107 | + z: .nan |
| 108 | + torque: |
| 109 | + x: .nan |
| 110 | + y: .nan |
| 111 | + z: 4.0540995597839355 |
| 112 | +
|
| 113 | + .. warning:: |
| 114 | + Wrench messages are not displayed properly in *RViz* as NaN values are not handled in *RViz* and FTS Broadcaster may send NaN values. |
| 115 | + |
| 116 | + |
| 117 | +Files used for this demo |
| 118 | +######################### |
| 119 | + |
| 120 | +- Launch file: `rrbot_system_with_sensor.launch.py <https://github.com/ros-controls/ros2_control_demos/example_4/bringup/launch/rrbot_system_with_sensor.launch.py>`__ |
| 121 | +- Controllers yaml: `rrbot_with_sensor_controllers.yaml <https://github.com/ros-controls/ros2_control_demos/example_4/bringup/config/rrbot_with_sensor_controllers.yaml>`__ |
| 122 | +- URDF: `rrbot_system_with_sensor.urdf.xacro <https://github.com/ros-controls/ros2_control_demos/example_4/description/urdf/rrbot_system_with_sensor.urdf.xacro>`__ |
| 123 | + |
| 124 | + + ``ros2_control`` URDF tag: `rrbot_system_with_sensor.ros2_control.xacro <https://github.com/ros-controls/ros2_control_demos/example_4/description/ros2_control/rrbot_system_with_sensor.ros2_control.xacro>`__ |
| 125 | + |
| 126 | +- RViz configuration: `rrbot.rviz <https://github.com/ros-controls/ros2_control_demos/example_4/description/rviz/rrbot.rviz>`__ |
| 127 | +- Hardware interface plugin: `rrbot_system_with_sensor.cpp <https://github.com/ros-controls/ros2_control_demos/example_4/hardware/rrbot_system_with_sensor.cpp>`__ |
| 128 | + |
| 129 | + |
| 130 | +Controllers from this demo |
| 131 | +########################## |
| 132 | +- ``Joint State Broadcaster`` (`ros2_controllers repository <https://github.com/ros-controls/ros2_controllers>`__): `doc <https://control.ros.org/master/doc/ros2_controllers/joint_state_broadcaster/doc/userdoc.html>`__ |
| 133 | +- ``Forward Command Controller`` (`ros2_controllers repository <https://github.com/ros-controls/ros2_controllers>`__): `doc <https://control.ros.org/master/doc/ros2_controllers/forward_command_controller/doc/userdoc.html>`__ |
| 134 | +- ``Force Torque Sensor Broadcaster`` (`ros2_controllers repository <https://github.com/ros-controls/ros2_controllers>`__): `doc <https://control.ros.org/master/doc/ros2_controllers/force_torque_sensor_broadcaster/doc/userdoc.html>`__ |
0 commit comments