Tutorial: Using Gazebo plugins with ROS
http://gazebosim.org/tutorials?tut=ros_gzplugins
Plugin Types
Gazebo supports several plugin types, and all of them can be connected to ROS, but only a few types can be referenced through a URDF file:
- ModelPlugins, to provide access to the physics::Model API
- SensorPlugins, to provide access to the sensors::Sensor API
- VisualPlugins, to provide access to the rendering::Visual API
Adding a ModelPlugin
In short, the ModelPlugin
is inserted in the URDF inside the <robot>
element. It is wrapped with the <gazebo>
pill, to indicate information passed to Gazebo. For example:
<robot>
... robot description ...
<gazebo>
<plugin name="differential_drive_controller" filename="libdiffdrive_plugin.so">
... plugin parameters ...
</plugin>
</gazebo>
... robot description ...
</robot>
Upon loading the robot model within Gazebo, the diffdrive_plugin
code will be given a reference to the model itself, allowing it to manipulate it. Also, it will be give a reference to the SDF element of itself, in order to read the plugin parameters passed to it.
Adding a SensorPlugin
Specifying sensor plugins is slightly different. Sensors in Gazebo are meant to be attached to links, so the <gazebo>
element describing that sensor must be given a reference to that link. For example:
<robot>
... robot description ...
<link name="sensor_link">
... link description ...
</link>
<gazebo reference="sensor_link">
<sensor type="camera" name="camera1">
... sensor parameters ...
<plugin name="camera_controller" filename="libgazebo_ros_camera.so">
... plugin parameters ..
</plugin>
</sensor>
</gazebo>
</robot>
Upon loading the robot model within Gazebo, the camera_controller
code will be given a reference to the sensor, providing access to its API. Also, it will be give a reference to the SDF element of itself, in order to read the plugin parameters passed to it.
Plugins available in gazebo_plugins
Camera
Description: provides ROS interface for simulating cameras such as wge100camera by publishing the CameraInfo and Image ROS messages as described in sensormsgs.
Multicamera
Description: synchronizes multiple camera's shutters such that they publish their images together. Typically used for stereo cameras, uses a very similar interface as the plain Camera
plugin
Note: currently only supports stereo cameras.
Depth Camera
Description: simulates a sensor like a Kinect, which is duplicated in the Kinect plugin. Will probably be merged in the future.
Openni Kinect
Description: simulates a Microsoft Kinect, publishes the same topics as the corresponding ROS drivers for the Microsoft kinect as documented in the Fuerte documentation here.
GPU Laser
Description: simulates laser range sensor by broadcasting LaserScan message as described in sensor_msgs. See Hokuyo Laser Scanners Reference.
Laser
Description: the non-GPU version of GPU Laser
, but essentially uses the same code. See GPU Laser for documentation.
Block Laser
Description: provides grid style laser range scanner simulation (e.g. Velodyne).
F3D (Force Feedback Ground Truth)
Description: broadcasts external forces on a body in simulation over WrenchStamped message as described in geometry_msgs.
Force
Description: ROS interface for applying Wrench (geometry_msgs) on a body in simulation.
IMU (GazeboRosImu)
Description: simulates IMU sensor. Measurements are computed by the ROS plugin, not by Gazebo.
IMU sensor (GazeboRosImuSensor)
Description: simulates an Inertial Motion Unit sensor, the main differences from IMU (GazeboRosIMU) are: - inheritance from SensorPlugin instead of ModelPlugin, - measurements are given by gazebo ImuSensor instead of being computed by the ros plugin, - gravity is included in inertial measurements.
Joint Pose Trajectory
Description: listens to a jointtrajectoryaction and plays back the set of joint positions. Sets the set of joints to exact positions without regards to simulated physics and forces.
P3D (3D Position Interface for Ground Truth)
Description: broadcasts the inertial pose of any body in simulation via Odometry message as described in nav_msgs via ROS topic.
Projector
Description: projects a static texture from a source outwards, such as used with the PR2's original head camera sensor. See API documentation for more information.
Prosilica Camera
Description: simulates interfaces exposed by a ROS Prosilica Camera. Here's an example URDF Xacro macro.
Bumper
Description: provides contact feedback via ContactsState message.
Differential Drive
Description: model plugin that provides a basic controller for differential drive robots in Gazebo. You need a well defined differential drive robot to use this plugin.
Skid Steering Drive
Description: model plugin that provides a basic controller for skid steering drive robots in Gazebo (Pioneer 3AT for instance).
Video Plugin
Description: visual plugin that displays a ROS image stream on an OGRE Texture inside gazebo. This plugin does not modify the texture of one of the existing link surfaces, but creates a new texture on top of it. The texture will be created on the XY plane, visible from the +Z side. The plugin requires a pixel size while constructing the texture, and will resize incoming ROS image messages to match if they are a different size.
Planar Move Plugin
Description: model plugin that allows arbitrary objects (for instance cubes, spheres and cylinders) to be moved along a horizontal plane using a geometry_msgs/Twist message. The plugin works by imparting a linear velocity (XY) and an angular velocity (Z) to the object every cycle.