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

Multi robot simulation in ROS

asked 2012-06-30 05:26:00 -0500

Neostek gravatar image

updated 2012-08-09 23:44:17 -0500

Lorenz gravatar image

Hello everybody,

I have a problem with multi-robot simulation.

I have a launch file that launches two xacro files

 <param name="quad_urdf"
    command="$(find xacro)/xacro.py
    '$(find package)/models/quadrotorWithCamera.xacro'"
 />

<node name="spawn_quad0" 
  pkg="gazebo" type="spawn_model"
  args="-urdf -param quad_urdf -model quad0 -x 0 -y 0 -z 3"
  respawn="false" output="screen">
</node>

<node name="spawn_quad1" 
  pkg="gazebo" type="spawn_model"
  args="-urdf -param quad_urdf -model quad1 -x 1 -y 1 -z 3"
  respawn="false" output="screen">
</node>

The file quadrotorWithCamera.xacro loads a camera that publishes on /ptz/camera_info (as example of a topic).

Obviously, both quadrotors will publish on this topic and that's wrong. I see two solutions:

1) rename topic with remap. But it doesn't work. I set <remap from="ptz/camera_info" to="ptz/camera_info2"/> in both node but if I run rostopic list /ptz/camera_info is still on while /ptz/camera_info2 has no topic published on it.

2) Try to give as input to xacro file the robot name but it seems no input is available.

Any suggestion?

Thanks for any reply,

Neostek

edit retag flag offensive close merge delete

Comments

Can you share your simulation configuration files?

prince gravatar image prince  ( 2012-07-23 19:36:40 -0500 )edit

What version of simulator gazebo are you running? ROS topic remapping is broken in simulator_gazebo 1.6.10 and before (see http://ros.org/wiki/simulator_gazebo/ChangeList/1.6), fixes are in 1.6.11, but the debian for that is being generated right now (http://www.ros.org/debbuild/fuerte.html).

hsu gravatar image hsu  ( 2012-08-01 10:32:20 -0500 )edit

6 Answers

Sort by ยป oldest newest most voted
6

answered 2012-07-01 21:07:24 -0500

You can try to put each node in a different namespace, using the ns attribute or the <group> tag so that you will hopefully get two different topics /ns1/ptz/camera_info and /ns2/ptz/camera_info.

edit flag offensive delete link more
4

answered 2012-08-01 11:50:15 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

When you use namespaces for a node all parameters used by this node get the namespace as well. So when launch like the example in the above answer, the node spawn_quad0 looks for a parameter first_pelikan/quad_urdf (and not just quad_urdf).

You can solve this in two ways:

<group ns="first_pelican">
   <param name="quad_urdf" value="....." />
   <node name="spawn_quad0" pkg="gazebo" type="spawn_model" args="-urdf -param quad_urdf -model quad0 -x 0 -y 0 -z 3" respawn="false" output="screen"/>
</group>

<group ns="second_pelican">
   <param name="quad_urdf" value="....." />
   <node name="spawn_quad1" pkg="gazebo" type="spawn_model" args="-urdf -param quad_urdf -model quad1 -x 1 -y 1 -z 3" respawn="false" output="screen"/>
</group>

Or, to avoid duplication of parameter, declare it outside the group, but use fully-qualified name when using the param (i.e with the slash at the beginning).

<param name="quad_urdf" value="....." />

<group ns="first_pelican">
  <node name="spawn_quad0" pkg="gazebo" type="spawn_model" args="-urdf -param /quad_urdf -model quad0 -x 0 -y 0 -z 3" respawn="false" output="screen"/>
</group>

<group ns="second_pelican">
  <node name="spawn_quad1" pkg="gazebo" type="spawn_model" args="-urdf -param /quad_urdf -model quad1 -x 1 -y 1 -z 3" respawn="false" output="screen"/>
</group>

The same is valid if you declare namespaces without the group, like:

<node name="foo" ns="first_pelican">
  <!-- becomes /first_pelican/param1 -->
  <param name="param1" value="0" />
</node>

<!-- all params in the included files gets the prefix of /first_pelican -->
<include file="file_to_include" ns="first_pelican" />

Hope that helps.

edit flag offensive delete link more
1

answered 2012-07-03 05:42:02 -0500

Neostek gravatar image

I find a solution. The namespace has to be added as argument in the args field of the node, not as an attribute. In addition, I used namespace instead of ns:

<node name="spawn_quad0" pkg="gazebo" type="spawn_model" args="-urdf -param quad_urdf -model quad0 -x 0 -y 0 -z 3 -namespace quad0" respawn="false" output="screen"> </node>

edit flag offensive delete link more
0

answered 2012-08-01 00:35:44 -0500

pmarinplaza gravatar image

the only way I find to do that is with group:

<group ns="first_pelican">

   <node name="spawn_quad0" pkg="gazebo" type="spawn_model" args="-urdf -param quad_urdf -model quad0 -x 0 -y 0 -z 3" respawn="false" output="screen"/>

</group>

<group ns="second_pelican">

   <node name="spawn_quad1" pkg="gazebo" type="spawn_model" args="-urdf -param quad_urdf -model quad1 -x 1 -y 1 -z 3" respawn="false" output="screen"/>

</group>
edit flag offensive delete link more
0

answered 2012-07-02 21:36:04 -0500

Neostek gravatar image

Ok good idea. My only point is how to set a parameter from the launch file to the xacro file representing my robot.

This because I want that each robot takes as input the name of the namespace (i.e. the name of the robot itself). In this way, I can built only one xacro file.

Can you give me an example how do you want to do that?

Thanks a lot.

edit flag offensive delete link more

Comments

1

The convention here is that posting an answer is only for answering the question .. it's not like a forum thread, and answers will be re-ordered based on votes. If you want to respond to somebody's answer, please post a comment. If you need to expand on your question, go back and edit it.

lindzey gravatar image lindzey  ( 2012-07-03 06:57:28 -0500 )edit
0

answered 2012-07-02 22:00:00 -0500

Neostek gravatar image

I tried to add ns="myRobot" to my node

<node name="spawn_quad0" ns="myRobot" pkg="gazebo" type="spawn_model" args="-urdf -param quad_urdf -model quad0 -x 0 -y 0 -z 3" respawn="false" output="screen"> </node>

but an error appears:

File "/opt/ros/electric/stacks/simulator_gazebo/gazebo/scripts/spawn_model", line 330, in <module> sm.callSpawnService() File "/opt/ros/electric/stacks/simulator_gazebo/gazebo/scripts/spawn_model", line 215, in callSpawnService model_xml = rospy.get_param(self.param_name) File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/client.py", line 378, in get_param return _param_server[param_name] #MasterProxy does all the magic for us File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/msproxy.py", line 117, in __getitem__ raise KeyError(key) KeyError: 'quad_urdf' [quad0/spawn_quad0-3] process has died [pid 11229, exit code 1]. log files: /home/marco/.ros/log/27005474-c4e5-11e1-853e-001d60c8d68d/quad0-spawn_quad0-3*.log

and I do not know what I wrong.

Many thanks for any reply.

edit flag offensive delete link more

Comments

spawn_model has a parameter namespace to set the ros namespace where you want your model to be. Also, if you use -param, you need to load the parameters before using them. Have a look at this tutorial http://www.ros.org/wiki/simulator_gazebo/Tutorials/Gazebo_ROS_API

Pablo Urcola gravatar image Pablo Urcola  ( 2012-07-02 23:06:43 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-06-30 05:26:00 -0500

Seen: 5,036 times

Last updated: Aug 09 '12