Gazebo world plugins - JenniferBuehler/gazebo-pkgs GitHub Wiki

Some packages which work with Gazebo depend on Gazebo plugins to be loaded. Some of these plugins will need to be loaded as Gazebo "World" plugins, which normally have to be listed in the Gazebo "world" file. However I consider this a bit inconvenient because that prohibits use of many already existing Gazebo worlds, e.g. the ones shipped with gazebo_ros. So I added a Gazebo "System" plugin, called libgazebo_plugin_loader.so which can work around this: The plugin can load other world plugins at runtime, so you do not have to specify the required world plugins in the gazebo .world file, but instead can specify the plugins to load in a .yaml file.

This plugin can be found in the package gazebo_world_plugin_loader. The wiki page for object information illustrates an example world plugin which uses this world plugin loader.

Implementation

Gazebo (or gzserver) has to be launched with the argument

gzserver -s libgazebo_world_plugin_loader.so

to load the plugin. The gazebo_ros launch files (e.g. empty_world.launch) have a parameter extra_gazebo_args which can be used to pass extra parameters to the launching of gzserver.

For an example, refer to the launch file jaco_on_table_gazebo_controlled.launch in repository jaco-arm-pkgs, which sets the required extra arguments.

The Gazebo world plugins to be loaded are specified as ROS parameters. This YAML file is used by default by the tutorial files and can be used as a template:

rosed gazebo_state_plugins WorldPlugins.yaml

In this example the gazebo_object_info plugin is loaded (the "object information service" also described on this wiki), which can be used to to request information (e.g. position and shape) of objects in Gazebo:

world_name: "default"
world_plugins:
    - name: gazebo_object_info
      file: libgazebo_object_info.so

There is also a plugin called gazebo_map_publisher which you only need if you would like gazebo to publish a 2D grid occupancy map of the world as well.