Skip to content

Commit

Permalink
Add tf_prefix to URDF and launch files
Browse files Browse the repository at this point in the history
  • Loading branch information
mintar committed Sep 18, 2020
1 parent 245683a commit 8eb6e7b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
4 changes: 3 additions & 1 deletion mir_description/launch/upload_mir_urdf.launch
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" ?>
<launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find mir_description)/urdf/mir.urdf.xacro" />
<arg name="tf_prefix" default="" doc="TF prefix to use for all of Mobipick's TF frames"/>

<param name="robot_description" command="$(find xacro)/xacro --inorder $(find mir_description)/urdf/mir.urdf.xacro tf_prefix:=$(arg tf_prefix)" />
</launch>
11 changes: 10 additions & 1 deletion mir_description/urdf/mir.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
<xacro:include filename="$(find mir_description)/urdf/include/mir_100_v1.urdf.xacro" />
<xacro:include filename="$(find mir_description)/urdf/include/common.gazebo.xacro" />

<xacro:mir_100 prefix=""/>
<xacro:arg name="tf_prefix" default="" />
<xacro:property name="tf_prefix_" value="$(arg tf_prefix)" />
<xacro:if value="${tf_prefix_ == ''}">
<xacro:property name="prefix" value="" />
</xacro:if>
<xacro:unless value="${tf_prefix_ == ''}">
<xacro:property name="prefix" value="${tf_prefix_}/" />
</xacro:unless>

<xacro:mir_100 prefix="${prefix}"/>
<xacro:controller_plugin_gazebo robot_namespace=""/>

<!-- instead of the controller_plugin_gazebo, you can use the diffdrive controller like this:
Expand Down
3 changes: 3 additions & 0 deletions mir_gazebo/launch/mir_empty_world.launch
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<arg name="robot_y" default="0.0" />
<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." />

<group>
<remap from="joint_states" to="mir/joint_states" />
<remap from="mobile_base_controller/cmd_vel" to="cmd_vel" />
Expand All @@ -30,5 +32,6 @@
<arg name="robot_x" value="$(arg robot_x)" />
<arg name="robot_y" value="$(arg robot_y)" />
<arg name="robot_yaw" value="$(arg robot_yaw)" />
<arg name="tf_prefix" value="$(arg tf_prefix)" />
</include>
</launch>
15 changes: 12 additions & 3 deletions mir_gazebo/launch/mir_gazebo_common.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
<arg name="robot_x" default="0.0" />
<arg name="robot_y" default="0.0" />
<arg name="robot_yaw" default="0.0" />
<arg name="prefix" value="" /> <!-- this has to be "value", not "default", otherwise subst_value doesn't work -->

<arg name="tf_prefix" default="" doc="tf_prefix to be used by gazebo plugins and in the robot's urdf etc." />

<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" />
<include file="$(find mir_description)/launch/upload_mir_urdf.launch">
<arg name="tf_prefix" value="$(arg tf_prefix)" />
</include>

<!-- Spawn the robot into Gazebo -->
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model mir
Expand All @@ -21,7 +28,9 @@
args="joint_state_controller mobile_base_controller"/>

<!-- EKF -->
<include file="$(find mir_gazebo)/launch/includes/ekf.launch.xml"/>
<include file="$(find mir_gazebo)/launch/includes/ekf.launch.xml">
<arg name="tf_prefix" value="$(arg prefix)" />
</include>

<!-- Robot state publisher -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" output="screen" />
Expand Down
2 changes: 2 additions & 0 deletions mir_gazebo/launch/mir_maze_world.launch
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0"?>
<launch>
<arg name="gui" default="true" />
<arg name="tf_prefix" default="" doc="tf_prefix to be used by gazebo plugins and in the robot's urdf etc." />

<include file="$(find mir_gazebo)/launch/mir_empty_world.launch">
<arg name="gui" value="$(arg gui)" />
<arg name="tf_prefix" value="$(arg tf_prefix)" />
</include>

<include file="$(find mir_gazebo)/launch/includes/spawn_maze.launch.xml" />
Expand Down

0 comments on commit 8eb6e7b

Please sign in to comment.