Ask Your Question
1

Sensor messages not working properly in rviz for multiple turtlebots simulated in gazebo

asked 2015-11-20 01:28:09 -0500

Usman Arif gravatar image

updated 2015-11-20 11:23:04 -0500

I have spawned 2 turtlebots in gazebo. All the topics seem to be working fine. Even the move base seems to be working when given a goal to accomplish. If i check with a topic echo, all the concerned topics seem to be working fine. But I could not visualize all the topics in rviz. I have a feeling that this has something to do with the tf being broadcasted, as when i try to observe the laser scans and point clouds in rviz I get some errors like these.

Error For pointcloud in riviz Transform [sender=unknown_publisher] For frame [robot1/robot1/camera_depth_optical_frame]: Frame [robot1/robot1/camera_depth_optical_frame] does not exist

Error For laser scan: Transform [sender=unknown_publisher] For frame [camera_depth_frame]: Frame [camera_depth_frame] does not exist

The robot and the camera raw image appears perfect in rviz.

My Launch file for getting the robots in:

<launch>
  <arg name="world_file"  default="$(env TURTLEBOT_GAZEBO_WORLD_FILE)"/>
  <arg name="base"      value="$(optenv TURTLEBOT_BASE kobuki)"/> <!-- create, roomba -->
  <arg name="battery"   value="$(optenv TURTLEBOT_BATTERY /proc/acpi/battery/BAT0)"/>  <!-- /proc/acpi/battery/BAT0 --> 
  <arg name="stacks"    value="$(optenv TURTLEBOT_STACKS hexagons)"/>  <!-- circles, hexagons --> 
  <arg name="3d_sensor" value="$(optenv TURTLEBOT_3D_SENSOR kinect)"/>  <!-- kinect, asus_xtion_pro --> 


  <include file="/opt/ros/indigo/share/gazebo_ros/launch/empty_world.launch">   <!-- $(find gazebo_ros) -->
    <arg name="use_sim_time" value="true"/>
    <arg name="debug" value="false"/>
    <arg name="world_name" value="$(arg world_file)"/>
  </include>

 <group ns="robot1">
  <param name="tf_prefix" value="robot1"/>
   <include file=".../launch/turtlebot.launch">
     <arg name="robot_name" value="robot1"/>
     <arg name="init_pose" value="-z 3 -x 3"/>
   </include>
<node pkg="tf" type="static_transform_publisher" name="$(anon odom_map_broadcaster)" args="3 0 0 0 0 0 map robot1/odom 100"/>
</group>
 <group ns="robot2"> 
  <param name="tf_prefix" value="robot2"/> 
   <include file=".../turtlebot.launch">
     <arg name="robot_name" value="robot2"/>
     <arg name="init_pose" value="-z 3 -x -3"/>
   </include>
<node pkg="tf" type="static_transform_publisher" name="$(anon odom_map_broadcaster)" args="-3 0 0 0 0 0 map robot2/odom 100"/>
</group>
</launch>

My navigation launch file

<launch>
  <param name="/use_sim_time" value="true"/>
<!-- Map server -->
  <arg name="map_file" default="$(env TURTLEBOT_GAZEBO_MAP_FILE)"/>
  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" >
    <param name="frame_id" value="/map" />
  </node>

  <group ns="robot1">
    <param name="tf_prefix" value="robot1" />
    <param name="amcl/initial_pose_x" value="3" />
    <param name="amcl/initial_pose_y" value="1" />
    <include file="..navigation/launch/amcl_0.1.launch" /> 
  </group>

<group ns="robot2">
    <param name="tf_prefix" value="robot2" />
    <param name="amcl/initial_pose_x" value="-3" />
    <param name="amcl/initial_pose_y" value="1" />
    <include file="..navigation/launch/amcl_0.1.launch" /> 
  </group>
</launch>
edit retag flag offensive close merge delete

Comments

One more thing. The tf tree seems perfect. map is the root node with two branches robot1/odom & robot2/odom and then the rest of the transforms. No unconnected ones

Usman Arif gravatar imageUsman Arif ( 2015-11-20 01:49:28 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-12-10 00:16:26 -0500

Usman Arif gravatar image

Problem solved :)

Made a few changes. Posting the updated files

