Ask Your Question
2

Multiple TurtleBots in gazebo [closed]

asked 2012-08-09 22:08:22 -0600

prasanna.kumar gravatar image

updated 2012-11-03 02:16:09 -0600

Hi all,

I want to spawn two TurtleBots in Gazebo. And also I wish to control each of the robots independently. Is there a way to do it ?

Thanks!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by prasanna.kumar
close date 2013-01-08 23:12:12

Comments

Hello prasanna kumar, is it possible to tell me how to do it and what should I write in my launch file. Thank you

Ramez gravatar imageRamez ( 2015-06-24 10:34:47 -0600 )edit

6 Answers

Sort by ยป oldest newest most voted
2

answered 2012-08-14 06:54:58 -0600

maurizio gravatar image

updated 2012-08-14 06:55:38 -0600

Hi,

I tried to spawn two turtlebots taking a look to the above link and others. I tried to change line 36 of gazebo_ros_create.cpp as reported here [http://answers.ros.org/question/33981/multiple-turtlebots-in-gazebo/], i.e. line 36 to node_namespaceP_ = new ParamT<std::string>("robotNamespace","",0);

Then, I used two configuration file, one for each turtlebot. For each node inside this configuration file, I have added a namespace through the option "ns", I just report the first one below.

I still see /odom and /cmd_vel topics without any specification wrt the namespaces. Other topics, like scan, are actually modified accordingly to the namespace of the two robots.

Thank you

<launch>
<group ns="JOLLY">
  <param name="robot_description" command="$(find xacro)/xacro.py '$(find turtlebot_description)/urdf/turtlebot.urdf.xacro'" />
</group>
  <node name="spawn_turtlebot_model2" pkg="gazebo" type="spawn_model" args="$(optenv ROBOT_INITIAL_POSE) -unpause -urdf -param robot_description -x 2 -y 10 -z 0.05 -model turtlebot2" respawn="false" output="screen" ns="JOLLY"/>

  <node pkg="diagnostic_aggregator" type="aggregator_node" name="diagnostic_aggregator" ns="JOLLY" >
    <rosparam command="load" file="$(find turtlebot_bringup)/config/diagnostics.yaml" />
  </node>

  <node pkg="robot_state_publisher" type="state_publisher" name="robot_state_publisher" output="screen" ns="JOLLY">
    <param name="publish_frequency" type="double" value="20.0" />
  </node>


  <!-- The odometry estimator -->

  <node pkg="robot_pose_ekf" type="robot_pose_ekf" name="robot_pose_ekf" ns="JOLLY">
    <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"/>
    <param name="output_frame" value="odom" />
  </node>


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

  <!-- Fake Laser -->
  <node pkg="nodelet" type="nodelet" name="kinect_laser" args="load pointcloud_to_laserscan/CloudToScan openni_manager" respawn="true" ns="JOLLY">
    <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"/>
  </node>

  <!-- 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" ns="JOLLY">
    <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"/>
  </node>


</launch>
edit flag offensive delete link more
2

answered 2012-08-09 23:29:45 -0600

Jakub gravatar image
edit flag offensive delete link more
0

answered 2012-08-14 11:38:35 -0600

maurizio gravatar image

Thanks,

I had just solved it 5 minutes ago, I was writing a reply.

Do you know if there are problems with tf or related stuff? Now I am going to use the navigation stack for both of them.

Thank you again.

PS: I think it would be better to write a page that clearly states these issues, it is a waste of time and I guess it is an important feature for many researchers

edit flag offensive delete link more

Comments

There was a problem with tf_prefix in gazebo_ros_laser.cpp but it's solved right now in the newest release of gazebo_plugins package.

Jakub gravatar imageJakub ( 2012-08-14 12:07:46 -0600 )edit

Sorry but I didn't get: I use ros electric (we are having some problems with fuerte...). Are you referring to fuerte or electric? If this is just for fuerte, could you please provide the link to the patch? Probably your're referring to this https://code.ros.org/trac/ros-pkg/ticket/5511

maurizio gravatar imagemaurizio ( 2012-08-14 12:24:58 -0600 )edit
0

answered 2012-08-14 10:59:06 -0600

Jakub gravatar image

One thing more is needed. In the same gazebo_ros_create.cpp starting from line 157 you have to change the fully-qualified topic names to relative one i.e.

/cmd_vel -> cmd_vel
/odom -> odom
/joint_states -> joint_states

Recompile and that's it.

edit flag offensive delete link more
0

answered 2012-08-14 14:38:07 -0600

maurizio gravatar image

updated 2012-08-14 14:39:00 -0600

Seems to be ok now, I do not have to set tf_prefix inside the robot_state_publisher node but I have to declare separately, like this

<group ns="robot1"> </group>

Tomorrow I'll continue trying to exploit a navigation stack for every robot.

Thanks for the suggestions

edit flag offensive delete link more

Comments

I've tried to summarize everything here. Pleas check it out.

Jakub gravatar imageJakub ( 2012-08-14 22:35:31 -0600 )edit
0

answered 2012-08-14 13:15:56 -0600

maurizio gravatar image

I made the modifications reported in the patch related to gazebo_ros_laser.cpp (link text)

I can correctly see the laser footprints coming from both the turtlebots, but not at the same time. Basically in rviz, i can visualize just one robot model (and I am not even sure which of them it is: if I try to set TF prefix in robot model it complains saying "No transform from [/robot1/base_footprint] to [/base_link]" "No transform from [/robot1/base_link] to [/base_link]" and so on...

edit flag offensive delete link more

Comments

@maurizio please tell how you use navigation stack for each robot ?? i also doing the same job .. thanks

qubaish g gravatar imagequbaish g ( 2013-03-23 08:07:03 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-08-09 22:08:22 -0600

Seen: 1,830 times

Last updated: Aug 14 '12