Gazebo | Ignition | Community
Ask Your Question
1

Joint and link plugins: do they really exist?

asked 2018-11-14 08:51:02 -0500

Georacer gravatar image

updated 2018-11-14 09:22:08 -0500

Hello everyone!

My intention is to write a plugin that will be attached directly to a link or joint, not to the model, in order to apply a force or torque.

I see in this tutorial (http://gazebosim.org/tutorials?tut=ro...) that the gazebo tag can accept the reference argument, which can be pointed to the link or joint of choice.

However, it is not clear to me what this reference is or where it is accessed by the plugin code.

The standard Load() function of the ModelPlugin accepts as arguments a ModelPtr _model and a SDFElement _sdf (for the sdf structure of the plugin tag/environment itself).

How will I go about obtaining the reference link/joint directly?

P.S. I know that I could pass a link_name argument in the plugin and get that from the plugin code, from the _sdf->GetElement("link_name"), but this doesn't take advantage of the reference tag.

Thank you in advance, George

edit: Fixed link to point to the correct internal link

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-11-14 12:32:35 -0500

chapulina gravatar image

I believe the tutorial is partially wrong. Yes, it is true that you can use a link or a joint as a reference in URDF to inject a plugin tag into it. But there's no point in doing that, because plugins under links and joints are not valid SDF.

See this example URDF:

<?xml version="1.0"?>
<robot name="test">

  <link name="link1">
    <inertial>
      <mass value="0.5"/>
      <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
  </link>

  <joint name="joint1" type="revolute">
    <axis xyz="0 -1 0"/>
    <parent link="link1"/>
    <child link="link2"/>
    <limit effort="30" velocity="1.0" lower="-1" upper="1" />
  </joint>

  <link name="link2">
    <inertial>
      <mass value="0.5"/>
      <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
  </link>

  <!-- OK: model plugin under <robot> ends up under <model> -->
  <gazebo>
    <plugin name="model_plugin" filename="model.so">
    </plugin>
  </gazebo>

  <!-- OK: sensor plugin under <gazebo reference="link name"><sensor> ends up under <sensor> -->
  <gazebo reference="link1">
    <sensor type="camera" name="camera">
        <plugin name="sensor_plugin" filename="sensor.so">
        </plugin>
    </sensor>
  </gazebo>

  <!-- NOT OK: ? plugin under <gazebo reference="link name"> ends up under <link> -->
  <gazebo reference="link2">
    <plugin name="link_plugin" filename="link.so">
    </plugin>
  </gazebo>

  <!-- NOT OK: ? plugin under <gazebo reference="joint name"> ends up under <joint> -->
  <gazebo reference="joint1">
    <plugin name="joint_plugin" filename="joint.so">
    </plugin>
  </gazebo>
</robot>

You can convert it to SDF as follows:

gz sdf -p test.urdf > test.sdf

And this is the result:

<sdf version='1.6'>
  <model name='test'>
    <link name='link1'>
      ...
      <sensor name='camera' type='camera'>
        <plugin name='sensor_plugin' filename='sensor.so'/>
      </sensor>
    </link>
    <link name='link2'>
      ...
      <plugin name='link_plugin' filename='link.so'/>
    </link>
    <joint name='joint1' type='revolute'>
      ...
      <plugin name='joint_plugin' filename='joint.so'/>
    </joint>
    <plugin name='model_plugin' filename='model.so'/>
  </model>
</sdf>

However, that is not valid SDF, since link_plugin and joint_plugin have no meaning.

So:

  1. I think that the parts of the tutorial which encourage inserting plugins under links and joints should be removed.
  2. I'm not sure if there's a problem with the URDF -> SDF conversion. The tutorial says that "Any elements inside the <gazebo> tags which are not (in the spec) are directly inserted into the (relevant) tag of the generated SDF". So it sounds like that's the desired behavior, but I'm not sure why.
edit flag offensive delete link more

Comments

Thank you for your answer! Indeed, I checked again at the SDF documentation and there is no `plugin` tag for `Link` nor for `Joint`. Naturally, there is one for `Sensor`. It's really frustrating going against bad documentation or tutorials...

Georacer gravatar imageGeoracer ( 2018-11-14 12:59:49 -0500 )edit
chapulina gravatar imagechapulina ( 2018-11-14 16:12:45 -0500 )edit
1
1

answered 2018-11-14 09:03:20 -0500

nkoenig gravatar image

There are no joint or link plugins. You can use a model plugin to apply forces and torques to links to and joints.

Refer to the API, and look at example plugins like this one.

edit flag offensive delete link more

Comments

I've examined the API and examples dozens of times. The actual question is if this information on passing link and joint references to plugins (http://gazebosim.org/tutorials?tut=ros_gzplugins#Addingaplugintothe%3Clink%3Eelement) is actually wrong and bad. Or am I understanding the "reference" argument wrong?

Georacer gravatar imageGeoracer ( 2018-11-14 09:24:02 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-14 08:51:02 -0500

Seen: 352 times

Last updated: Nov 14 '18