The gazebo/gazeboserver.hh include will bring in everything needed to compile the plugin. Each plugin must inherit from the Plugin base class, define a Load function, and register itself using the GZ_REGISTER_PLUGIN macro.

A package config file is included in the Gazebo install called gazeboserver.pc that should make compilation easy:

pkg-config --libs --cflags gazeboserver

There is also an example cmake file located in the Gazebo sources in the plugins directory.

The following is an example plugin that works in conjunction with the elevator.world file that is located in the worlds directory in the sources.

This example plugin connects to the World's Update signal, which is called once every iteration of the simulation. Two geometries that act as contact sensors exist in the world. Within a running simulation, these two geoms are colored red. The elevator plugin connects to each of the geom's contact signals. When the first geom is hit, then the doors to the elevator are opened. When the second contact is hit, then the elevator is raised.

Examples of how to access bodies, geoms, and callbacks are provided in this example plugin. In order to use this plugin, use the follow steps:

1. Compile the elevator plugin (you should be in the directory containing the gazebo sources):

mkdir plugins/build

cd plugins/build

cmake ../

make

2. In another terminal, launch gazebo with the elevator.world:

gazebo worlds/elevator.world

3. In the terminal in which you compiled the plugins, load the elevator plugin:

gazeboplugin add ./libelevator.so elevator

The gazeboplugin command line tool allows you to insert, list, and remove plugins. The first parameter specifies the action (add or list or remove). When adding, the second argument is the location of the plugin file, and the third argument is a name for the plugin.
It is also possible to list the currently running plugins:

gazeboplugin list

And to remove a plugin you only have to specify the name given to the plugin:

gazeboplugin remove elevator

4. In order to make the doors open and the elevator raise, something needs to hit the contact geoms. You can either modify the elevator.world to include a robot that moves around, or you can manually spawn a sphere using the GUI and drop it on the contact geoms.