gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.16k stars 476 forks source link

Adding robot_namespace to sdf nested models #734

Open osrf-migration opened 11 years ago

osrf-migration commented 11 years ago

Original report (archived issue) by Dave Coleman (Bitbucket: Dave Coleman).


This is a re-post of an issue for gazebo_ros_pkgs, see that link.

Per John Hsu - we need to add robot namespace functionality inside of Gazebo's URDF parsing functionality in the Gazebo repo at

gazebo/sdf/interface/parser_urdf.cc
osrf-migration commented 11 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Can you explain "robot namespace functionality" with an example?

osrf-migration commented 11 years ago

Original comment by Dave Coleman (Bitbucket: Dave Coleman).


I'm not completely clear on the concept, but basically we want to be able to launch multiple robots into gazebo and have all their plugins be namespaces to avoid naming conflicts.

The spawn_model script has a robot_namespace argument that it uses to add a /robot1 namespace within a URDF, but it is unable to namespace plugins or models that are included using the Gazebo include tag like:

<include>
  <uri>model://mymodel</uri>
</include>

So the ability to add namespaces to models and plugins needs to be pushed into the Gazebo parser itself.

See fmder's original issue for more details https://github.com/osrf/gazebo_ros_pkgs/issues/2#issuecomment-19277757

osrf-migration commented 11 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


After talking about it with @davetcoleman I think the desired functionality is related to overwriting plugin parameter elements.

For example, consider a robot model that uses a plugin with some parameters:

<model name="complicated_robot">
  <link name="awesome_link"/>
  <plugin name="magic_plugin" filename="libAwesome.so">
    <pi>3.14159</pi>
    <namespace>default</namespace>
  </plugin>
</model>

The desired functionality is to be able use the <include> tag to overwrite plugin parameters (<namespace> in the following example):

<include>
  <uri>model://complicated_robot</uri>
  <plugin name="magic_plugin>
    <namespace>unique_name</namespace>
  </plugin>
</include>

The include block should expand to the following, with the <namespace> parameter overwritten.

<model name="complicated_robot">
  <link name="awesome_link"/>
  <plugin name="magic_plugin" filename="libAwesome.so">
    <pi>3.14159</pi>
    <namespace>unique_name</namespace>
  </plugin>
</model>
osrf-migration commented 11 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Is this a case where something like xacro for sdf would be useful?

osrf-migration commented 11 years ago

Original comment by Dave Coleman (Bitbucket: Dave Coleman).


Your proposed solution

<include>
  <uri>model://complicated_robot</uri>
  <plugin name="magic_plugin>
    <namespace>unique_name</namespace>
  </plugin>
</include>

is nice in that it allows any number of parameters to be passed to the plugin. But maybe a simpler implementation could be done by just having a namespace tag that is then passed to the plugins and anything else that could use it:

<include>
  <uri>model://complicated_robot</uri>
  <namespace>robot2</namespace>
</include>

It depends if we think there is a use case for needing to pass lots of customizations to generic plugins...

osrf-migration commented 11 years ago

Original comment by John Hsu (Bitbucket: hsu, GitHub: hsu).


for the first option, it might be more clear to use reference in place of name, given we are referring to an existing plugin, not creating one. For example:

<include>
  <uri>model://complicated_robot</uri>
  <plugin reference="magic_plugin>
    <namespace>unique_name</namespace>
  </plugin>
</include>
osrf-migration commented 11 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


+1 to @hsu 's idea about using a reference attribute instead of name.

@davetcoleman : sdf doesn't currently define a <namespace> tag, so I'm not sure where it would be used outside of a plugin.

@nkoenig xacro would probably help solve this problem.

osrf-migration commented 11 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


I assume xacro won't get into SDF as soon as you need this functionality. If that's the case, then I support John and Steve with reference.

osrf-migration commented 11 years ago

Original comment by Dave Coleman (Bitbucket: Dave Coleman).


I think duplicating a plugin's properties via a reference tag is messy in that you now have multiple places contributing to a plugin's properties. I think it's giving more power than necessary for this small problem.

Could we not add the <namespace> tag to SDF? Its the same as adding a <plugin> tag but much simpler. Another option, which I like, is to automatically pass a namespace to all plugins based on the internal namespace Gazebo uses for multiple models of the same type. I believe internally Gazebo namespaces objects as so:

pr2/
pr2_0/
pr2_1/

If you do need more plugin customization, you could just copy the the elements into your base URDF using the tags.

But the other way works, too.

osrf-migration commented 11 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


@davetcoleman, I don't think of it as messy to use the reference tag. I consider the sdf values set in a model as the defaults, and the reference tag lets you override the defaults. It seems useful to me.

Allowing a <namespace> to be specified via sdf would require internal changes to gazebo, since the namespace for gazebo topics is based on the world name and the model name "~/" + modelName.

osrf-migration commented 7 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).