O'Reilly logo

Robot Operating System Cookbook by Kumar Bipin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hello World plugin

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required