最近我正在用类方法编写ROS代码,并希望使用相同的回调函数订阅不同的主题。但是,它没有用。
错误 /usr/include/boost/bind/bind.hpp:75:错误:'void(InterFace :: *)(const boost :: shared_ptr>>&,std :: __ cxx11 :: basic_string&)'不是类,结构或联合类型 typedef typename F :: result_type type;
void Parameterfun(const cars::MotionConstPtr, std::string &names)
{if (names== "velocity")
ROS_INFO("velocity");}
ROS::Subscribe sub_1 = n.subscribe("/velocity", 100,boost::bind(&InterFace::Parameterfun, _1, &names_1));
ROS::Subscribe sub_2 = n.subscribe("/acceleration", 100, boost::bind(&InterFace::Parameterfun, _1, &names_2));
因为两个主题使用相同的回调函数,所以我想知道我从主题速度中获得了哪些数据以及从加速度中获得了哪些数据。