June 2018
Intermediate to advanced
484 pages
11h 36m
English
Plugins are designed to be simple. Here, we will discuss a bare bones World plugin which contains a class with a few member functions.
First, we will make a directory and a .cc file for the new plugin:
$ mkdir ~/gazebo_plugin_tutorial $ cd ~/gazebo_plugin_tutorial $ gedit hello_world.cc
You can also use the existing package from the chapter3_tutorials/ gazebo_plugin_tutorial file on GitHub.
Next, we will add the following code to hello_world.cc:
#include <gazebo/gazebo.hh> namespace gazebo { class WorldPluginTutorial : public WorldPlugin { public: WorldPluginTutorial() : WorldPlugin() { printf("Gazebo Says: Hello World!n"); } public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf) { } }; GZ_REGISTER_WORLD_PLUGIN(WorldPluginTutorial) ...