Home | Tutorials | Wiki | Issues
Ask Your Question
1

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:

http://farnsworth.csres.utexas.edu/sh... http://farnsworth.csres.utexas.edu/sh...rosvideo.h http://farnsworth.csres.utexas.edu/sh...rosvideo.cc

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>
  <geometry>
    <box>
      <size>0.254000 0.330200 0.019050</size>
    </box>
  </geometry>
  <material>
    <script>
      <name>Gazebo/Grey</name>
    </script>
  </material>
  <plugin name='laptop_video_controller' filename='libgazebo_ros_video.so'>
    <height>240</height>
    <width>320</width>
    <topicName>image_raw</topicName>
  </plugin>
</visual>

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

<visual name='robot1::base_footprint::base_footprint_visuallaptop_screen_link'>
  <geometry>
    <box>
      <size>0.254000 0.330200 0.019050</size>
    </box>
  </geometry>
  <pose>0.236849 0.000000 1.093250 0.000000 -1.047200 0.000000</pose>
  <material>
    <script>
      <name>Gazebo/Grey</name>
      <uri>__default__</uri>
    </script>
  </material>
  <plugin name='laptop_video_controller' filename='libgazebo_ros_video.so'/>
</visual>

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

edit retag flag offensive close merge delete

Comments

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
0

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: https://bitbucket.org/osrf/gazebo/issue/598/visualplugin-parameters-lost-on-spawning-a

edit flag offensive delete link more
2

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

AndreiHaidu gravatar image

Hi,

This is possible, I will give you a template:

Here is a plugin example in the sdf file:

    <plugin name='plugin_name' filename='libplugin_name.so'>
    <sdf_parameter>69.0</sdf_parameter>
</plugin>

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

Comments

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

Stats

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

Seen: 2,930 times

Last updated: Mar 21 '13