当前位置:   article > 正文

在类里面实现ros的subscribe或message_filter的回调遇到的坑_no matching function for call to 鈥榬os::nodehandle:

no matching function for call to 鈥榬os::nodehandle::subscribe(const char [21

坑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);}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/813938
推荐阅读
相关标签
  

闽ICP备14008679号