Error while running nodelet: cannot load library, undefined symbol
I am trying to create a nodelet out of an existing node with the header file gridmapping_nodelet.h given as
#ifndef GRIDMAPIING_NODELET_H
#define GRIDMAPIING_NODELET_H
#include <gridmapping/gridprocess.h>
#include <missiondata/dem.h>
#include <ros/ros.h>
#include <nodelet/nodelet.h>
//namespace TX
//{
namespace gridmapping_nodelet
{
class gridmapping : public nodelet::Nodelet
{
public:
gridmapping(){};
virtual void onInit();
~gridmapping();
private:
ros::NodeHandle * n;
double maxrange;
double cellsize;
int gridsize;
TX::GridProcess* process;
//subcribe to pose and lidar data
ros::Subscriber pose;
ros::Subscriber points;
ros::Subscriber points2;
ros::Subscriber stereo;
//set publish frequency
ros::Timer obst_publish_timer;
ros::Timer marker_publish_timer;
};
};
//};
#endif
and gridmapping_nodelet.cpp file is as follows
#include <gridmapping_nodelet/gridmapping_nodelet.h>
#include <pluginlib/class_list_macros.h>
// watch the capitalization carefully
PLUGINLIB_DECLARE_CLASS(gridmapping_nodelet, gridmappingn,gridmapping_nodelet::gridmapping, nodelet::Nodelet)
using namespace gridmapping_nodelet;
void gridmapping_nodelet::gridmapping::onInit()
{
*n = getNodeHandle();
n->getParam("/gridmapping/maxrange", maxrange);
n->getParam("/gridmapping/cellsize", cellsize);
gridsize = (6*maxrange)/cellsize;
//this does the publishing and data processing
process = new TX::GridProcess(*n, cellsize, maxrange, gridsize);
//process = new TX::GridProcess(*n, 20, 400, 100);
//subcribe to pose and lidar data
pose = n->subscribe("/gridmapping/pose",0, & TX::GridProcess::updatePose, process);
points = n->subscribe("/gridmapping/cloud", 5,& TX::GridProcess::updateGrid, process);
points2 = n->subscribe("/gridmapping/cloud2", 5,& TX::GridProcess::updateGrid2, process);
stereo = n->subscribe("/gridmapping/stereocloud", 5, & TX::GridProcess::updateGridStereo, process);
//set publish frequency
obst_publish_timer = n->createTimer(ros::Duration(0.25), &TX::GridProcess::publishObstacles, process);
marker_publish_timer = n->createTimer(ros::Duration(0.25), &TX::GridProcess::publishMarkers, process);
}
nodelet_plugins.xml is given by
<library path="lib/libgridmapping">
<class name="gridmapping_nodelet/gridmappingn" type="gridmapping_nodelet::gridmapping" base_class_type="nodelet::Nodelet">
<description>
This is gridmapping nodelet.
</description>
</class>
</library>
CMakeLists.txt
rosbuild_add_library(gridmapping src/gridmapping_nodelet.cpp)
manifest.xml
<export>
<cpp cflags="-I${prefix}/include" lflags="-L${prefix}/lib -lgridmapping" />
<nodelet plugin="${prefix}/nodelet_plugins.xml" />
</export>
launch file
<launch>
<node pkg="nodelet" type="nodelet" name="standalone_nodelet" args="manager" output="screen"/>
<node pkg="nodelet" type="nodelet" name="gridmapping" args="load gridmapping_nodelet/gridmappingn standalone_nodelet" output="screen">
</node>
</launch>
The parameters are defined in a separate launch file which calls on the launch file mentioned above.
The ouput error is as follows
[ERROR] [1323458052.686296083]: Failed to load nodelet [/gridmapping] of type [gridmapping_nodelet/gridmappingn]: Failed to load library /home/aeroscout/ros/tx_stacks/tx_perception/gridmapping_nodelet/lib/libgridmapping.so. Make sure that you are calling the PLUGINLIB_REGISTER_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Cannot load library: /home/aeroscout/ros/tx_stacks/tx_perception/gridmapping_nodelet/lib/libgridmapping.so: undefined symbol: _ZN2TX11GridProcess11updateGrid2ERKN5boost10shared_ptrIKN11sensor_msgs12PointCloud2_ISaIvEEEEE
Any help is greatly appreciated
EDIT 1
Alright the library issue is resolved, thanks to Tully! But now I am facing md5sum errors, I have checked all my packages for consistency in terms in messages(by rebuilding them after clean) and the node I am converting to nodelet runs just fine. Since I don't change message types during conversion, I was surprised to see this error in the log file after my nodelet crashed -
[roscpp_internal] [2011-12-15 16:26:31,390] [thread 0x7f6100734760]: [DEBUG] UDPROS server listening on port ...