-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Welcome to the vigir_pluginlib wiki!
How to provide new plugins of your custom package 'my_package'. Steps 1-3 has to be performed within 'my_package':
- Export your plugin:
#include <pluginlib/class_list_macros.h>
...
namespace my_namespace
{
MyPlugin::MyPlugin()
: base_class_namespace::PluginBaseClass()
...
}
PLUGINLIB_EXPORT_CLASS(my_namespace::MyPlugin, base_class_namespace::PluginBaseClass)
- Create my_plugin.xml file:
<library path="lib/libmy_package">
<class type="my_namespace::MyPlugin" base_class_type="base_class_namespace::PluginBaseClass">
<description>
MyPlugin: My awesome first plugin
</description>
</class>
...
</library>
Please take note that you cannot mixup plugins with base classes from different packages as you have to export for each package separately.
See: http://wiki.ros.org/pluginlib/PluginExport
- Export to ROS Package System by adding into package.xml:
...
<export>
...
<base_class_package plugin="${prefix}/my_plugin.xml" />
</export>
...
Note: The package.xml must directly depend on the base_class_package (build_depend and run_depend). Indirect dependencies won't work.
- Add class loader to plugin manager:
vigir_pluginlib::PluginManager::addPluginClassLoader<PluginBaseClass>("base_class_package", "base_class_namespace::PluginBaseClass");
Note that there are indeed no modifications of base class package needed!
Details see here:
http://wiki.ros.org/pluginlib/PluginExport
The vigir_pluginlib uses plugin_lib under the hood where many magic is happening. This can cause many unforeseen issues.
- MultiLibraryClassLoader blames about not existing library. Example:
[PluginManager] Plugin (thor_mang_step_plan_msg_plugin) of type_class 'thor_mang_footstep_planning::ThorMangStepPlanMsgPlugin' failed to load for some reason. Error: MultiLibraryClassLoader: Could not create object of class type thor_mang_footstep_planning::ThorMangStepPlanMsgPlugin as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()
Solution: Ensure all above steps have been done right. Another very weird issue may arise if you try to load plugins from a package A which have been depended from another package B which exports plugins too. NEVER DO THAT!!! As the library from A may be linked into B, while loading library B the MultiLibraryClassLoader may invoke all PLUGINLIB_EXPORT_CLASS macros from A too. This confuses the class_loaders as all plugins from A seems now to be part of package B.