Skip to content

Embed gazebo yarp plugins in an SDF model

Silvio Traversaro edited this page Jul 21, 2014 · 3 revisions

To expose sensors and actuators of your gazebo model as Yarp devices, you should before have an URDF/SDF model of your robot.

You can read more about how to create an SDF model (for example converting an URDF model) in Gazebo documentation.

Once you have an SDF model of your robot, it is possible to use gazebo-yarp-plugins embedding appropriate tags in the SDF file.

Controlboard

In Yarp the controlboard devices are used both to expose joint or motor level sensors (such as encoders) and to encapsulate low-level control capabilities (such as joint-level position, velocity or torque control).

To add a gazebo_yarp_controlboard plugin to your SDF model, just add an appropriate plugin tag as a child of the tag. Let us see for example how the plugin for the torso's control board is added in the iCub SDF model:

<sdf version='1.4'>
  <model name='iCub'>

    ...usual sdf content...

    <plugin name="controlboard_torso" filename="libgazebo_yarp_controlboard.so">
        <yarpConfigurationFile>model://icub/conf/gazebo_icub_torso.ini</yarpConfigurationFile>
    </plugin>

  </model>
</sdf>

The yarpConfigurationFile tag specifies a Gazebo URI that contains the information used to instantiate the device. For this example you can check the gazebo_icub_torso.ini file. The jointNames option specifies the names of the Gazebo model joints that are controlled by the controlboard (in this case the three joints torso_yaw, torso_roll and torso_pitch).

Setting Initial Configuration for a Kinematic Chain:

An optional tag of the gazebo_yarp_controlboard plugin is:

<initialConfiguration></initialConfiguration>

which can be used to set an initial configuration for a particular controlboard.

Supposing that you want to set the initial configuration for iCub's torso, you can write something like:

  <plugin name="controlboard_torso" filename="libgazebo_yarp_controlboard.so">
        <yarpConfigurationFile>model://icub/conf/gazebo_icub_torso.ini</yarpConfigurationFile>
        <initialConfiguration>0.10 0.0 -0.10</initialConfiguration>
  </plugin>

Notice that the initial values are specified in Radians.