@@ -91,6 +91,103 @@ The *RRBot* URDF files can be found in the ``description/urdf`` folder.
9191 [RRBotSystemWithGPIOHardware]: Got command 0.5 for GP output 0!
9292 [RRBotSystemWithGPIOHardware]: Got command 0.7 for GP output 1!
9393
94+ 7. Let's introspect the ros2_control hardware component. Calling
95+
96+ .. code-block :: shell
97+
98+ ros2 control list_hardware_components
99+
100+ should give you
101+
102+ .. code-block :: shell
103+
104+ Hardware Component 1
105+ name: RRBot
106+ type: system
107+ plugin name: ros2_control_demo_example_10/RRBotSystemWithGPIOHardware
108+ state: id=3 label=active
109+ command interfaces
110+ joint1/position [available] [claimed]
111+ joint2/position [available] [claimed]
112+ flange_analog_IOs/analog_output1 [available] [claimed]
113+ flange_vacuum/vacuum [available] [claimed]
114+
115+ This shows that the custom hardware interface plugin is loaded and running. If you work on a real
116+ robot and don't have a simulator running, it is often faster to use the ``mock_components/GenericSystem ``
117+ hardware component instead of writing a custom one. Stop the launch file and start it again with
118+ an additional parameter
119+
120+ .. code-block :: shell
121+
122+ ros2 launch ros2_control_demo_example_10 rrbot.launch.py use_mock_hardware:=True
123+
124+ Calling ``list_hardware_components `` with the ``-v `` option
125+
126+ .. code-block :: shell
127+
128+ ros2 control list_hardware_components -v
129+
130+ now should give you
131+
132+ .. code-block :: shell
133+
134+ Hardware Component 1
135+ name: RRBot
136+ type: system
137+ plugin name: mock_components/GenericSystem
138+ state: id=3 label=active
139+ command interfaces
140+ joint1/position [available] [claimed]
141+ joint2/position [available] [claimed]
142+ flange_analog_IOs/analog_output1 [available] [claimed]
143+ flange_vacuum/vacuum [available] [claimed]
144+ state interfaces
145+ joint1/position [available]
146+ joint2/position [available]
147+ flange_analog_IOs/analog_output1 [available]
148+ flange_analog_IOs/analog_input1 [available]
149+ flange_analog_IOs/analog_input2 [available]
150+ flange_vacuum/vacuum [available]
151+
152+ One can see that the plugin ``mock_components/GenericSystem `` was now loaded instead: It will mirror the command interfaces to state interfaces with identical name. Call
153+
154+ .. code-block :: shell
155+
156+ ros2 topic echo /gpio_controller/inputs
157+
158+ again and you should see that - unless commands are received - the values of the state interfaces are now ``nan `` except for the vacuum interface.
159+
160+ .. code-block :: shell
161+
162+ interface_names:
163+ - flange_analog_IOs/analog_output1
164+ - flange_analog_IOs/analog_input1
165+ - flange_analog_IOs/analog_input2
166+ - flange_vacuum/vacuum
167+ values:
168+ - .nan
169+ - .nan
170+ - .nan
171+ - 1.0
172+
173+ This is, because for the vacuum interface an initial value of ``1.0 `` is set in the URDF file.
174+
175+ .. code-block :: xml
176+
177+ <gpio name =" flange_vacuum" >
178+ <command_interface name =" vacuum" />
179+ <state_interface name =" vacuum" >
180+ <param name =" initial_value" >1.0</param >
181+ </state_interface >
182+ </gpio >
183+
184+ Call again
185+
186+ .. code-block :: shell
187+
188+ ros2 topic pub /gpio_controller/commands std_msgs/msg/Float64MultiArray " {data: [0.5,0.7]}"
189+
190+ and you will see that the GPIO command interfaces will be mirrored to their respective state interfaces.
94191
95192Files used for this demos
96193-------------------------
@@ -104,7 +201,11 @@ Files used for this demos
104201
105202- RViz configuration: `rrbot.rviz <https://github.com/ros-controls/ros2_control_demos/tree/{REPOS_FILE_BRANCH}/ros2_control_demo_description/rrbot/rviz/rrbot.rviz >`__
106203
107- - Hardware interface plugin: `rrbot.cpp <https://github.com/ros-controls/ros2_control_demos/tree/{REPOS_FILE_BRANCH}/example_10/hardware/rrbot.cpp >`__
204+ - Hardware interface plugin:
205+
206+ + `rrbot.cpp <https://github.com/ros-controls/ros2_control_demos/tree/{REPOS_FILE_BRANCH}/example_10/hardware/rrbot.cpp >`__
207+ + `generic_system.cpp <https://github.com/ros-controls/ros2_control/tree/{REPOS_FILE_BRANCH}/hardware_interface/src/mock_components/generic_system.cpp >`__
208+
108209- GPIO controller: `gpio_controller.cpp <https://github.com/ros-controls/ros2_control_demos/tree/{REPOS_FILE_BRANCH}/example_10/controllers/gpio_controller.cpp >`__
109210
110211
0 commit comments