Creating a Gazebo plugin

From The Player Project

Jump to: navigation, search
m (Reverted edits by Woolerystixmaker (talk) to last revision by Rmattes)
 
Line 11: Line 11:
The following is a stub for a plugin
The following is a stub for a plugin
-
<pre>
+
<source lang="cpp">
#include <gazebo/gazeboserver.hh>
#include <gazebo/gazeboserver.hh>
Line 31: Line 31:
   GZ_REGISTER_PLUGIN("ExamplePlugin", ExamplePlugin)
   GZ_REGISTER_PLUGIN("ExamplePlugin", ExamplePlugin)
}
}
-
</pre>
+
</source>
The <tt>gazebo/gazeboserver.hh</tt> include will bring in everything needed to compile the plugin. Each plugin must inherit from the <tt>Plugin</tt> base class, define a <tt>Load</tt> function, and register itself using the <tt>GZ_REGISTER_PLUGIN</tt> macro.
The <tt>gazebo/gazeboserver.hh</tt> include will bring in everything needed to compile the plugin. Each plugin must inherit from the <tt>Plugin</tt> base class, define a <tt>Load</tt> function, and register itself using the <tt>GZ_REGISTER_PLUGIN</tt> macro.
Line 43: Line 43:
The following is an example plugin that works in conjunction with the elevator.world file that is located in the <tt>worlds</tt> directory in the sources.
The following is an example plugin that works in conjunction with the elevator.world file that is located in the <tt>worlds</tt> directory in the sources.
-
<pre>
+
<source lang="cpp">
#include <boost/bind.hpp>
#include <boost/bind.hpp>
#include <gazebo/gazeboserver.hh>
#include <gazebo/gazeboserver.hh>
Line 116: Line 116:
   GZ_REGISTER_PLUGIN("Elevator", Elevator)
   GZ_REGISTER_PLUGIN("Elevator", Elevator)
}
}
-
</pre>
+
</source>
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.  
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.  

Latest revision as of 22:57, 29 August 2011

Personal tools