Gazebo | Ignition | Community
Ask Your Question

Why does SDF plugin syntax not support additional parameters like URDF?

asked 2013-03-20 15:42:23 -0600

piyushk gravatar image

updated 2013-03-20 18:37:10 -0600

All the gazebo ros plugins have a bunch of parameters that are set in the URDF and parsed by parser_urdf. SDFs don't seem to have the same functionality. As far as I can tell, the code doesn't even support it.

How would you supply parameters to the plugins inside an SDF?

Thanks!! Piyush

EDIT #1:

It looks like I was reading the code incorrectly, and @AndreiHaidu's answer is correct. My test case uses VisualPlugins which still fails (all parameters get wiped in the SDF received by the visual plugin). Are VisualPlugin's supposed to have this same functionality as well?

Edit #2:

Here are a few files that should reproduce the error:

The plugin works for the default parameters, displaying a ROS image topic inside gazebo.

Here's a bit more info that might be useful. I have a patch in the works that forwards visual plugins in parser_urdf. For my real setup I have verified that Gazebo receives the correct converted SDF:

<visual name='base_footprint_visuallaptop_screen_link'>
  <pose>0.236849 -0.000000 1.093250 0.000000 -1.047200 -0.000000</pose>
      <size>0.254000 0.330200 0.019050</size>
  <plugin name='laptop_video_controller' filename=''>

By the time this reaches Visual::Load, it gets changed to:

<visual name='robot1::base_footprint::base_footprint_visuallaptop_screen_link'>
      <size>0.254000 0.330200 0.019050</size>
  <pose>0.236849 0.000000 1.093250 0.000000 -1.047200 0.000000</pose>
  <plugin name='laptop_video_controller' filename=''/>

This is as far as I have gotten to figuring out whats going wrong.

edit retag flag offensive close merge delete


Can you post your SDF. The visual plugin should behave exactly like every other plugin.

nkoenig gravatar imagenkoenig ( 2013-03-20 17:53:00 -0600 )edit

@nkoenig: see updated question

piyushk gravatar imagepiyushk ( 2013-03-20 18:42:03 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-21 13:41:59 -0600

piyushk gravatar image

I had a bit more time to take a look at this. It looks like unlike model Plugins, Visual Plugins are created by sending a visual message from Link::Load. At this time, the plugin msg does not support copying over the inner XML data from the SDF and this information is lost.

I've filed a bug report here:

edit flag offensive delete link more

answered 2013-03-20 16:22:07 -0600

AndreiHaidu gravatar image


This is possible, I will give you a template:

Here is a plugin example in the sdf file:

    <plugin name='plugin_name' filename=''>

For example in the Load function of the plugin you can get the parameter as following:

void PluginName::Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
double param;

if (!_sdf->HasElement("sdf_parameter"))
    // if parameter tag does NOT exist
    std::cout << "Missing parameter <sdf_parameter> in PluginName, default to 0" << std::endl;
    param = 0;
    // if parameter tag exists, get its value
else param = _sdf->GetElement("sdf_parameter")->GetValueDouble();

Cheers, Andrei

edit flag offensive delete link more


Thanks for the quick response. I'm using similar code which seems to be failing for VisualPlugins. I've updated the question.

piyushk gravatar imagepiyushk ( 2013-03-20 17:05:14 -0600 )edit

Very helpful! Thanks

Angelos gravatar imageAngelos ( 2017-06-28 03:53:38 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2013-03-20 15:42:23 -0600

Seen: 3,151 times

Last updated: Mar 21 '13