Skip to content

Commit f6dad1e

Browse files
committed
add mock components support
1 parent cfdf254 commit f6dad1e

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

sciurus17_description/robot_description_loader.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self):
2020
self.use_gazebo = 'false'
2121
self.use_gazebo_head_camera = 'false'
2222
self.use_gazebo_chest_camera = 'false'
23+
self.use_mock_components = 'false'
2324
self.gz_control_config_package = ''
2425
self.gz_control_config_file_path = ''
2526

@@ -34,6 +35,7 @@ def load(self):
3435
' use_gazebo:=', self.use_gazebo,
3536
' use_gazebo_head_camera:=', self.use_gazebo_head_camera,
3637
' use_gazebo_chest_camera:=', self.use_gazebo_chest_camera,
38+
' use_mock_components:=', self.use_mock_components,
3739
' gz_control_config_package:=', self.gz_control_config_package,
3840
' gz_control_config_file_path:=', self.gz_control_config_file_path
3941
])

test/test_robot_description_loader.py

+9
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,12 @@ def test_use_gazebo_chest_camera():
7979
rdl.gz_control_config_package = 'sciurus17_description'
8080
rdl.gz_control_config_file_path = 'config/dummy_controllers.yaml'
8181
assert 'reference="chest_camera_link"' in exec_load(rdl)
82+
83+
84+
def test_use_mock_components():
85+
# use_gazeboが変更され、xacroにgz_ros2_controlがセットされることを期待
86+
rdl = RobotDescriptionLoader()
87+
rdl.use_mock_components = 'true'
88+
rdl.gz_control_config_package = 'sciurus17_description'
89+
rdl.gz_control_config_file_path = 'config/dummy_controllers.yaml'
90+
assert 'mock_components/GenericSystem' in exec_load(rdl)

urdf/sciurus17.ros2_control.xacro

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55

66
<ros2_control name="sciurus17" type="system">
77
<hardware>
8-
<plugin>sciurus17_hardware/Sciurus17Hardware</plugin>
9-
<param name="port_name">${PORT_NAME}</param>
10-
<param name="baudrate">${BAUDRATE}</param>
11-
<param name="timeout_seconds">${TIMEOUT_SECONDS}</param>
12-
<param name="manipulator_config_file_path">${MANIPULATOR_CONFIG_FILE_PATH}</param>
8+
<xacro:if value="${USE_MOCK_COMPONENTS}">
9+
<plugin>mock_components/GenericSystem</plugin>
10+
</xacro:if>
11+
<xacro:unless value="${USE_MOCK_COMPONENTS}">
12+
<plugin>sciurus17_hardware/Sciurus17Hardware</plugin>
13+
<param name="port_name">${PORT_NAME}</param>
14+
<param name="baudrate">${BAUDRATE}</param>
15+
<param name="timeout_seconds">${TIMEOUT_SECONDS}</param>
16+
<param name="manipulator_config_file_path">${MANIPULATOR_CONFIG_FILE_PATH}</param>
17+
</xacro:unless>
1318
</hardware>
1419

1520
<joint name="${NAME_JOINT_BODY}">

urdf/sciurus17.urdf.xacro

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<xacro:arg name="use_gazebo" default="false" />
2121
<xacro:arg name="use_gazebo_head_camera" default="false" />
2222
<xacro:arg name="use_gazebo_chest_camera" default="false" />
23+
<xacro:arg name="use_mock_components" default="false" />
2324
<xacro:arg name="port_name" default="/dev/sciurus17spine" />
2425
<xacro:arg name="baudrate" default="3000000" />
2526
<xacro:arg name="timeout_seconds" default="1.0" />
@@ -28,6 +29,7 @@
2829
<xacro:arg name="gz_control_config_file_path" default="" />
2930
<xacro:property name="USE_GAZEBO_HEAD_CAMERA" value="$(arg use_gazebo_head_camera)"/>
3031
<xacro:property name="USE_GAZEBO_CHEST_CAMERA" value="$(arg use_gazebo_chest_camera)"/>
32+
<xacro:property name="USE_MOCK_COMPONENTS" value="$(arg use_mock_components)"/>
3133
<xacro:property name="PORT_NAME" value="$(arg port_name)"/>
3234
<xacro:property name="BAUDRATE" value="$(arg baudrate)"/>
3335
<xacro:property name="TIMEOUT_SECONDS" value="$(arg timeout_seconds)"/>

0 commit comments

Comments
 (0)