简体   繁体   中英

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

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. If you need/wish to bind to a reference, use boost::ref(vs)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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