Skip to content

Commit

Permalink
ROS 2 Gazebo対応 (#5)
Browse files Browse the repository at this point in the history
* use_gazeboオプション追加

* 古いGazeboの記述を削除

* Gazeboのマテリアルを設定

* use_gazeboオプション追加

* use_gazeboオプションを確認するCIを追加
  • Loading branch information
Kuwamai authored Oct 16, 2023
1 parent ee688c1 commit e8e16dc
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 294 deletions.
4 changes: 3 additions & 1 deletion sciurus17_description/robot_description_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ def __init__(self):
get_package_share_directory('sciurus17_description'),
'urdf',
'sciurus17.urdf.xacro')
self.use_gazebo = 'false'

def load(self):
return Command([
'xacro ',
self.robot_description_path
self.robot_description_path,
' use_gazebo:=', self.use_gazebo
])
7 changes: 7 additions & 0 deletions test/test_robot_description_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ def test_change_description_path():
with pytest.raises(Exception) as e:
exec_load(rdl)
assert e.value


def test_use_gazebo():
# use_gazeboが変更され、xacroにgazeboタグがセットされることを期待
rdl = RobotDescriptionLoader()
rdl.use_gazebo = 'true'
assert '<gazebo' in exec_load(rdl)
64 changes: 14 additions & 50 deletions urdf/sciurus17.urdf.xacro
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<?xml version="1.0"?>

<robot name="sciurus17" xmlns:xacro="http://ros.org/wiki/xacro" >
<robot
name="sciurus17"
xmlns:xacro="http://ros.org/wiki/xacro"
xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface">

<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_body.xacro"/>
<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_head.xacro"/>
<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_right_arm.xacro"/>
<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_right_hand.xacro"/>
<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_left_arm.xacro"/>
<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_left_hand.xacro"/>
<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_gazebo.xacro"/>

<xacro:arg name="use_gazebo" default="false" />

<material name="white">
<color rgba="0.9 0.9 0.9 1.0"/>
</material>

<material name="red">
<color rgba="0.8984375 0.0 0.0703125 1"/>
</material>
Expand Down Expand Up @@ -129,55 +139,6 @@
<xacro:property name="COLOR_LINK_HAND" value="red"/>
<xacro:property name="COLOR_LINK_CAMERA" value="white"/>

<xacro:arg name="use_gazebo_simulation" default="false" />
<xacro:arg name="load_trans1" default="false" />
<xacro:arg name="load_trans2" default="false" />
<xacro:arg name="load_trans3" default="false" />

<xacro:arg name="use_effort_right_arm" default="false" />
<xacro:property name="right_arm_interface" value="position"/>
<xacro:if value="$(arg use_effort_right_arm)">
<xacro:property name="right_arm_interface" value="effort"/>
</xacro:if>

<xacro:arg name="use_effort_left_wrist" default="false" />
<xacro:property name="left_wrist_interface" value="position"/>
<xacro:if value="$(arg use_effort_left_wrist)">
<xacro:property name="left_wrist_interface" value="effort"/>
</xacro:if>

<xacro:if value="$(arg use_gazebo_simulation)">
<xacro:include filename="$(find sciurus17_description)/urdf/sciurus17_gazebo.xacro"/>

<xacro:if value="$(arg load_trans1)">
<xacro:default_transmission joint_name="r_arm_joint1" interface="${right_arm_interface}"/>
<xacro:default_transmission joint_name="r_arm_joint2" interface="${right_arm_interface}"/>
<xacro:default_transmission joint_name="r_arm_joint3" interface="${right_arm_interface}"/>
<xacro:default_transmission joint_name="r_arm_joint4" interface="${right_arm_interface}"/>
<xacro:default_transmission joint_name="r_arm_joint5" interface="${right_arm_interface}"/>
<xacro:default_transmission joint_name="r_arm_joint6" interface="${right_arm_interface}"/>
<xacro:default_transmission joint_name="r_arm_joint7" interface="${right_arm_interface}"/>
<xacro:default_transmission joint_name="r_hand_joint"/>
</xacro:if>

<xacro:if value="$(arg load_trans2)">
<xacro:default_transmission joint_name="l_arm_joint1"/>
<xacro:default_transmission joint_name="l_arm_joint2"/>
<xacro:default_transmission joint_name="l_arm_joint3"/>
<xacro:default_transmission joint_name="l_arm_joint4"/>
<xacro:default_transmission joint_name="l_arm_joint5"/>
<xacro:default_transmission joint_name="l_arm_joint6"/>
<xacro:default_transmission joint_name="l_arm_joint7" interface="${left_wrist_interface}"/>
<xacro:default_transmission joint_name="l_hand_joint"/>
</xacro:if>

<xacro:if value="$(arg load_trans3)">
<xacro:default_transmission joint_name="waist_yaw_joint"/>
<xacro:default_transmission joint_name="neck_yaw_joint"/>
<xacro:default_transmission joint_name="neck_pitch_joint"/>
</xacro:if>
</xacro:if>

<!-- Used for fixing robot 'base_link' to Gazebo 'world' -->
<link name="world"/>

Expand All @@ -198,4 +159,7 @@

<xacro:sciurus17_left_hand/>

<xacro:if value="$(arg use_gazebo)">
<xacro:gazebo_robot_settings/>
</xacro:if>
</robot>
10 changes: 0 additions & 10 deletions urdf/sciurus17_body.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@
</collision>
</link>

<gazebo reference="${NAME_LINK_BASE}">
<material>Gazebo/White</material>
</gazebo>
<gazebo reference="${NAME_LINK_BODY}">
<material>Gazebo/White</material>
</gazebo>
<gazebo reference="${NAME_LINK_CHEST_CAMERA}">
<material>Gazebo/Black</material>
</gazebo>

</xacro:macro>

</robot>
Loading

0 comments on commit e8e16dc

Please sign in to comment.