Rosanswers logo

Hello everyone.

I am trying to run two Turtlebots in Gazebo and have one observe the other. I encountered the common error of one of the turtlebots only showing up as wheels, but by using a hack I am able to see both Turtlebots fully by closing the Gazebo GUI and reopening it again with rosrun gazebo gui.

The problem arises when I try to have one robot observe the other using its kinect and RVIZ. I can see the topics /camera/image_raw and /camera/depth/points (no namespace) from the turtlebot that originally fully appeared in gazebo. The other robot, though, appears only as wheels in RVIZ even though it is fully visible in Gazebo!

I figure there is two ways of solving this. 1) Actually remedying the problem of one of the Turtlebots not fully appearing originally in Gazebo instead of using the hack(which I have no idea how to do) 2) Observe the Turtlebot that fully appears from the others Kinect. There are topics /robot1/depth/image_raw and /robot1/depth/camera_info being published (and similarly for robot2) but when I set the topic to /robot1/depth/image_raw RVIZ looks for camerainfo on /robot2/depth/camera_info and vice versa and says no camerainfo received. I get just an image of a horizontal white line.

These probably coincide but I am hoping some of you know better than me. I am using the following launch file to launch the Gazebo world with the 2 turtlebots in it simultaneously:

Where robot1 and robot2.launch are identical files except for the robots and nodes use different namespaces so that I can control the robots separately, and I have successfully written a teleop node to allow me to do this.

So how can I have one Turtlebot observe the other (not just its wheels)? Any ideas would be appreciated.

Thanks for your help!



So here is the list of topics being published or subscribed:






















































As you can see, I have the majority of topics specify for which robot they belong, but not the /camera topics. So, I guess the questions I need to be asking are:

  1. What Gazebo plugin(s) are responsible for publishing the /camera topics? I figure I can use namespaces in them in order to specify to RVIZ which robot's camera feed I want to see.

  2. Why isn't the whole Turtlebot showing up in RVIZ and how can I fix it?

Thanks again! -Alan

Originally posted by ajhamlet on ROS Answers with karma: 3 on 2013-05-21

Post score: 0


1 Answer 1


Rosanswers logo


The problem you have with respect to rviz is due to malformed tf. When you are using multiple robots, you need to resolve the tf data for each of the robots by adding a "tf_prefix". By doing so all the links of the robot have unique names like robot1_tf/base_link, robot2_tf/odom etc and tf trees can be constructed for both robots and rviz can display both the robots.

To resolve the sensor data of the robots you have to provide a namespace for each robot. In the below shown case the scan topic become /robot1/scan and /robot1/camera/image_raw etc and the rviz is able to display the scan data of both the robots.

I use the following launch file:

  <!-- start gazebo with an empty plane -->
  <param name="/use_sim_time" value="true" />


  <node launch-prefix="optirun" name="gazebo" pkg="gazebo" type="gazebo" args="$(find angen_gazebo)/worlds/angen_empty.world" respawn="false" output="screen"/>
  <node name="gazebo_gui" pkg="gazebo" type="gui" />

<param name="robot_description"
    command="$(find xacro)/xacro.py $(find turtlebot_description)/urdf/turtlebot.urdf.xacro" />

  <group ns="robot1">
    <param name="tf_prefix" value="robot1" />
    <include file="$(find angen_turtlebot)/launch/fuerte_final_r1.launch" >
      <arg name="init_pose" value="-x 9 -y 5 -z 0.05" />
      <arg name="robot_name"  value="Robot1" />

  <group ns="robot2">
    <param name="tf_prefix" value="robot2" />
    <include file="$(find angen_turtlebot)/launch/fuerte_final_r1.launch" >
      <arg name="init_pose" value="-x 9 -y 4 -z 0.05" />
      <arg name="robot_name"  value="Robot2" />




    <arg name="init_pose"/>
    <arg name="robot_name"/>

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find turtlebot_description)/urdf/turtlebot.urdf.xacro'" />

  <node name="spawn_turtlebot_model" pkg="gazebo" type="spawn_model" args="$(arg init_pose) -unpause -urdf -param /robot_description -model $(arg robot_name) -robotNamespace $(arg robot_name)" respawn="false" output="screen"/>

  <node pkg="diagnostic_aggregator" type="aggregator_node" name="diagnostic_aggregator" >
    <rosparam command="load" file="$(find turtlebot_bringup)/config/diagnostics.yaml" />
  <node pkg="robot_state_publisher" type="state_publisher" name="robot_state_publisher" output="screen">
    <param name="publish_frequency" type="double" value="30.0" />

  <!-- The odometry estimator -->

  <node pkg="robot_pose_ekf" type="robot_pose_ekf" name="robot_pose_ekf">
    <param name="freq" value="30.0"/>
    <param name="sensor_timeout" value="1.0"/>
    <param name="publish_tf" value="true"/>
    <param name="odom_used" value="true"/>
    <param name="imu_used" value="false"/>
    <param name="vo_used" value="false"/>
    <!--<param name="output_frame" value="odom"/>-->

  <!-- throttling -->
  <node pkg="nodelet" type="nodelet" name="pointcloud_throttle" args="load pointcloud_to_laserscan/CloudThrottle openni_manager" respawn="true">
    <param name="max_rate" value="20.0"/>
    <remap from="cloud_in" to="/camera/depth/points"/>
    <remap from="cloud_out" to="cloud_throttled"/>

  <!-- Fake Laser -->
  <node pkg="nodelet" type="nodelet" name="kinect_laser" args="load pointcloud_to_laserscan/CloudToScan openni_manager" respawn="true">
    <param name="output_frame_id" value="/camera_depth_frame"/>
    <!-- heights are in the (optical?) frame of the kinect -->
    <param name="min_height" value="-0.15"/>
    <param name="max_height" value="0.15"/>
    <remap from="cloud" to="/cloud_throttled"/>

  <!-- Fake Laser (narrow one, for localization -->
  <node pkg="nodelet" type="nodelet" name="kinect_laser_narrow" args="load pointcloud_to_laserscan/CloudToScan openni_manager" respawn="true">
    <param name="output_frame_id" value="/camera_depth_frame"/>
    <!-- heights are in the (optical?) frame of the kinect -->
    <param name="min_height" value="-0.025"/>
    <param name="max_height" value="0.025"/>
    <remap from="cloud" to="/cloud_throttled"/>
    <remap from="scan" to="/narrow_scan"/>


Regarding the gazebo problem, many who use robots in gazebo have that problem. I usually do not care about that as long as the robot obeys my navigation commands. But to solve that you can do the following: comment the line in launch file that launches gui, so now you will be launching gazebo without the gui. After launchimg that you can run rosrun gazebo gui and both the robots will be visible right from the start.

Read in detail here.

Originally posted by prasanna.kumar with karma: 1363 on 2013-05-21

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by ajhamlet on 2013-05-22:
Thank you for your response. I think I have already mostly figured out the namespace/tf_prefix issue (actually, using an answer to a question you previously asked). Please see the update to my question for more info on the issue I am having.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.