<launch>
  <arg name="world_file"  default="$(env TURTLEBOT_GAZEBO_WORLD_FILE)"/>
  <arg name="base"      value="$(optenv TURTLEBOT_BASE kobuki)"/> <!-- create, roomba -->
  <arg name="battery"   value="$(optenv TURTLEBOT_BATTERY /proc/acpi/battery/BAT0)"/>  <!-- /proc/acpi/battery/BAT0 --> 
  <arg name="stacks"    value="$(optenv TURTLEBOT_STACKS hexagons)"/>  <!-- circles, hexagons --> 
  <arg name="3d_sensor" value="$(optenv TURTLEBOT_3D_SENSOR kinect)"/>  <!-- kinect, asus_xtion_pro --> 


  <include file="/opt/ros/indigo/share/gazebo_ros/launch/empty_world.launch">   <!-- $(find gazebo_ros) -->
    <arg name="use_sim_time" value="true"/>
    <arg name="debug" value="false"/>
    <arg name="world_name" value="$(arg world_file)"/>
  </include>

<!-- Robot Description, Global (one description for all robots) -->
<arg name="urdf_file" default="$(find xacro)/xacro.py '$(find turtlebot_description)/robots/kobuki_hexagons_kinect.urdf.xacro'" />
  <param name="robot_description" command="$(arg urdf_file)" />


 <group ns="robot1">
  <param name="tf_prefix" value="robot1_tf"/> 
   <include file="/home/.../launch/turtlebot.launch">
     <arg name="robot_name" value="robot1"/>
     <arg name="robot_prefix" value="robot1_tf"/>
     <arg name="init_pose" value="-z 3 -x 3"/>
   </include>
<node pkg="tf" type="static_transform_publisher" name="$(anon odom_map_broadcaster)" args="3 0 0 0 0 0 map robot1_tf/odom 100"/>
</group> 
</launch>

So publishing the static map transform in the above launch file. And this should be done for every robot you have in your environment (multiple robots), notice that the "map" is global as it doesn't have a "/" before it.

Next file is the turtlebot.launch which I am using

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

    <!-- Gazebo model spawner -->
  <node name="spawn_turtlebot_model" pkg="gazebo_ros" type="spawn_model"
        args="$(arg init_pose) -unpause -urdf -param /robot_description -model $(arg robot_name)"/>


  <!-- Velocity muxer -->
  <node pkg="nodelet" type="nodelet" name="mobile_base_nodelet_manager" args="manager"/>
  <node pkg="nodelet" type="nodelet" name="cmd_vel_mux"
        args="load yocs_cmd_vel_mux/CmdVelMuxNodelet mobile_base_nodelet_manager">
    <param name="yaml_cfg_file" value="$(find turtlebot_bringup)/param/mux.yaml" />
    <remap from="cmd_vel_mux/output" to="mobile_base/commands/velocity"/>
  </node>

   <!--Bumper/cliff to pointcloud (not working, as it needs sensors/core messages) -->
  <include file="$(find turtlebot_bringup)/launch/includes/kobuki/bumper2pc.launch.xml"/>

  <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
    <param name="publish_frequency" type="double" value="30.0" />
  </node>

  <!-- Fake laser -->
  <node pkg="nodelet" type="nodelet" name="laserscan_nodelet_manager" args="manager"/>
  <node pkg="nodelet" type="nodelet" name="depthimage_to_laserscan"
        args="load depthimage_to_laserscan/DepthImageToLaserScanNodelet laserscan_nodelet_manager">
    <param name="scan_height" value="10"/>
    <!-- publishing my output frame id with the robot tf prefix, this would end any errors in rviz saying no transform exist from /camera_depth_frame to /camera_depth_frame  -->
    <param name="output_frame_id" value="$(arg robot_prefix)/camera_depth_frame"/>
    <param name="range_min" value="0.45"/>
    <remap from="image" to="camera/depth/image_raw"/>
    <remap from="scan" to="scan"/>
  </node>
</launch>

The one important thing here to note is the output_frame_id of the fake laser. Please refer to the comment above this line

Next inline is my move_base and amcl launch file (combined)

<launch>
  <param name="/use_sim_time" value="true"/>

<!-- Map server -->
  <arg name="map_file" default="$(env TURTLEBOT_GAZEBO_MAP_FILE)"/>
  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" >
    <param name="frame_id" value="/map" />
  </node>

  <group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
    <param name="amcl/initial_pose_x" value="3" />
    <param name="amcl/initial_pose_y" value="1" />
    <include file="/home/..../launch/amcl_0.1.launch" /> 
  </group>
</launch>

Keeping ... (more)

edit flag offensive delete link more
0

answered 2016-06-22 07:44:02 -0500

bahom gravatar image

Thanks for sharing this. it helped me to get out from days stuck.

edit flag offensive delete link more

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

Stats

Asked: 2015-11-20 01:28:09 -0500

Seen: 795 times

Last updated: Jun 22 '16