Skip to content

Commit

Permalink
Add prepend_prefix_to_laser_frame to URDF and launch files
Browse files Browse the repository at this point in the history
Fixes #65.
  • Loading branch information
mintar committed Sep 18, 2020
1 parent 8eb6e7b commit 96d7915
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
3 changes: 2 additions & 1 deletion mir_description/launch/upload_mir_urdf.launch
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" ?>
<launch>
<arg name="tf_prefix" default="" doc="TF prefix to use for all of Mobipick's TF frames"/>
<arg name="prepend_prefix_to_laser_frame" default="false" doc="Set this to 'true' if you don't start the spawn_model node inside a namespace."/>

<param name="robot_description" command="$(find xacro)/xacro --inorder $(find mir_description)/urdf/mir.urdf.xacro tf_prefix:=$(arg tf_prefix)" />
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find mir_description)/urdf/mir.urdf.xacro tf_prefix:=$(arg tf_prefix) prepend_prefix_to_laser_frame:=$(arg prepend_prefix_to_laser_frame)" />
</launch>
20 changes: 18 additions & 2 deletions mir_description/urdf/include/mir_100_v1.urdf.xacro
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<!-- The gazebo_ros_laser plugin does the following:
- If the ROS parameter 'tf_prefix' is set, it prepends the
- tf_prefix in front of the frameName.
- Otherwise, it prepends the robotNamespace.
The robotNamespace gets automatically set if you start the
spawn_model node inside a namespace. In this case, set
prepend_prefix_to_laser_frame to 'false', otherwise the
resulting frameName will have two prefixes prepended.
If you don't start spawn_model inside a namespace but have a
non-empty prefix, set prepend_prefix_to_laser_frame to 'true'. -->
<xacro:arg name="prepend_prefix_to_laser_frame" default="false" />

<xacro:include filename="$(find mir_description)/urdf/include/common_properties.urdf.xacro" />
<xacro:include filename="$(find mir_description)/urdf/include/imu.gazebo.urdf.xacro" />
<xacro:include filename="$(find mir_description)/urdf/include/mir_100.gazebo.xacro" />
Expand Down Expand Up @@ -192,15 +206,17 @@
<child link="${prefix}front_laser_link" />
<origin xyz="0.4288 0.2358 0.1914" rpy="0.0 0.0 ${0.25 * pi}" /> <!-- from visually matching up the meshes of the MiR and the laser scanner -->
</joint>
<xacro:sick_s300 prefix="${prefix}" link="front_laser_link" topic="f_scan" />
<xacro:sick_s300 prefix="${prefix}" link="front_laser_link" topic="f_scan"
prepend_prefix_to_laser_frame="$(arg prepend_prefix_to_laser_frame)" />

<joint name="${prefix}base_link_to_back_laser_joint" type="fixed">
<parent link="${prefix}base_link" />
<child link="${prefix}back_laser_link" />
<origin xyz="-0.3548 -0.2352 0.1914" rpy="0.0 0.0 ${-0.75 * pi}" /> <!-- from visually matching up the meshes of the MiR and the laser scanner -->
</joint>

<xacro:sick_s300 prefix="${prefix}" link="back_laser_link" topic="b_scan" />
<xacro:sick_s300 prefix="${prefix}" link="back_laser_link" topic="b_scan"
prepend_prefix_to_laser_frame="$(arg prepend_prefix_to_laser_frame)" />

<!-- Ultrasound sensors -->
<joint name="${prefix}us_1_joint" type="fixed"> <!-- right ultrasound -->
Expand Down
22 changes: 19 additions & 3 deletions mir_description/urdf/include/sick_s300.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<xacro:property name="laser_z" value="0.185" />
<xacro:property name="laser_mass" value="2.0" />

<xacro:macro name="sick_s300" params="link topic prefix">
<xacro:macro name="sick_s300" params="link topic prefix prepend_prefix_to_laser_frame='false'">
<link name="${prefix}${link}">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="${pi} 0 0" />
Expand Down Expand Up @@ -61,8 +61,24 @@
</noise>
</ray>
<plugin name="gazebo_ros_${link}_controller" filename="libgazebo_ros_laser.so">
<!-- no prefix, plugin always uses a tf_prefix (if none is set it uses robotNamespace) -->
<frameName>${link}</frameName>
<!-- The gazebo_ros_laser plugin does the following:
- If the ROS parameter 'tf_prefix' is set, it prepends the
- tf_prefix in front of the frameName.
- Otherwise, it prepends the robotNamespace.
The robotNamespace gets automatically set if you start the
spawn_model node inside a namespace. In this case, set
prepend_prefix_to_laser_frame to 'false', otherwise the
resulting frameName will have two prefixes prepended.
If you don't start spawn_model inside a namespace but have a
non-empty prefix, set prepend_prefix_to_laser_frame to 'true'. -->
<xacro:if value="${prepend_prefix_to_laser_frame}">
<frameName>${prefix}${link}</frameName>
</xacro:if>
<xacro:unless value="${prepend_prefix_to_laser_frame}">
<frameName>${link}</frameName>
</xacro:unless>
<topicName>${topic}</topicName>
</plugin>
</sensor>
Expand Down
1 change: 1 addition & 0 deletions mir_gazebo/launch/mir_empty_world.launch
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
<arg name="robot_y" value="$(arg robot_y)" />
<arg name="robot_yaw" value="$(arg robot_yaw)" />
<arg name="tf_prefix" value="$(arg tf_prefix)" />
<arg name="prepend_prefix_to_laser_frame" value="true" />
</include>
</launch>
4 changes: 3 additions & 1 deletion mir_gazebo/launch/mir_gazebo_common.launch
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
<arg name="robot_yaw" default="0.0" />

<arg name="tf_prefix" default="" doc="tf_prefix to be used by gazebo plugins and in the robot's urdf etc." />
<arg name="prepend_prefix_to_laser_frame" default="false" doc="Set this to 'true' if you don't start the spawn_model node inside a namespace."/>

<arg name="prefix" value="$(arg tf_prefix)/" if="$(eval tf_prefix != '')" /> <!-- $(arg prefix) is used in all the config files! TODO: For multiple robots, create groups when loading the parameters to overwrite the arg? -->
<arg name="prefix" value="" unless="$(eval tf_prefix != '')" />


<!-- Load URDF -->
<include file="$(find mir_description)/launch/upload_mir_urdf.launch">
<arg name="tf_prefix" value="$(arg tf_prefix)" />
<arg name="tf_prefix" value="$(arg tf_prefix)" />
<arg name="prepend_prefix_to_laser_frame" value="$(arg prepend_prefix_to_laser_frame)" />
</include>

<!-- Spawn the robot into Gazebo -->
Expand Down

0 comments on commit 96d7915

Please sign in to comment.