坑1:没有在ros的subscribe的输入参数里写上这个类对应的指针,也就是this关键词。
Segmentator{
public:
void run(){
pub = nh2.advertise<sensor_msgs::PointCloud2>("/cloud_without_floor", 1000);
sub = nh.subscribe("/camera/stream/1/cloud", 1000, &Segmentator::chatterCallback);}
private:
void chatterCallback(const sensor_msgs::PointCloud2ConstPtr &msg){...}
报错:error: no matching function for call to 'ros::NodeHandle::subscribe(const char [23], int, void (Segmentator::*)(const PointCloud2ConstPtr&))'
sub = nh.subscribe("/camera/stream/1/cloud", 1000, &Segmentator::chatterCallback);
办法:sub = nh.subscribe("/camera/stream/1/cloud", 1000, &Segmentator::chatterCallback);} ->
sub = nh.subscribe("/camera/stream/1/cloud", 1000, &Segmentator::chatterCallback, this);}
坑