Load plugin for IKFast class using C++
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");
try
{
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.h
is 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.