main function doesn't find functions of my class: ROS or c++ error?
hello everyone
I wrote my class structure in a header file (stage_listener.h):
#ifndef sl_H #define sl_H #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 "list" #include "vector" #include "scan_node.h" #include "odom_node.h" #include "coord.h" class stage_listener{ public: stage_listener(){}; int numOdom(); int numScan(); private: std::list<odom_node> odom_list; std::list<scan_node> scan_list; std::list<coord> corners_list; std::list<coord> polar2cart(std::vector<float>, float, float, float, float); void addOdomNode (const nav_msgs::Odometry); void addScanNode (const sensor_msgs::LaserScan); void extractCorners(std::vector<float>, float, float, float, float); int distance (float, float, float, float, float); void nodes2text(std::vector<odom_node>, std::vector<scan_node>); }; #endif
Then I wrote its associated .cpp file (stage_listener.cpp):
#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 "odom_node.h" #include "scan_node.h" #include "tf/transform_listener.h" #include "list" #include "vector" #include "coord.h" #include "math.h" #include "stdlib.h" #include "iterator" #include "string" stage_listener::stage_listener(){} int stage_listener::numOdom(){ return (int)(odom_list.size()); } int stage_listener::numScan(){ return (int)(scan_list.size()); } void stage_listener::addOdomNode (const nav_msgs::Odometry mes){ geometry_msgs::Pose robot_pose = mes.pose.pose; geometry_msgs::Point robot_point = robot_pose.position; odom_node *on = new odom_node(); (*on).xCoord = robot_point.x; (*on).yCoord = robot_point.y; (*on).frame_id = mes.header.frame_id; double orientation = tf::getYaw(robot_pose.orientation); (*on).angle = (float)orientation; odom_list.push_back(*on); } std::list<coord> stage_listener::polar2cart(std::vector<float> v, float a_min, float a_inc, float range_min, float range_max){ std::list<coord> lc; for(int i=0; i<(int)v.size(); i++){ if(v[i]>= range_min && v[i]<=range_max){ coord *c = new coord(); (*c).x = v[i]*cos(a_min + a_inc*i); (*c).y = v[i]*sin(a_min + a_inc*i); lc.push_back(*c); } } return lc; } void stage_listener::addScanNode (const sensor_msgs::LaserScan mes){ scan_node *sn = new scan_node(); (*sn).scan = mes.ranges; (*sn).frame_id = mes.header.frame_id; (*sn).cartesian = polar2cart(mes.ranges, mes.angle_min, mes.angle_increment, mes.range_min, mes.range_max); scan_list.push_back(*sn); } int distance (float a, float b, float c, float x0, float y0){ return abs(a*x0 + b*y0 + c)/sqrt(pow(a,2) + pow(b,2)); } void extractCorners(std::list<coord> points, float d_max, std::list<coord> dest){ if(points.size() == 1){ coord *corner = new coord(); (*corner).x = points.front().x; (*corner).y = points.front().y; dest.push_back(*corner); } else if(points.size() == 2){ coord *corner_a = new coord(); coord *corner_b = new coord(); (*corner_a).x = points.front().x; (*corner_a).y = points.front().y; (*corner_b).x = points.back().x; (*corner_b).y = points.back().y; dest.push_back(*corner_a); dest.push_back(*corner_b); } else{ std::list<coord>::iterator i = points.end(); float x1 = points.front().x; float y1 = points.front().y; float x2 = (*i).x; float y2 = (*i).y; float a = y1-y2; float b = x2-x1; float c = y1*(x1-x2) + x1*(y2-y1); int max = 0; int ref = 0; int count = points.size()-2; i--; while(i!=points.begin()){ coord temp = (*i); int ...