having problems with subscribe when using boost::bind
here is my code
#include <ros/ros.h>
#include "costmap/costmap.h"
#include <sensor_msgs/LaserScan.h>
int main(int argc, char **argv) {
ros::init(argc, argv, "costmap");
ros::NodeHandle n;
costmap costmap_;
ros::Subscriber sub = n.subscribe<sensor_msgs::LaserScan::ConstPtr>("scan", 1000, boost::bind(&upDateMap, _1, costmap_));
ros::spin();
return 0;}
void upDateMap(const sensor_msgs::LaserScan::ConstPtr &msg, costmap &costmap_){}
and here is my costmap.h:
void upDateMap(const sensor_msgs::LaserScan::ConstPtr &msg, costmap &costmap_);
class costmap {};
costmap is a class defined by me.
When i run catkin_make,In file included from /home/mushen/catkin_ws/src/costmap/src/costmap.cpp:1:0:
/home/mushen/catkin_ws/src/costmap/include/costmap/costmap.h:14:61: error: ‘costmap’ has not been declared
comes out.
how could i solve this?
Is the
costmap
class actually declared in the.cpp
file that containsmain(..)
? If not, it could be that you're simply missing an#include
for the header that declarescostmap
.Isn't the issue that you're using
costmap
(the class) inupDateMap(..)
before it's actually declared incostmap.h
?Try swapping the declarations of
class costmap
andvoid upDateMap(..)
and recompile.This seems like a straightforward C++ issue to me, not a ROS or
boost::bind
one.