Skip to content

Commit

Permalink
テスト実行時はダミーのパラメータファイルを読み込めるようにdescription_loaderを修正 (#73)
Browse files Browse the repository at this point in the history
* テスト時はダミーのパラメータファイルを読み込めるようにdescription_loaderを修正

* CIの設定ファイルから読み込む必要のないsetup.bashの変数を削除

* 余計な文字を削除
  • Loading branch information
YusukeKato authored Sep 8, 2023
1 parent bf67052 commit 909db12
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 7 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/industrial_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ jobs:
strategy:
matrix:
env:
# テストがワークスペース内のパッケージに依存しているため、setup.bashを読み込む
# Ref: https://github.com/ros-industrial/industrial_ci/issues/585
- { ROS_DISTRO: humble, ROS_REPO: ros, BEFORE_RUN_TARGET_TEST_EMBED: "ici_with_unset_variables source /root/target_ws/install/setup.bash" }
- { ROS_DISTRO: humble, ROS_REPO: ros }
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(self):
self.use_gazebo = 'false'
self.use_ignition = 'false'
self.use_camera = 'false'
self.gz_control_config_package = ''
self.gz_control_config_file_path = ''

def load(self):
return Command([
Expand All @@ -37,5 +39,7 @@ def load(self):
' port_name:=', self.port_name,
' use_gazebo:=', self.use_gazebo,
' use_ignition:=', self.use_ignition,
' use_camera:=', self.use_camera
' use_camera:=', self.use_camera,
' gz_control_config_package:=', self.gz_control_config_package,
' gz_control_config_file_path:=', self.gz_control_config_file_path
])
35 changes: 35 additions & 0 deletions crane_plus_description/test/dummy_controllers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
controller_manager:
ros__parameters:
update_rate: 100 # Hz

crane_plus_arm_controller:
type: joint_trajectory_controller/JointTrajectoryController
crane_plus_gripper_controller:
type: joint_trajectory_controller/JointTrajectoryController
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

crane_plus_arm_controller:
ros__parameters:
joints:
- crane_plus_joint1
- crane_plus_joint2
- crane_plus_joint3
- crane_plus_joint4

command_interfaces:
- position

state_interfaces:
- position

crane_plus_gripper_controller:
ros__parameters:
joints:
- crane_plus_joint_hand

command_interfaces:
- position

state_interfaces:
- position
6 changes: 6 additions & 0 deletions crane_plus_description/test/test_robot_description_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def test_use_gazebo():
# use_gazeboが変更され、xacroにgazebo_ros2_controlがセットされることを期待
rdl = RobotDescriptionLoader()
rdl.use_gazebo = 'true'
rdl.gz_control_config_package = 'crane_plus_description'
rdl.gz_control_config_file_path = 'test/dummy_controllers.yaml'
assert 'gazebo_ros2_control/GazeboSystem' in exec_load(rdl)


Expand All @@ -58,11 +60,15 @@ def test_use_ignition():
rdl = RobotDescriptionLoader()
rdl.use_gazebo = 'true'
rdl.use_ignition = 'true'
rdl.gz_control_config_package = 'crane_plus_description'
rdl.gz_control_config_file_path = 'test/dummy_controllers.yaml'
assert 'ign_ros2_control/IgnitionSystem' in exec_load(rdl)


def test_use_camera():
# use_cameraが変更されて、xacroにcameraがセットされることを期待
rdl = RobotDescriptionLoader()
rdl.use_camera = 'true'
rdl.gz_control_config_package = 'crane_plus_description'
rdl.gz_control_config_file_path = 'test/dummy_controllers.yaml'
assert 'camera_link' in exec_load(rdl)
6 changes: 4 additions & 2 deletions crane_plus_description/urdf/crane_plus.gazebo.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@
name_link_4
name_link_hand
use_ignition
config_package
config_file_path
">

<gazebo>
<xacro:if value="${use_ignition}">
<plugin filename="libign_ros2_control-system.so" name="ign_ros2_control::IgnitionROS2ControlPlugin">
<parameters>$(find crane_plus_control)/config/crane_plus_controllers.yaml</parameters>
<parameters>$(find ${config_package})/${config_file_path}</parameters>
</plugin>
</xacro:if>

<xacro:unless value="${use_ignition}">
<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
<robot_sim_type>gazebo_ros2_control/GazeboSystem</robot_sim_type>
<parameters>$(find crane_plus_control)/config/crane_plus_controllers.yaml</parameters>
<parameters>$(find ${config_package})/${config_file_path}</parameters>
</plugin>
</xacro:unless>
</gazebo>
Expand Down
6 changes: 5 additions & 1 deletion crane_plus_description/urdf/crane_plus.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<xacro:arg name="read_loads" default="0" />
<xacro:arg name="read_voltages" default="0" />
<xacro:arg name="read_temperatures" default="0" />
<xacro:arg name="gz_control_config_package" default="" />
<xacro:arg name="gz_control_config_file_path" default="" />

<!-- Link to provide the location reference for the arm -->
<link name="base_link"/>
Expand Down Expand Up @@ -128,7 +130,9 @@
name_link_3="${NAME_LINK_3}"
name_link_4="${NAME_LINK_4}"
name_link_hand="${NAME_LINK_HAND}"
use_ignition="$(arg use_ignition)" />
use_ignition="$(arg use_ignition)"
config_package="$(arg gz_control_config_package)"
config_file_path="$(arg gz_control_config_file_path)" />

<xacro:crane_plus_gazebo_ros2_control_settings
name="crane_plus"
Expand Down
2 changes: 2 additions & 0 deletions crane_plus_gazebo/launch/crane_plus_with_table.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def generate_launch_description():
description_loader = RobotDescriptionLoader()
description_loader.use_gazebo = 'true'
description_loader.use_ignition = 'true'
description_loader.gz_control_config_package = 'crane_plus_control'
description_loader.gz_control_config_file_path = 'config/crane_plus_controllers.yaml'
description = description_loader.load()

move_group = IncludeLaunchDescription(
Expand Down

0 comments on commit 909db12

Please sign in to comment.