Ask Your Question

Error: No match for call to 'boost::…'

asked 2019-08-22 08:36:29 -0600

usamamaq gravatar image

updated 2019-08-22 09:36:47 -0600

I am trying to modify another code. Just wanted to add another subscriber to it. This is the skeleton of the code:

namespace my_server
    a_server::a_server(ros::NodeHandle n)
    : nh()
        ros::NodeHandle n(n_);
        sub1 = new message_filters::Subscriber<sensor_msgs::PointCloud2> (nh(), "/x", 5);
        sub2 = new tf::MessageFilter<sensor_msgs::PointCloud2> (*sub1, sub3, xyz, 5);
        sub2->registerCallback(boost::bind(&a_server::callback, this, _1));

    void a_server::callback(const sensor_msgs::PointCloud2::ConstPtr& cl)

And here is the header file:

namespace my_server
    class a_server
        a_server(ros::NodeHandle n_ = ros::NodeHandle("~"));
        virtual ~a_server();

        virtual void callback(const sensor_msgs::PointCloud2::ConstPtr& cl);
            ros::NodeHandle n;
            message_filters::Subscriber<sensor_msgs::PointCloud2>* sub1;
            tf::MessageFilter<sensor_msgs::PointCloud2>* sub2;
            tf::TransformListener sub3;

Now I want to add another subscriber to it. Do not need to bind it with previous subscriber. I am doing it by adding this line after previous subscribers.

ros::Subscriber  sub4 = nh.subscribe<geometry_msgs::Point>("/y", 1, &a_server::callback2);

And added a callback function after void a_server::callback:

void a_server::callback2(geometry_msgs::Point &a)

And this to header file under protected: void callback2(geometry_msgs::Point &a);

This is the error that i am getting :

no match for call to ‘(boost::_mfi::mf1<void, my_server::a_server, geometry_msgs::Point_<std::allocator<void> >&>) (const boost::shared_ptr<const geometry_msgs::Point_<std::allocator<void> > >&)’

I understand this has something to do with boost::bind usage in previous subscribers. But I don't want to change them. Just need to add another subscriber whose callback function will update a global variable that will in return be used by previous callback function.

edit retag flag offensive close merge delete


ros::Subscriber  sub4 = m_nh.subscribe<geometry_msgs::Point>("/y", 1, &a_server::callback2);

I believe the prototype is "topic name, callback, queue size".

gvdhoorn gravatar image gvdhoorn  ( 2019-08-22 09:28:13 -0600 )edit

Sorry i didn't get it. Isn't this the syntax "topic name, queue size, callback" for node.subscriber like in ROS tutorial:

ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
usamamaq gravatar image usamamaq  ( 2019-08-22 09:44:44 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-08-22 10:48:04 -0600

usamamaq gravatar image

So after loosing precious 6 hours. This is how it is solved. Subscriber was added like this:

ros::Subscriber sub4 = nh.subscribe<geometry_msgs::Point>("/y", 1, boost::bind(&a_server::callback2, this, _1));

Callback function was written like this:

void a_server::callback2(const geometry_msgs::Point::ConstPtr& a)

Header file was added with this under Public:

void callback2(const geometry_msgs::Point::ConstPtr& a);
edit flag offensive delete link more


so what was the problem exactly? I am having a similar problem, that I've described briefly here:

azerila gravatar image azerila  ( 2020-06-12 08:51:20 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-08-22 08:36:29 -0600

Seen: 898 times

Last updated: Aug 22 '19