Robotics StackExchange | Archived questions

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

Hi

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?

Greetings Markus

Asked by Markus Bader on 2013-10-30 15:43:00 UTC

Comments

Answers

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: https://github.com/ros-simulation/gazebo_ros_demos/blob/master/rrbot_description/urdf/rrbot.gazebo#L7

Asked by jbohren on 2013-10-31 11:57:33 UTC

Comments

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 looks to me like a design flaw or workaround.

Asked by Markus Bader on 2013-11-04 09:29:50 UTC

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 <robotNamespace> tag is sort of sloppy, but I personally tend to propagate these things with xacro arguments anyway.

Asked by jbohren on 2013-11-04 22:22:10 UTC

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.

Asked by Markus Bader on 2013-11-05 05:34:59 UTC

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: https://github.com/ros-simulation/gazebo_ros_pkgs/blob/hydro-devel/gazebo_ros/src/gazebo_ros_api_plugin.cpp#L2119

Asked by piyushk on 2014-03-25 12:31:42 UTC

piyushk you are right, but the current (March 2014) gazebo_ros plugins especially the sensor plugins are not taking care of the robotNamespace. Thats way a created a pull request to get that problem fixed. https://github.com/ros-simulation/gazebo_ros_pkgs/pull/141

Asked by Markus Bader on 2014-03-28 05:06:28 UTC

@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.

Asked by piyushk on 2014-03-28 18:04:40 UTC

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.

Asked by nkoenig on 2013-11-01 18:00:46 UTC

Comments

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?

Asked by Markus Bader on 2013-11-04 09:25:53 UTC

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

Asked by nkoenig on 2013-11-07 16:48:16 UTC

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?

Asked by Markus Bader on 2013-11-08 07:06:30 UTC

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

Asked by nkoenig on 2013-11-13 17:28:44 UTC

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

Asked by Markus Bader on 2014-03-20 10:45:44 UTC