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

Multiple turtlebots "odom" topic problem

asked 2014-04-24 05:30:05 -0500

Robert1 gravatar image

Hi Everyone, I spawned multiple turtlebots for my gazebo simulation using the kobuki model from the turtlebot simulator. I can input velocity commands for each individual turtlebot using different namespace like /robot1/vel_cmd, robot2/vel_cmd ..etc but I couldn't read my odometry topic on the same manner. In other words I just got one single topic “/odom” but I need to push down the “/odom” topic into its own namespace like /robot1/odom, robot2/odom...robot4/odom. I installed hydro ROS, gazebo/gazebo_ros_pkg and turtlebot simulator from pre- built-debians and I read some posts where people recommend to install gazebo/gazeb_ros_pkg “from source” to have access to the source code then to solve this problem by changing the source. For this particular problem I read that I need to change the gazebo_ros_create.cpp file where the odom topic is declared like “/odom” as global name and I need to change it to “odom” as relative name to be able to push down the topic I haven't tried it yet but I have my doubts about this option. Please any help regarding this matter. Thanks alot

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2014-05-20 13:35:25 -0500

Carlos Hdz gravatar image

Hi...

I had the same problem, and I found a solution (at least for my case). I will try to explain what I do, in case of someone is interested in try it out (this will be a long answer!)..

First, i will you you the launch files that i use, and then some of the nodes I write in order to make it work... The launch files are:

<?xml version="1.0" ?>

<launch>

  <arg name="r1_x" default="1" />
  <arg name="r1_y" default="1" />
  <arg name="r2_x" default="-1" />
  <arg name="r2_y" default="1" />

  <!-- start world -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
  <!--         -->
    <arg name="use_sim_time" value="true"/>
    <arg name="debug" value="true"/>
    <arg name="gui" value="true"/>       <!-- graphic interface -->
    <arg name="headless" value="false"/>
    <arg name="world_name" value="$(find tb_tables)/worlds/tres_mesas.world"/>
  </include>

   <!-- include robot description -->
   <param name="robot_description"
    command="$(find xacro)/xacro.py '$(find turtlebot_description)/robots/kobuki_hexagons_kinect.urdf.xacro'" />

  <!-- BEGIN ROBOT 0-->
  <group ns="robot0">
    <param name="tf_prefix" value="robot0_tf" />
    <include file="$(find tb_tables)/launch/simulation/includes/turtlebot1.launch" >
      <arg name="init_pose" value="-x $(arg r2_x) -y $(arg r2_y) -z 0" />
      <arg name="robot_name"  value="robot0" />
    </include>
  </group>    

  <!-- BEGIN ROBOT 1-->
  <group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
    <include file="$(find tb_tables)/launch/simulation/includes/turtlebot1.launch" >
      <arg name="init_pose" value="-x $(arg r1_x) -y $(arg r1_y) -z 0" />
      <arg name="robot_name"  value="robot1" />
    </include>
  </group>    
  </launch>

This is the auxiliar launch file (called above, inside a namespace).

  <?xml version="1.0" ?>
<launch>

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

    <!-- odom publisher -->
        <param name="robot_name" value=  "$(arg robot_name)" />
        <node pkg="tb_tables" type="odom_sim_2" name="odom_sim"/>

      <!-- 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) -robotNamespace $(arg robot_name) -namespace $(arg robot_name)"/>

    <!-- robot state publisher (at 1 Hz) --> 
    <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
     <param name="publish_frequency" type="double" value="1.0" />
    </node>

    <!-- Publish tf info -->
    <node pkg="tb_tables" name="tb_tf_broadcaster" type="tb_tf_can2">
    </node>     
</launch>

And this launch file is for running the navigation stack for both robots:

<?xml version="1.0" ?>

<launch>

  <arg name="map_file" default="$(find tb_tables)/maps/blank_map.yaml"/>
  <arg name="rviz_robot" default="robot1"/>


  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" > 
  </node>

  <!-- BEGIN ROBOT 0-->
  <group ns="robot0">
    <param name="tf_prefix" value="robot0_tf" />
    <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" /> 
    <node pkg="tb_tables" name="fake_localization" type="fake_localiza2" output="screen"/>
    <include file="$(find tb_tables)/launch/simulation/includes/move_base_sim.launch.xml" />
  </group>

  <!-- BEGIN ROBOT 1-->
  <group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
    <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" /> 
    <node pkg="tb_tables" name="fake_localization" type="fake_localiza2" output="screen"/>
    <include file="$(find tb_tables)/launch/simulation/includes/move_base_sim.launch.xml" />
  </group>      
</launch>

You can see in this launch files that I use a node named "odom_sim". As some people have noticed, namespaces in the kobuki gazebo plugin doesn't work for many topics (being odometry one of them), so I program this node (odom_sim) in order to publish ... (more)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-04-24 05:30:05 -0500

Seen: 1,232 times

Last updated: May 20 '14