O'Reilly logo

Robot Operating System Cookbook by Kumar Bipin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a plugin

We already have a plugin that compiles as a shared library, and so we could attach it to a world model in an SDF file (refer to the SDF documentation for more information). During startup, Gazebo parses the SDF file, locates the plugin, and loads the code.

Next, we will create a world file called ~/gazebo_plugin_tutorial/hello.world and copy the following code into it:

<?xml version="1.0"?> 
<sdf version="1.4"> 
  <world name="default"> 
    <plugin name="hello_world" filename="libhello_world.so"/> 
  </world> 
</sdf> 

Finally, we will pass it to gzserver on startup:

$ gzserver ~/gazebo_plugin_tutorial/hello.world --verbose

We will see output similar to this:

Gazebo plugin

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required