# Load plugin from separate package

Is it possible to load a plugin developed in a separate package without declaring it in the package where the base class resides? Would it be enough to declare the plugin in the .cpp file where the actual plugin lives?

When I tried this, I got the error:

[ERROR] [1372978694.271503470]: The plugin failed to load for some reason. Error: According to the loaded plugin descriptions the class amigctrl_plugin/AmigoBot with base class type cruise_plugin_base::PBase does not exist. Declared types are  cruise_core/amigo_locomotion_plugin


So the plugin that I developed isn't listed here. Just the one that exists in the original package. Can plugins only be declared in the package where they are to be loaded? Is there a way around this?

EDIT: Fixed one error, another came up to go. First, for reference:

  <export>
<pkg_name plugin="${prefix}/plugin.xml" /> </export>  The tag "pkg_name" must be the name of the package where the base class resides. I named it the package name of the actual plugin. Now we have a new runtime error, saying: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid Aborted (core dumped)  Any advice on this would be appreciated. edit retag close merge delete ## 3 Answers Sort by » oldest newest most voted Ok I fixed it myself. What I did was: 1. Compile the base class into a library (Done is CMakeLists.txt) 2. Export that library from the base class manifest (Done in manifest.xml in Fuerte) 3. Depend on the base class package from the plugin packages manifest 4. Plugin can be declared in a source file within the package where the plugin resides 5. Export the plugin library (Done in the plugin package manifest.xml) My only problem was confusing all the names it works now. more ## Comments i also have a pluginlib in a package and want to use it in another package. i have followed the plugin tutorial. i get an error error: cannot convert ‘boost::shared_ptr<kinematics::kinematicsbase>’ to ‘kinematics::KinematicsBase*’ in assignment. this is my program on the begining: pluginlib::ClassLoader<kinematics::kinematicsbase> poly_loader("kinematics_base", "kinematics::KinematicsBase"); kinematics::KinematicsBase* kinbase=NULL; ( 2013-08-17 00:58:38 -0500 )edit A good place to look would be http://www.ros.org/wiki/pluginlib. Possibly just a missing xml or export. more ## Comments Seemed to be the case. The the tag in the export section in the manifest.xml has to be the name of the package where the base class resides. I made it the name of the package that the plugin resides. Now I'm getting another runtime error. Details above. ( 2013-07-04 17:52:47 -0500 )edit Hard to tell just based on that error line. Most likely you need to check through your plugin code for bugs. ( 2013-07-04 20:36:05 -0500 )edit Additionally of what @candronikos answered (which is very helpful), I would like to add more detail to point #2 : which says "Export that library from the base class manifest (Done in manifest.xml in Fuerte)" In catkinized versions manifest.xml is obviously now replaced by package.xml and the export must be done like this: <export> <my_pkg_base_class plugin="${prefix}/plugins.xml" />
</export>


where my_pkg_base_class is the pkg name that contains your base class, make sure you are able to do roscd to it!

I spent a lot of time trying to make a moveit move_group capability plugin because I was exporting with my_pkg_base_class as move_group but it should be moveit_ros_move_group, like this:

<export>
<moveit_ros_move_group plugin="\${prefix}/plugins.xml" />
</export>


Even when the namespace and folder name was set to move_group!

more