ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Remapping the gazebo node

asked 2016-08-28 14:08:51 -0500

patrchri gravatar image

updated 2016-08-31 03:00:11 -0500

Hello,

I am using the following launch file to spawn my robot in gazebo:

<launch>
  <arg name="paused" default="false"/>
  <arg name="debug" default="false"/>
  <arg name="gui" default="true"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find labrob_gazebo)/worlds/second_world.world"/>
    <arg name="paused" value="$(arg paused)" />
    <arg name="debug" value="$(arg debug)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="use_sim_time" value="true" />
    <arg name="headless" value="false" />
  </include>


  <!-- urdf xml robot description loaded on the Parameter Server-->
  <param name="robot_description" command="$(find xacro)/xacro.py '$(find labrob_description)/urdf/labrob.urdf'" />

  <!-- push robot_description to factory and spawn robot in gazebo -->
  <node name="labrob_spawn" pkg="gazebo_ros" type="spawn_model" output="screen" 
    args="-urdf -param robot_description -model labrob" />
</launch>

and I want to remap the gazebo node so it will stop using the tf topic.

I have seen this question after DavidN's help, but I would prefer not to modify the launch files of the gazebo_ros package and do the remapping from the launch files I use.

I have tried to create a remap.launch file that I ran after roslaunching the above file, in which I wrote:

<launch>
<node pkg="gazebo_ros" name="gazebo" type="gzserver">
<remap from="tf" to="gazebo_tf"/>
</node>
</launch>

This didn't work, probably because the remapping can be achieved at the start of the execution of the node and not during runtime. I have tried to use the <remap from="tf" to="gazebo_tf"/> tag almost everywhere in the first file I present here, but the gazebo node doesn't remap from the tf topic -it is not recognized.

How could I modify the first launch file to successfully remap the gazebo node from my package ?

Thank you for your answers and for your time in advance,

Chris

EDITED:

The solution proposed by Winston didn't work, because the /gazebo node was already launched initially in the launch file. To be more specific, I got the following errors:

roslaunch file contains multiple nodes named [/gazebo].
Please check all <node> 'name' attributes to make sure they are unique.
Also check that $(anon id) use different ids.
The traceback for the exception was written to the log file
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-08-31 05:41:40 -0500

You have to specify the remapping directly where the gazebo node is started (Internally, the XML-based remapping is converted to arguments provided to the executable). So the one option is to copy the empty_world.launch launch file from gazebo_ros and add the appropriate remapping, e.g. change this part to:

<node name="gazebo" pkg="gazebo_ros" type="$(arg script_type)" respawn="false" output="screen"
    args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) -e $(arg physics) $(arg extra_gazebo_args) $(arg world_name)">
    <remap from="tf" to="tf_remapped_away" />
  </node>
</node>

As another (potential) option, the original empty_world.launch also provides a extra_gazebo_args argument, that can be used to provide additional arguments. I tried manually adding the remapping there (for my test the /clock topic) This however doesn't work, likely due to the duplicate := (would probably need to be escaped somehow):

roslaunch gazebo_ros empty_world.launch extra_gazebo_args:=/clock:=/clock_remapped_away
edit flag offensive delete link more

Comments

extra_gazebo_args is working for me (for remapping), I have added:

<arg name="extra_gazebo_args" value="joint_states:=/turtlebot3_burger/joint_states" />

using gazebo_ros empty_world.launch:

<!-- Gazebo world -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(arg world_path)"/>
    <arg name="paused" value="$(arg paused)"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="$(arg gazebo_gui)"/>
    <arg name="headless" value="false"/>
    <arg name="debug" value="false"/>
    <arg name="extra_gazebo_args" value="joint_states:=/turtlebot3_burger/joint_states" />
</include>
Oscar Lima gravatar image Oscar Lima  ( 2020-05-16 01:59:06 -0500 )edit
0

answered 2016-08-29 04:10:23 -0500

Winston gravatar image

updated 2016-08-29 04:11:51 -0500

Try this:

<launch>
  <arg name="paused" default="false"/>
  <arg name="debug" default="false"/>
  <arg name="gui" default="false"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find labrob_gazebo)/worlds/second_world.world"/>
    <arg name="paused" value="$(arg paused)" />
    <arg name="debug" value="$(arg debug)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="use_sim_time" value="true" />
    <arg name="headless" value="false" />
  </include>


  <!-- urdf xml robot description loaded on the Parameter Server-->
  <param name="robot_description" command="$(find xacro)/xacro.py '$(find labrob_description)/urdf/labrob.urdf'" />

  <node pkg="gazebo_ros" name="gazebo" type="gzserver">
     <remap from="tf" to="gazebo_tf"/>
  </node>

  <!-- push robot_description to factory and spawn robot in gazebo -->
  <node name="labrob_spawn" pkg="gazebo_ros" type="spawn_model" output="screen" 
    args="-urdf -param robot_description -model labrob" />
</launch>
edit flag offensive delete link more

Comments

Hello, firstly thank you for answering, secondly because I will not be visiting my lab soon to try your suggestion at the pc there, are you sure this will work so I can mark your answer as correct ?

patrchri gravatar image patrchri  ( 2016-08-29 09:47:01 -0500 )edit

I tried your suggestion and it didn't work...I re-edited my question for that case.

patrchri gravatar image patrchri  ( 2016-08-30 09:43:30 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-08-28 14:08:51 -0500

Seen: 1,923 times

Last updated: Aug 31 '16