ROS:subscribe函数无法识别我的回调方法



我收到此错误"错误:调用‘ros::NodeHandle::subscribe(const char [24], int, <unresolved overloaded function type>)’ 没有匹配函数

这是我在班上BangBangControlUnit 的回调函数

// on message reciept: 'current_maintained_temp' void current_maintained_temp_callback(const std_msgs::Int32::ConstPtr& msg){ temp_to_maintain = msg->data;
}

这就是我在主要功能中使用订阅的方式

// subscribe to 'current_maintained_temp' ros::Subscriber current_maintained_temp_sub = n.subscribe("current_maintained_temp", 1000, control.current_maintained_temp_callback);

有人能告诉我我做错了什么吗?

用类方法作为回调创建订阅者的正确签名如下:

ros::Subscriber sub = nh.subscribe("my_topic", 1, &Foo::callback, &foo_object);

因此,在您的情况下,您应该使用:

current_maintained_temp_sub = n.subscribe("current_maintained_temp", 1000, &BangBangControlUnit::current_maintained_temp_callback, &control);

你可以在这里阅读更多关于C++发行商和订阅者的信息。

最新更新