Ask Your Question

multiple turtlebots simulation in gazebo and visualization in rviz

asked 2014-11-18 16:43:24 -0500

hjh gravatar image

updated 2014-11-19 17:30:28 -0500

Hi, I need to simulate multiple turtlebots in gazebo and visualize them in rviz and finally I succeed to add two robots into gazebo and rviz according to this but there are a few problems.

1.if I teleop one of the robot, even just rotate in place, the turtlebot will drift.

I checked this however when I look into the source file of gazebo_ros_kobuki.cpp(kobuki_gazebo_plugins) I find that this module is using the non-holonomic robot model. I am not sure what is the problem.

2.When I drive one robot toward the other and let these two robot collide, in the gazebo everything is ok but in rviz the moving robot just drive into the other one and pass through it, like the other one never exists. And also there is no output of bump cloud.

3.As you can see in the teleop launch file, I only publish velocity commands to one robot. But the actual result is that that turtlebot in gazebo works fine but in rviz both turtlebots react to the angular velocity. That means if I drive the robot, say robot1, linearly then only robot1 moves in rviz but when I sent angular velocity through keyboard then both robots will rotate in rviz.[this one is solved by change sensor names]

So I check the velocity topics related to both robots, it shows that only /robot1/command/velocity receives messages other velocity related topics have no message received. But still both robots rotate.

Here are related files: Gazebo related files Main launch file:

  <!-- gazebo world start -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="use_sim_time" value="true"/>
    <arg name="debug" value="false"/>
    <arg name="world_name" value="$(find agents_gazebo)/worlds/"/>
    <arg name="gui" value="true"/>
  <!-- Map server -->
  <arg name="map_file" default="$(find agents_gazebo)/maps/willow-2010-02-18-0.10.yaml"/>
  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" >
       <param name="frame_id" value="/map"/>
  <!-- include robots -->
  <include file="$(find agents_gazebo)/launch/includes/agents.launch.xml"/>

agents.launch.xml for multiple robots launch

  <arg name="base"      value="$(optenv TURTLEBOT_BASE kobuki)"/> 
  <arg name="battery"   value="$(optenv TURTLEBOT_BATTERY /proc/acpi/battery/BAT0)"/>  
  <arg name="stacks"    value="$(optenv TURTLEBOT_STACKS hexagons)"/>  
  <arg name="3d_sensor" value="$(optenv TURTLEBOT_3D_SENSOR kinect)"/>  

  <arg name="urdf_file" default="$(find xacro)/ '$(find turtlebot_description)/robots/$(arg base)_$(arg stacks)_$(arg 3d_sensor).urdf.xacro'" />
  <param name="robot_description" command="$(arg urdf_file)" />

  <!-- BEGIN ROBOT 1-->
  <group ns="robot1">
    <arg name="robot_name" value="robot1"/>
    <include file="$(find agents_gazebo)/launch/includes/agent.launch.xml" >
    <arg name="initial_pose_x" value="0" />
    <arg name="initial_pose_y" value="0" />
    <arg name="initial_pose_z" value="0" />
    <arg name="initial_pose_yaw" value="0" />
    <arg name="robot_name" value="$(arg robot_name)"/>

  <!-- BEGIN ROBOT 2-->
  <group ns="robot2">
    <arg name="robot_name" value="robot2"/>
    <include file="$(find agents_gazebo)/launch/includes/agent.launch.xml" >
    <arg name="initial_pose_x" value="1" />
    <arg name="initial_pose_y" value="0" />
    <arg name="initial_pose_z" value="0" />
    <arg name="initial_pose_yaw" value="3.1415926" />
      <arg name="robot_name" value="$(arg robot_name)"/>

agent ... (more)

edit retag flag offensive close merge delete


Hi can you please share the rviz file for multiple robots, i have it for one robot but i don't know what should i add or how to modify it. Thank you

Ramez gravatar image Ramez  ( 2015-07-02 10:35:41 -0500 )edit

to run multiple robots you need to revise several files if it is ok i can send you some patch files to you but you have to give me your email address

hjh gravatar image hjh  ( 2015-07-27 10:59:21 -0500 )edit

@hjh I'm facing problems running controller manager in different namespaces for multi-robot simulation. Could you provide me with your patch files. It might help or give me some idea. You can send the files to

webvenky gravatar image webvenky  ( 2015-09-21 00:43:39 -0500 )edit

@hjh It would be the community's greatest benefit if you could share your files somewhere public (eg. adding their contents in your answer, or sharing the link to your repository).

130s gravatar image 130s  ( 2015-09-21 01:13:56 -0500 )edit

Sorry for the late reply I have uploaded my solution to github please visit

hjh gravatar image hjh  ( 2015-09-21 04:32:15 -0500 )edit

@hjh Thanks.

webvenky gravatar image webvenky  ( 2015-09-21 12:29:03 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-11-19 17:26:05 -0500

hjh gravatar image

updated 2014-11-19 17:30:54 -0500

I managed to solve the problem in rotation. it seems that the kobuki plugin just generates one set of odom and other sensors and still it is the namespace problem. However I had another problem and I added it into the original question. Please do help me if you have any idea. Thanks!

edit flag offensive delete link more


Sorry for the late reply I have uploaded my solution to github please visit

hjh gravatar image hjh  ( 2015-09-21 04:31:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-11-18 16:43:24 -0500

Seen: 2,939 times

Last updated: Jul 02 '15