ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Load plugin for IKFast class using C++

asked 2016-11-16 16:10:19 -0600

JoshMarino gravatar image

updated 2016-11-16 16:27:01 -0600

Hello there,

I am trying to load the IKFast MoveIt! plugin I already created through a C++ file using pluginlib. I am trying to do so in order to get access to the IKFast functions outside of MoveIt!.

When following the tutorial, I get this error when trying to compile using catkin_make:

Linking CXX executable /home/josh/catkin_ws/devel/lib/ikfast_lf_plugin_load_test/IKFast_leg_LF_loader

CMakeFiles/IKFast_leg_LF_loader.dir/src/IKFast_leg_LF_loader.cpp.o: In function `std::map<std::string, class_loader::class_loader_private::AbstractMetaObjectBase*, std::less<std::string>, std::allocator<std::pair<std::string const, class_loader::class_loader_private::AbstractMetaObjectBase*>
> >& class_loader::class_loader_private::getFactoryMapForBaseClass<kinematics::KinematicsBase>()':

IKFast_leg_LF_loader.cpp:(.text._ZN12class_loader20class_loader_private25getFactoryMapForBaseClassIN10kinematics14KinematicsBaseEEERSt3mapISsPNS0_22AbstractMetaObjectBaseESt4lessISsESaISt4pairIKSsS6_EEEv[_ZN12class_loader20class_loader_private25getFactoryMapForBaseClassIN10kinematics14KinematicsBaseEEERSt3mapISsPNS0_22AbstractMetaObjectBaseESt4lessISsESaISt4pairIKSsS6_EEEv]+0x16): undefined reference to `typeinfo for kinematics::KinematicsBase'

CMakeFiles/IKFast_leg_LF_loader.dir/src/IKFast_leg_LF_loader.cpp.o:(.rodata._ZTIPN10kinematics14KinematicsBaseE[_ZTIPN10kinematics14KinematicsBaseE]+0x18): undefined reference to `typeinfo for kinematics::KinematicsBase'

collect2: error: ld returned 1 exit status

make[2]: *** [/home/josh/catkin_ws/devel/lib/ikfast_lf_plugin_load_test/IKFast_leg_LF_loader] Error 1

make[1]: *** [ikfast_lf_plugin_load_test/CMakeFiles/IKFast_leg_LF_loader.dir/all] Error 2

make: *** [all] Error 2

Invoking "make -j2 -l2" failed

Here is my code I am using:

#include <pluginlib/class_loader.h>
#include "/opt/ros/jade/include/moveit/kinematics_base/kinematics_base.h"

int main(int argc, char** argv)
  // Create a classloader that is used to load the plugin
  pluginlib::ClassLoader<kinematics::KinematicsBase> poly_loader("moveit_core", "kinematics::KinematicsBase");

    boost::shared_ptr<kinematics::KinematicsBase> IKFast_LF = poly_loader.createInstance("ikfast_kinematics_plugin::IKFastKinematicsPluginLF");
    ROS_INFO("The plugin was loaded.");
  catch(pluginlib::PluginlibException& ex)
    ROS_ERROR("The plugin failed to load for some reason. Error: %s", ex.what());

  return 0;

I have also copied the functions from the auto-generated ikfast_moveit_plugin.cpp into a header file, that would take the place of polygon_plugins.h in the tutorial. Also from the tutorial, polygon_base.his replaced with kinematics_base.h from /opt/ros/jade/include/moveit/kinematics_base/kinematics_base.h.

Has anyone else come across this problem when trying to load a plugin?

Any help would be appreciated.

Link to catkin package

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-01-05 05:14:32 -0600

rbbg gravatar image

The undefined reference error suggests there is a problem with linking. You are including the correct header but you are not linking it.

If you change the following in your CMakeLists.txt

find_package(catkin REQUIRED COMPONENTS

and change the header to include

#include <moveit/kinematics_base/kinematics_base.h>

you should be all set. Changing the include ensures that your system will be able to find the right header, even if the location might move (or should you use another ros distro).

edit flag offensive delete link more

Question Tools



Asked: 2016-11-16 16:10:19 -0600

Seen: 575 times

Last updated: Jan 05 '17