Robot Operating System Cookbook
上QQ阅读APP看书,第一时间看更新

Plugins registration

In the preceding subsection, we created standard C++ classes. Now, we will discuss pluginlib-specific work as a declaration of the Triangle and Square classes as plugins. Let's look at the source code in the src/polygon_plugins.cpp file:

#include <pluginlib/class_list_macros.h> 
#include <pluginlib_tutorials_/polygon_base.h> 
#include <pluginlib_tutorials_/polygon_plugins.h> 
 
PLUGINLIB_EXPORT_CLASS(polygon_plugins::Triangle, polygon_base::RegularPolygon) 
PLUGINLIB_EXPORT_CLASS(polygon_plugins::Square, polygon_base::RegularPolygon) 

Here, we have registered the Triangle and Square classes as plugins using the PLUGINLIB_EXPORT_CLASS macro.