Gazebo | Ignition | Community
Ask Your Question

Multiple robots with ROS plugins (Sensor plugin vs. model plug-in)

asked 2013-10-30 15:43:00 -0600

Markus Bader gravatar image

updated 2013-10-30 15:44:21 -0600


I am using gazebo 2.0.0 and ROS hydro on Ubuntu 12.04 64bit
I like to have multiple robots within gazebo but with xacro/urdf file.
The idea was to use the name under which the robot model was spawned as prefix. This worked with some code rewriting by telling the gazebo_ros model (diffdrive) plug-in by using the physics::ModelPtr::GetName() function to access the model instance name. But the laser model uses receives a sensors::SensorPtr on Load?

  • How can I get the model instance name?
  • Is there a other way to do this?

Greetings Markus

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2013-10-31 11:57:33 -0600

jbohren gravatar image

The idea was to use the name under which the robot model was spawned as prefix.

Just about every gazebo_ros plugin supports the <robotNamespace> configuration tag. You can use this to have them create their publishers and subscribers on namespaced topics.

See here for an example:

edit flag offensive delete link more



Thanks Jonathan. But that’s not the solution I am looking for. Because I do not like to touch my xacro or sdf file after I fixed it. I just want to spawn the robot with a different model name. Using the <robotNamespace> looks to me like a design flaw or workaround.

Markus Bader gravatar imageMarkus Bader ( 2013-11-04 08:29:50 -0600 )edit

Yeah, I see what you mean. It would be interesting to standardize plugin namespacing configuration so that you could tell a sensor plugin to be scoped to the model's spawn name. I also agree that the &lt;robotNamespace&gt; tag is sort of sloppy, but I personally tend to propagate these things with xacro arguments anyway.

jbohren gravatar imagejbohren ( 2013-11-04 21:22:10 -0600 )edit

Yes I know that xacro is able to forward variable and therefore also the robotNamespace but people are starting to build workarounds as long as there is no standard with a documentation. Honestly thing there must be a solution for SDF otherwise it won't be used.

Markus Bader gravatar imageMarkus Bader ( 2013-11-05 04:34:59 -0600 )edit

While this is still a hackish solution, you don't normally need to touch the xacro/urdf file. robotNamespace is automatically added to URDF models before sending them to Gazebo:

piyushk gravatar imagepiyushk ( 2014-03-25 12:31:42 -0600 )edit

piyushk you are right, but the current (March 2014) gazeboros plugins especially the sensor plugins are not taking care of the robotNamespace. Thats way a created a pull request to get that problem fixed.

Markus Bader gravatar imageMarkus Bader ( 2014-03-28 05:06:28 -0600 )edit

@Markus Bader: I understand now. Great work on the PR. I've definitely used laser and camera with namespaces and multi-robot scenarios. The laser one with current debs is still working for me. Could you specify which sensor plugin is broken, and I'll try and reproduce the issue.

piyushk gravatar imagepiyushk ( 2014-03-28 18:04:40 -0600 )edit

answered 2013-11-01 18:00:46 -0600

nkoenig gravatar image

The full (aka scoped) name of a sensor is: world_name::model_name::link_name::sensor_name

That string is returned by Sensor::GetScopedName().

So, you could parse the sensor's scoped name for the model_name.

edit flag offensive delete link more


With GetScopedName() I am getting default::pioneer2dx::base_link::laser. The question is now can I assume that the model name is always the one after default?

Markus Bader gravatar imageMarkus Bader ( 2013-11-04 08:25:53 -0600 )edit

The model name always follows the world name. It is the nature of the model hierarchy.

nkoenig gravatar imagenkoenig ( 2013-11-07 15:48:16 -0600 )edit

Thanks, but now the question rises how important is it to get the model name? Should I implement in the Sensor class or in my plugin?

Markus Bader gravatar imageMarkus Bader ( 2013-11-08 06:06:30 -0600 )edit

Are you using the model name to prefix ROS topics? If so, you can get the model name inside the plugin.

nkoenig gravatar imagenkoenig ( 2013-11-13 16:28:44 -0600 )edit

Hi Nate! Worked it now out how you suggested. I made a merge request forked gazeborospkgs where I appied this changes on the gazeboroslaser sensor. I am now able to spawn on a very simple way to robots with the same xacro as shown in merge request.

Markus Bader gravatar imageMarkus Bader ( 2014-03-20 10:45:44 -0600 )edit

Question Tools



Asked: 2013-10-30 15:43:00 -0600

Seen: 3,339 times

Last updated: Nov 01 '13