ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

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

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

usamamaq gravatar image

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

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));
    }
    a_server::~a_server()
    {
    .....
    }

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

And here is the header file:

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

        virtual void callback(const sensor_msgs::PointCloud2::ConstPtr& cl);
        protected:
            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 :

Error: 
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> > >&)’
BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS));

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

Comments

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 -0500 )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 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

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

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

Comments

so what was the problem exactly? I am having a similar problem, that I've described briefly here: https://stackoverflow.com/questions/6...

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

Question Tools

2 followers

Stats

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

Seen: 2,902 times

Last updated: Aug 22 '19