ros2_control - humble
Loading...
Searching...
No Matches
descriptions.hpp
1// Copyright 2020 ros2_control Development Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef ROS2_CONTROL_TEST_ASSETS__DESCRIPTIONS_HPP_
16#define ROS2_CONTROL_TEST_ASSETS__DESCRIPTIONS_HPP_
17
18#include <string>
19#include <vector>
20
21namespace ros2_control_test_assets
22{
23const auto urdf_head =
24 R"(
25<?xml version="1.0" encoding="utf-8"?>
26<!-- =================================================================================== -->
27<!-- | This document was autogenerated by xacro from minimal_robot.urdf.xacro | -->
28<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
29<!-- =================================================================================== -->
30<robot name="MinimalRobot">
31 <!-- Used for fixing robot -->
32 <link name="world"/>
33 <joint name="base_joint" type="fixed">
34 <origin rpy="0 0 0" xyz="0 0 0"/>
35 <parent link="world"/>
36 <child link="base_link"/>
37 </joint>
38 <link name="base_link">
39 <inertial>
40 <mass value="0.01"/>
41 <origin xyz="0 0 0"/>
42 <inertia ixx="0.001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.001"/>
43 </inertial>
44 <visual>
45 <origin rpy="0 0 0" xyz="0 0 0"/>
46 <geometry>
47 <cylinder length="0.2" radius="0.1"/>
48 </geometry>
49 <material name="DarkGrey">
50 <color rgba="0.4 0.4 0.4 1.0"/>
51 </material>
52 </visual>
53 <collision>
54 <origin rpy="0 0 0" xyz="0 0 0"/>
55 <geometry>
56 <cylinder length="1" radius="0.1"/>
57 </geometry>
58 </collision>
59 </link>
60 <joint name="joint1" type="revolute">
61 <origin rpy="-1.57079632679 0 0" xyz="0 0 0.2"/>
62 <parent link="base_link"/>
63 <child link="link1"/>
64 <limit effort="0.1" lower="-3.14159265359" upper="3.14159265359" velocity="0.2"/>
65 </joint>
66 <link name="link1">
67 <inertial>
68 <mass value="0.01"/>
69 <origin xyz="0 0 0"/>
70 <inertia ixx="0.001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.001"/>
71 </inertial>
72 <visual>
73 <origin rpy="0 0 0" xyz="0 0 0"/>
74 <geometry>
75 <cylinder length="1" radius="0.1"/>
76 </geometry>
77 <material name="DarkGrey">
78 <color rgba="0.4 0.4 0.4 1.0"/>
79 </material>
80 </visual>
81 <collision>
82 <origin rpy="0 0 0" xyz="0 0 0"/>
83 <geometry>
84 <cylinder length="1" radius="0.1"/>
85 </geometry>
86 </collision>
87 </link>
88 <joint name="joint2" type="revolute">
89 <origin rpy="1.57079632679 0 0" xyz="0 0 0.9"/>
90 <parent link="link1"/>
91 <child link="link2"/>
92 <limit effort="0.1" lower="-3.14159265359" upper="3.14159265359" velocity="0.2"/>
93 </joint>
94 <link name="link2">
95 <inertial>
96 <mass value="0.01"/>
97 <origin xyz="0 0 0"/>
98 <inertia ixx="0.001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.001"/>
99 </inertial>
100 <visual>
101 <origin rpy="0 0 0" xyz="0 0 0"/>
102 <geometry>
103 <cylinder length="1" radius="0.1"/>
104 </geometry>
105 <material name="DarkGrey">
106 <color rgba="0.4 0.4 0.4 1.0"/>
107 </material>
108 </visual>
109 <collision>
110 <origin rpy="0 0 0" xyz="0 0 0"/>
111 <geometry>
112 <cylinder length="1" radius="0.1"/>
113 </geometry>
114 </collision>
115 </link>
116 <joint name="tool_joint" type="fixed">
117 <origin rpy="0 0 0" xyz="0 0 1"/>
118 <parent link="link2"/>
119 <child link="tool_link"/>
120 </joint>
121 <link name="tool_link">
122 </link>
123)";
124
125const auto urdf_tail =
126 R"(
127</robot>
128)";
129
130const auto hardware_resources =
131 R"(
132 <ros2_control name="TestActuatorHardware" type="actuator">
133 <hardware>
134 <plugin>test_actuator</plugin>
135 </hardware>
136 <joint name="joint1">
137 <command_interface name="position"/>
138 <state_interface name="position"/>
139 <state_interface name="velocity"/>
140 <command_interface name="max_velocity" />
141 </joint>
142 </ros2_control>
143 <ros2_control name="TestSensorHardware" type="sensor">
144 <hardware>
145 <plugin>test_sensor</plugin>
146 <param name="example_param_write_for_sec">2</param>
147 <param name="example_param_read_for_sec">2</param>
148 </hardware>
149 <sensor name="sensor1">
150 <state_interface name="velocity"/>
151 </sensor>
152 </ros2_control>
153 <ros2_control name="TestSystemHardware" type="system">
154 <hardware>
155 <plugin>test_system</plugin>
156 <param name="example_param_write_for_sec">2</param>
157 <param name="example_param_read_for_sec">2</param>
158 </hardware>
159 <joint name="joint2">
160 <command_interface name="velocity"/>
161 <state_interface name="position"/>
162 <state_interface name="velocity"/>
163 <state_interface name="acceleration"/>
164 <command_interface name="max_acceleration" />
165 </joint>
166 <joint name="joint3">
167 <command_interface name="velocity"/>
168 <state_interface name="position"/>
169 <state_interface name="velocity"/>
170 <state_interface name="acceleration"/>
171 </joint>
172 <joint name="configuration">
173 <command_interface name="max_tcp_jerk"/>
174 <state_interface name="max_tcp_jerk"/>
175 </joint>
176 </ros2_control>
177)";
178
179const auto unitilizable_hardware_resources =
180 R"(
181 <ros2_control name="TestUnitilizableActuatorHardware" type="actuator">
182 <hardware>
183 <plugin>test_unitilizable_actuator</plugin>
184 </hardware>
185 <joint name="joint1">
186 <command_interface name="position"/>
187 <state_interface name="position"/>
188 <state_interface name="velocity"/>
189 <command_interface name="max_velocity" />
190 </joint>
191 </ros2_control>
192 <ros2_control name="TestUnitilizableSensorHardware" type="sensor">
193 <hardware>
194 <plugin>test_unitilizable_sensor</plugin>
195 <param name="example_param_write_for_sec">2</param>
196 <param name="example_param_read_for_sec">2</param>
197 </hardware>
198 <sensor name="sensor1">
199 <state_interface name="velocity"/>
200 </sensor>
201 </ros2_control>
202 <ros2_control name="TestUnitilizableSystemHardware" type="system">
203 <hardware>
204 <plugin>test_unitilizable_system</plugin>
205 <param name="example_param_write_for_sec">2</param>
206 <param name="example_param_read_for_sec">2</param>
207 </hardware>
208 <joint name="joint2">
209 <command_interface name="velocity"/>
210 <state_interface name="position"/>
211 <state_interface name="velocity"/>
212 <state_interface name="acceleration"/>
213 <command_interface name="max_acceleration" />
214 </joint>
215 <joint name="joint3">
216 <command_interface name="velocity"/>
217 <state_interface name="position"/>
218 <state_interface name="velocity"/>
219 <state_interface name="acceleration"/>
220 </joint>
221 <joint name="configuration">
222 <command_interface name="max_tcp_jerk"/>
223 <state_interface name="max_tcp_jerk"/>
224 </joint>
225 </ros2_control>
226)";
227
228const auto hardware_resources_missing_state_keys =
229 R"(
230 <ros2_control name="TestActuatorHardware" type="actuator">
231 <hardware>
232 <plugin>test_actuator</plugin>
233 </hardware>
234 <joint name="joint1">
235 <command_interface name="position"/>
236 <state_interface name="position"/>
237 <state_interface name="velocity"/>
238 </joint>
239 </ros2_control>
240 <ros2_control name="TestSensorHardware" type="sensor">
241 <hardware>
242 <plugin>test_sensor</plugin>
243 <param name="example_param_write_for_sec">2</param>
244 <param name="example_param_read_for_sec">2</param>
245 </hardware>
246 <sensor name="sensor1">
247 <state_interface name="velocity"/>
248 <state_interface name="does_not_exist"/>
249 </sensor>
250 </ros2_control>
251 <ros2_control name="TestSystemHardware" type="system">
252 <hardware>
253 <plugin>test_system</plugin>
254 <param name="example_param_write_for_sec">2</param>
255 <param name="example_param_read_for_sec">2</param>
256 </hardware>
257 <joint name="joint2">
258 <command_interface name="velocity"/>
259 <state_interface name="position"/>
260 <state_interface name="does_not_exist"/>
261 </joint>
262 <joint name="joint3">
263 <command_interface name="velocity"/>
264 <state_interface name="position"/>
265 <state_interface name="does_not_exist"/>
266 </joint>
267 </ros2_control>
268)";
269
270const auto hardware_resources_missing_command_keys =
271 R"(
272 <ros2_control name="TestActuatorHardware" type="actuator">
273 <hardware>
274 <plugin>test_actuator</plugin>
275 </hardware>
276 <joint name="joint1">
277 <command_interface name="position"/>
278 <command_interface name="does_not_exist"/>
279 <state_interface name="position"/>
280 <state_interface name="velocity"/>
281 </joint>
282 </ros2_control>
283 <ros2_control name="TestSensorHardware" type="sensor">
284 <hardware>
285 <plugin>test_sensor</plugin>
286 <param name="example_param_write_for_sec">2</param>
287 <param name="example_param_read_for_sec">2</param>
288 </hardware>
289 <sensor name="sensor1">
290 <state_interface name="velocity"/>
291 </sensor>
292 </ros2_control>
293 <ros2_control name="TestSystemHardware" type="system">
294 <hardware>
295 <plugin>test_system</plugin>
296 <param name="example_param_write_for_sec">2</param>
297 <param name="example_param_read_for_sec">2</param>
298 </hardware>
299 <joint name="joint2">
300 <command_interface name="velocity"/>
301 <command_interface name="does_not_exist"/>
302 <state_interface name="position"/>
303 </joint>
304 <joint name="joint3">
305 <command_interface name="velocity"/>
306 <command_interface name="does_not_exist"/>
307 <state_interface name="position"/>
308 </joint>
309 </ros2_control>
310)";
311
312const auto hardware_resources_missing_gpio_state_keys =
313 R"(
314 <ros2_control name="TestSystemHardware" type="system">
315 <hardware>
316 <plugin>test_system</plugin>
317 </hardware>
318 <joint name="joint2">
319 <command_interface name="velocity"/>
320 <command_interface name="max_acceleration"/>
321 <state_interface name="position"/>
322 <state_interface name="velocity"/>
323 </joint>
324 <gpio name="configuration">
325 <command_interface name="max_tcp_jerk"/>
326 <state_interface name="max_tcp_jerk"/>
327 <state_interface name="does_not_exist"/>
328 </gpio>
329 </ros2_control>
330)";
331
332const auto hardware_resources_missing_gpio_command_keys =
333 R"(
334 <ros2_control name="TestSystemHardware" type="system">
335 <hardware>
336 <plugin>test_system</plugin>
337 </hardware>
338 <joint name="joint2">
339 <command_interface name="velocity"/>
340 <command_interface name="max_acceleration"/>
341 <state_interface name="position"/>
342 <state_interface name="velocity"/>
343 </joint>
344 <gpio name="configuration">
345 <command_interface name="max_tcp_jerk"/>
346 <command_interface name="does_not_exist"/>
347 <state_interface name="max_tcp_jerk"/>
348 </gpio>
349 </ros2_control>
350)";
351
352const auto hardware_resources_with_exclusive_interface =
353 R"(
354 <ros2_control name="TestActuatorHardware1" type="actuator">
355 <hardware>
356 <plugin>test_actuator_exclusive_interfaces</plugin>
357 </hardware>
358 <joint name="joint1">
359 <command_interface name="position"/>
360 <command_interface name="velocity"/>
361 <command_interface name="effort"/>
362 <state_interface name="position"/>
363 <state_interface name="velocity"/>
364 <state_interface name="effort"/>
365 </joint>
366 </ros2_control>
367 <ros2_control name="TestActuatorHardware2" type="actuator">
368 <hardware>
369 <plugin>test_actuator_exclusive_interfaces</plugin>
370 </hardware>
371 <joint name="joint2">
372 <command_interface name="position"/>
373 <command_interface name="velocity"/>
374 <command_interface name="effort"/>
375 <state_interface name="position"/>
376 <state_interface name="velocity"/>
377 <state_interface name="effort"/>
378 </joint>
379 </ros2_control>
380 <ros2_control name="TestActuatorHardware3" type="actuator">
381 <hardware>
382 <plugin>test_actuator_exclusive_interfaces</plugin>
383 </hardware>
384 <joint name="joint3">
385 <command_interface name="position"/>
386 <command_interface name="velocity"/>
387 <command_interface name="effort"/>
388 <state_interface name="position"/>
389 <state_interface name="velocity"/>
390 <state_interface name="effort"/>
391 </joint>
392 </ros2_control>
393 <ros2_control name="TestSensorHardware" type="sensor">
394 <hardware>
395 <plugin>test_sensor</plugin>
396 <param name="example_param_write_for_sec">2</param>
397 <param name="example_param_read_for_sec">2</param>
398 </hardware>
399 <sensor name="sensor1">
400 <state_interface name="velocity"/>
401 </sensor>
402 </ros2_control>
403)";
404
405const auto diffbot_urdf =
406 R"(
407<?xml version="1.0" ?>
408<robot name="robot">
409 <!-- Space btw top of beam and the each joint -->
410 <!-- Links: inertial,visual,collision -->
411 <link name="base_link">
412 <inertial>
413 <!-- origin is relative -->
414 <origin rpy="0 0 0" xyz="0 0 0"/>
415 <mass value="5"/>
416 <inertia ixx="5" ixy="0" ixz="0" iyy="5" iyz="0" izz="5"/>
417 </inertial>
418 <visual>
419 <geometry>
420 <box size="0.5 0.1 0.1"/>
421 </geometry>
422 </visual>
423 <collision>
424 <!-- origin is relative -->
425 <origin xyz="0 0 0"/>
426 <geometry>
427 <box size="0.5 0.1 0.1"/>
428 </geometry>
429 </collision>
430 </link>
431 <link name="base_footprint">
432 <visual>
433 <geometry>
434 <sphere radius="0.01"/>
435 </geometry>
436 </visual>
437 <collision>
438 <origin xyz="0 0 0"/>
439 <geometry>
440 <sphere radius="0.00000001"/>
441 </geometry>
442 </collision>
443 </link>
444 <joint name="base_footprint_joint" type="fixed">
445 <origin rpy="0 0 0" xyz="0 0 0.11"/>
446 <child link="base_link"/>
447 <parent link="base_footprint"/>
448 </joint>
449 <link name="wheel_0_link">
450 <inertial>
451 <origin rpy="0 0 0" xyz="0 0 0"/>
452 <mass value="1"/>
453 <inertia ixx="0.2" ixy="0" ixz="0" iyy="0.2" iyz="0" izz="0.2"/>
454 </inertial>
455 <visual>
456 <origin rpy="0 0 0" xyz="0 0 0"/>
457 <geometry>
458 <cylinder length="0.086" radius="0.11"/>
459 </geometry>
460 </visual>
461 <collision>
462 <origin rpy="0 0 0" xyz="0 0 0"/>
463 <geometry>
464 <cylinder length="0.086" radius="0.11"/>
465 </geometry>
466 </collision>
467 </link>
468 <joint name="wheel_0_joint" type="continuous">
469 <parent link="base_link"/>
470 <child link="wheel_0_link"/>
471 <origin rpy="-1.5707963267948966 0 0" xyz="0.3 0 0"/>
472 <axis xyz="0 0 1"/>
473 </joint>
474 <!-- Transmission is important to link the joints and the controller -->
475 <transmission name="wheel_0_joint_trans" type="SimpleTransmission">
476 <actuator name="wheel_0_joint_motor"/>
477 <joint name="wheel_0_joint"/>
478 <mechanicalReduction>1</mechanicalReduction>
479 <motorTorqueConstant>1</motorTorqueConstant>
480 </transmission>
481 <gazebo reference="wheel_0_link">
482 <material>Gazebo/Red</material>
483 </gazebo>
484 <link name="wheel_1_link">
485 <inertial>
486 <origin rpy="0 0 0" xyz="0 0 0"/>
487 <mass value="1"/>
488 <inertia ixx="0.2" ixy="0" ixz="0" iyy="0.2" iyz="0" izz="0.2"/>
489 </inertial>
490 <visual>
491 <origin rpy="0 0 0" xyz="0 0 0"/>
492 <geometry>
493 <cylinder length="0.086" radius="0.11"/>
494 </geometry>
495 </visual>
496 <collision>
497 <origin rpy="0 0 0" xyz="0 0 0"/>
498 <geometry>
499 <cylinder length="0.086" radius="0.11"/>
500 </geometry>
501 </collision>
502 </link>
503 <joint name="wheel_1_joint" type="continuous">
504 <parent link="base_link"/>
505 <child link="wheel_1_link"/>
506 <origin rpy="-1.5707963267948966 0 0" xyz="-0.2 0 0"/>
507 <axis xyz="0 0 1"/>
508 </joint>
509 <!-- Transmission is important to link the joints and the controller -->
510 <transmission name="wheel_1_joint_trans" type="SimpleTransmission">
511 <actuator name="wheel_1_joint_motor"/>
512 <joint name="wheel_1_joint"/>
513 <mechanicalReduction>1</mechanicalReduction>
514 <motorTorqueConstant>1</motorTorqueConstant>
515 </transmission>
516 <gazebo reference="wheel_1_link">
517 <material>Gazebo/Red</material>
518 </gazebo>
519 <!-- Colour -->
520 <gazebo reference="base_link">
521 <material>Gazebo/Green</material>
522 </gazebo>
523 <gazebo reference="base_footprint">
524 <material>Gazebo/Purple</material>
525 </gazebo>
526 <ros2_control name="TestActuatorHardwareLeft" type="actuator">
527 <hardware>
528 <plugin>test_actuator</plugin>
529 </hardware>
530 <joint name="wheel_left">
531 <state_interface name="position"/>
532 <command_interface name="velocity"/>
533 <state_interface name="velocity"/>
534 </joint>
535 </ros2_control>
536 <ros2_control name="TestActuatorHardwareRight" type="actuator">
537 <hardware>
538 <plugin>test_actuator</plugin>
539 </hardware>
540 <joint name="wheel_right">
541 <state_interface name="position"/>
542 <command_interface name="velocity"/>
543 <state_interface name="velocity"/>
544 </joint>
545 </ros2_control>
546</robot>
547)";
548
549const auto minimal_robot_urdf =
550 std::string(urdf_head) + std::string(hardware_resources) + std::string(urdf_tail);
551const auto minimal_unitilizable_robot_urdf =
552 std::string(urdf_head) + std::string(unitilizable_hardware_resources) + std::string(urdf_tail);
553
554const auto minimal_robot_missing_state_keys_urdf =
555 std::string(urdf_head) + std::string(hardware_resources_missing_state_keys) +
556 std::string(urdf_tail);
557
558const auto minimal_robot_missing_command_keys_urdf =
559 std::string(urdf_head) + std::string(hardware_resources_missing_command_keys) +
560 std::string(urdf_tail);
561
562const auto minimal_robot_missing_gpio_state_keys_urdf =
563 std::string(urdf_head) + std::string(hardware_resources_missing_gpio_state_keys) +
564 std::string(urdf_tail);
565
566const auto minimal_robot_missing_gpio_command_keys_urdf =
567 std::string(urdf_head) + std::string(hardware_resources_missing_gpio_command_keys) +
568 std::string(urdf_tail);
569
570[[maybe_unused]] const std::string TEST_ACTUATOR_HARDWARE_NAME = "TestActuatorHardware";
571[[maybe_unused]] const std::string TEST_ACTUATOR_HARDWARE_TYPE = "actuator";
572[[maybe_unused]] const std::string TEST_ACTUATOR_HARDWARE_CLASS_TYPE = "test_actuator";
573[[maybe_unused]] const std::vector<std::string> TEST_ACTUATOR_HARDWARE_COMMAND_INTERFACES = {
574 "joint1/position", "joint1/max_velocity"};
575[[maybe_unused]] const std::vector<std::string> TEST_ACTUATOR_HARDWARE_STATE_INTERFACES = {
576 "joint1/position", "joint1/velocity", "joint1/some_unlisted_interface"};
577
578[[maybe_unused]] const std::string TEST_SENSOR_HARDWARE_NAME = "TestSensorHardware";
579[[maybe_unused]] const std::string TEST_SENSOR_HARDWARE_TYPE = "sensor";
580[[maybe_unused]] const std::string TEST_SENSOR_HARDWARE_CLASS_TYPE = "test_sensor";
581[[maybe_unused]] const std::vector<std::string> TEST_SENSOR_HARDWARE_COMMAND_INTERFACES = {""};
582[[maybe_unused]] const std::vector<std::string> TEST_SENSOR_HARDWARE_STATE_INTERFACES = {
583 "sensor1/velocity"};
584
585[[maybe_unused]] const std::string TEST_SYSTEM_HARDWARE_NAME = "TestSystemHardware";
586[[maybe_unused]] const std::string TEST_SYSTEM_HARDWARE_TYPE = "system";
587[[maybe_unused]] const std::string TEST_SYSTEM_HARDWARE_CLASS_TYPE = "test_system";
588[[maybe_unused]] const std::vector<std::string> TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES = {
589 "joint2/velocity", "joint2/max_acceleration", "joint3/velocity", "configuration/max_tcp_jerk"};
590[[maybe_unused]] const std::vector<std::string> TEST_SYSTEM_HARDWARE_STATE_INTERFACES = {
591 "joint2/position", "joint2/velocity", "joint2/acceleration", "joint3/position",
592 "joint3/velocity", "joint3/acceleration", "configuration/max_tcp_jerk"};
593
594} // namespace ros2_control_test_assets
595
596#endif // ROS2_CONTROL_TEST_ASSETS__DESCRIPTIONS_HPP_