Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock componentsに対応します #16

Merged
merged 11 commits into from
Nov 25, 2024
2 changes: 2 additions & 0 deletions sciurus17_description/robot_description_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self):
self.use_gazebo = 'false'
self.use_gazebo_head_camera = 'false'
self.use_gazebo_chest_camera = 'false'
self.use_mock_components = 'false'
self.gz_control_config_package = ''
self.gz_control_config_file_path = ''

Expand All @@ -34,6 +35,7 @@ def load(self):
' use_gazebo:=', self.use_gazebo,
' use_gazebo_head_camera:=', self.use_gazebo_head_camera,
' use_gazebo_chest_camera:=', self.use_gazebo_chest_camera,
' use_mock_components:=', self.use_mock_components,
' gz_control_config_package:=', self.gz_control_config_package,
' gz_control_config_file_path:=', self.gz_control_config_file_path
])
9 changes: 9 additions & 0 deletions test/test_robot_description_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ def test_use_gazebo_chest_camera():
rdl.gz_control_config_package = 'sciurus17_description'
rdl.gz_control_config_file_path = 'config/dummy_controllers.yaml'
assert 'reference="chest_camera_link"' in exec_load(rdl)


def test_use_mock_components():
# use_mock_componentsが変更され、xacroにmock_componentsがセットされることを期待
rdl = RobotDescriptionLoader()
rdl.use_mock_components = 'true'
rdl.gz_control_config_package = 'sciurus17_description'
rdl.gz_control_config_file_path = 'config/dummy_controllers.yaml'
assert 'mock_components/GenericSystem' in exec_load(rdl)
15 changes: 10 additions & 5 deletions urdf/sciurus17.ros2_control.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@

<ros2_control name="sciurus17" type="system">
<hardware>
<plugin>sciurus17_hardware/Sciurus17Hardware</plugin>
<param name="port_name">${PORT_NAME}</param>
<param name="baudrate">${BAUDRATE}</param>
<param name="timeout_seconds">${TIMEOUT_SECONDS}</param>
<param name="manipulator_config_file_path">${MANIPULATOR_CONFIG_FILE_PATH}</param>
<xacro:if value="${USE_MOCK_COMPONENTS}">
<plugin>mock_components/GenericSystem</plugin>
</xacro:if>
<xacro:unless value="${USE_MOCK_COMPONENTS}">
<plugin>sciurus17_hardware/Sciurus17Hardware</plugin>
<param name="port_name">${PORT_NAME}</param>
<param name="baudrate">${BAUDRATE}</param>
<param name="timeout_seconds">${TIMEOUT_SECONDS}</param>
<param name="manipulator_config_file_path">${MANIPULATOR_CONFIG_FILE_PATH}</param>
</xacro:unless>
</hardware>

<joint name="${NAME_JOINT_BODY}">
Expand Down
2 changes: 2 additions & 0 deletions urdf/sciurus17.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<xacro:arg name="use_gazebo" default="false" />
<xacro:arg name="use_gazebo_head_camera" default="false" />
<xacro:arg name="use_gazebo_chest_camera" default="false" />
<xacro:arg name="use_mock_components" default="false" />
<xacro:arg name="port_name" default="/dev/sciurus17spine" />
<xacro:arg name="baudrate" default="3000000" />
<xacro:arg name="timeout_seconds" default="1.0" />
Expand All @@ -28,6 +29,7 @@
<xacro:arg name="gz_control_config_file_path" default="" />
<xacro:property name="USE_GAZEBO_HEAD_CAMERA" value="$(arg use_gazebo_head_camera)"/>
<xacro:property name="USE_GAZEBO_CHEST_CAMERA" value="$(arg use_gazebo_chest_camera)"/>
<xacro:property name="USE_MOCK_COMPONENTS" value="$(arg use_mock_components)"/>
<xacro:property name="PORT_NAME" value="$(arg port_name)"/>
<xacro:property name="BAUDRATE" value="$(arg baudrate)"/>
<xacro:property name="TIMEOUT_SECONDS" value="$(arg timeout_seconds)"/>
Expand Down