ROS 报错:error: invalid use of non-static member function

代码:

rs_camera_info_subscriber_ = nh.subscribe("camera/color/camera_info", 1, &ContinuousDetector::rsCameraInfoCallback);

error: invalid use of non-static member function
ubscriber_ = nh.subscribe(“camera/color/camera_info”, 1, ContinuousDetector::rsCameraInfoCallback);

原因:
subscriber 使用的回调函数(这里是ContinuousDetector::rsCameraInfoCallback)是类的成员函数,需要声明。

解决办法:
在回调函数名后面加一个参数:this
此处应该是:

rs_camera_info_subscriber_ = nh.subscribe("camera/color/camera_info", 1, &ContinuousDetector::rsCameraInfoCallback, this);

你可能感兴趣的:(ROS)