boost::bind with ros topic,ros中subscribe用boost::bind绑定多个参数

boost::bind with ros topic,ros中subscribe用boost::bind绑定多个参数

#include <unistd.h>

using  namespace std;
//打开ioNum
void callBack_io(const  disinfect_msg::disinfect_msg::ConstPtr & msg,SerialPort *serial){

    serial->sendWriteData(msg->ioId,msg->ioFlag);
    cout<<"msg.ioId: "<<msg->ioId<<" ---  msg.ioFlag: "<<msg->ioId<<endl;
}



int main(int argc, char **argv) {
    string nodeName = "serial_server";
    //创建节点
    ros::init(argc, argv, nodeName,ros::init_options::AnonymousName);
    ros::NodeHandle node;
    SerialPort serial;

    ros::Subscriber sub_io  =node.subscribe<disinfect_msg::disinfect_msg>("serialControlIo_node",5,boost::bind(&callBack_io, _1, &serial));

    update_func(serial);
   
    return 0;

}

上一篇:03 ubuntu下安装boost1.76


下一篇:Boost(3):将c++类封装成python类