简体   繁体   English

ROS中的订户错误

[英]Subscriber error in ROS

This is my subscriber declaration followed by the callback function 这是我的订户声明,后跟回调函数

 message_filters::Subscriber<geometry_msgs::Point32>
point_sub(*nh, "tracked_point", 1);
    point_sub.registerCallback(&visualservoing3D::pointCallback);

The callback declaration is 回调声明是

void
visualservoing3D::pointCallback(const geometry_msgs::Point32ConstPtr& msg) 
{
    //Some functions 
}

But the following error pops up. 但是会弹出以下错误。 I know its something to do with my subscriber. 我知道这与我的订户有关。

/usr/include/boost/function/function_template.hpp:225:
error: no match for call to
‘(boost::_mfi::mf1<void,
visualservoing3D, const
boost::shared_ptr<const
geometry_msgs::Point32_<std::allocator<void>
> >&>) (const boost::shared_ptr<const geometry_msgs::Point32_<std::allocator<void>
>&)’

Thanks, 谢谢,

Nagsaver Nagsaver

point_sub.registerCallback(&visualservoing3D::pointCallback);

You need to bind the non-static member function to an object instance: 您需要将非静态成员函数绑定到对象实例:

#include <boost/bind.hpp>

point_sub.registerCallback(boost::bind(&visualservoing3D::pointCallback, p_vs, _1));

Where p_vs is a (shared) pointer to a visualservoing3D object. 其中p_vs是指向visualservoing3D对象的(共享)指针。 If you need/wish to bind to a reference, use boost::ref(vs) 如果您需要/希望绑定到参考,请使用boost::ref(vs)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM