Undefined reference error while constructing a list of nodes
Hello everyone I need to construct a list of odometric and laser measurement. For this purpose, I first wrote a .h file:
#include "ros/ros.h" #include "nav_msgs/Odometry.h" #include "geometry_msgs/Pose.h" #include "geometry_msgs/Point.h" #include "stdio.h" #include "sensor_msgs/LaserScan.h" class odom_node{ public: odom_node(); ~odom_node(); float xCoord; float yCoord; float angle; std::string frame_id; odom_node *next; }; class scan_node{ public: scan_node(); float scan[]; std::string frame_id; scan_node *next; }; class stage_listener{ public: stage_listener(); private: odom_node odom_graph; scan_node scan_list; void addOdomNode (const nav_msgs::Odometry); };
Then, in an associated .cpp file, I started defining the body of class stage_listener:
#include "ros/ros.h" #include "nav_msgs/Odometry.h" #include "geometry_msgs/Pose.h" #include "geometry_msgs/Point.h" #include "stdio.h" #include "sensor_msgs/LaserScan.h" #include "stage_listener.h" #include "tf/transform_listener.h" void addOdomNode (const nav_msgs::Odometry mes){ geometry_msgs::Pose robot_pose = mes.pose.pose; geometry_msgs::Point robot_point = robot_pose.position; //float xCoord = robot_point.x; //float yCoord = robot_point.y; //float zCoord = robot_point.z; odom_node on; //on.xCoord = robot_point.x; //double orientation = tf::getYaw(robot_pose.orientation); } int main(){}
Anyway, for what regads line
odom_node on;
I get the following error, after digiting make, once inside my ros package:
CMakeFiles/stage_listener.dir/src/stage_listener.o: In function `addOdomNode(nav_msgs::Odometry_<std::allocator<void> >)': /home/ubisum/fuerte_workspace/beginner/src/stage_listener.cpp:18: undefined reference to `odom_node::odom_node()' /home/ubisum/fuerte_workspace/beginner/src/stage_listener.cpp:18: undefined reference to `odom_node::~odom_node()'
Does anyone know the reason? I'm sorry if question may seem too silly, but I'm learning C++ and ROS at the once and it's not easy when coming from Java and MatLab.
Thanks for help
How did you link .h and .cpp file?
how can i make ROS compiler see my header files? using rosbuild_add_executable(example examples/example.cpp) seems uncorrect, since my cpp file associated to the header have no main can i use any of the expression in CMakeLists just to make .h headers visible?