Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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 = m_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.

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

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 = m_nh.subscribe<geometry_msgs::Point>("/y", 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.