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

Creating plugins

We will create a base class called RegularPolygon from which all of our plugins, including Triangle and Square, would inherit.

The source code of packages can be downloaded from GitHub (https://github.com/kbipin/Robot-Operating-System-Cookbook):

#ifndef PLUGINLIB_TUTORIALS__POLYGON_BASE_H_ 
#define PLUGINLIB_TUTORIALS__POLYGON_BASE_H_ 
 
namespace polygon_base 
{ 
  class RegularPolygon 
  { 
    public: 
      virtual void initialize(double side_length) = 0; 
      virtual double area() = 0; 
      virtual ~RegularPolygon(){} 
 
    protected: 
      RegularPolygon(){} 
  }; 
}; 
#endif 

We will create two RegularPolygon plugins; the first will be Triangle and the second will be Square: pluginlib_tutorials/include/pluginlib_tutorials/polygon_plugins.h.

 #ifndef PLUGINLIB_TUTORIALS__POLYGON_PLUGINS_H_ ...

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