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