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

catkin_make error on boost::bind during synchronizer callback

asked 2017-09-20 23:46:57 -0500

rosusernli gravatar image

updated 2022-02-07 15:52:01 -0500

130s gravatar image

I am getting an error related to boost when trying to time synchronize two images from topics. It is showing an error in the boost::bind function during callback which i am not sure how to correct it.


A portion of the build output is listed below:

/usr/include/boost/bind/mem_fn_template.hpp: In instantiation of ‘R boost::_mfi::mf2<R, T, A1, A2>::call(U&, const void*, B1&, B2&) const [with U = StereoGrabber (*)(); B1 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >; B2 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >; R = void; T = StereoGrabber; A1 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&; A2 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&]’:
/usr/include/boost/bind/mem_fn_template.hpp:286:46:   required from ‘R boost::_mfi::mf2<R, T, A1, A2>::operator()(U&, A1, A2) const [with U = StereoGrabber (*)(); R = void; T = StereoGrabber; A1 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&; A2 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&]’
/usr/include/boost/bind/bind.hpp:392:34:   required from ‘void boost::_bi::list3<A1, A2, A3>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = boost::_mfi::mf2<void, StereoGrabber, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&>; A = boost::_bi::list9<const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&, const boost::shared_ptr<const message_filters::NullType>&, const boost::shared_ptr<const message_filters::NullType>&, const boost::shared_ptr<const message_filters::NullType>&, const boost::shared_ptr<const message_filters::NullType>&, const boost::shared_ptr<const message_filters::NullType>&, const boost::shared_ptr<const message_filters::NullType>&, const boost::shared_ptr<const message_filters::NullType>&>; A1 = boost::_bi::value<StereoGrabber (*)()>; A2 = boost::arg<1>; A3 = boost::arg<2>]’
/usr/include/boost/bind/bind_template.hpp:305:59:   required from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F, L>::operator()(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&) [with A1 = boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >; A2 = boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >; A3 = boost::shared_ptr<const message_filters::NullType>; A4 = boost::shared_ptr<const message_filters::NullType>; A5 = boost::shared_ptr<const message_filters::NullType>; A6 = boost::shared_ptr<const message_filters::NullType>; A7 = boost::shared_ptr<const message_filters::NullType>; A8 = boost::shared_ptr<const message_filters::NullType>; A9 = boost::shared_ptr<const message_filters::NullType>; R = void; F = boost::_mfi::mf2<void, StereoGrabber, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&>; L = boost::_bi::list3<boost::_bi::value<StereoGrabber (*)()>, boost::arg<1>, boost::arg<2> >; boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/include/boost/bind/bind.hpp:827:34:   required from ‘void boost::_bi::list9<A1, A2, A3, A4, A5, A6, A7, A8, A9>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = boost::_bi::bind_t<void, boost::_mfi::mf2<void, StereoGrabber, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&>, boost::_bi::list3<boost::_bi::value<StereoGrabber (*)()>, boost::arg<1>, boost::arg<2> > >; A = boost::_bi::list9<const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&, const boost::shared_ptr<const message_filters::NullType>&, const boost::shared_ptr<const message_filters::NullType>&, const ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2017-09-21 07:09:13 -0500

rosusernli gravatar image

Found out the mistake while building. I didn't notice it first.

The Problem was with the class object declaration.

StereoGrabber sgb();

The class constructor doesn't take any arguments. It should have been : StereoGrabber sgb;

The updated code for time synchronizer is :

class StereoGrabber
{
public:
    StereoGrabber(){};

    void GrabImage(const sensor_msgs::ImageConstPtr& msgImage1,const sensor_msgs::ImageConstPtr& msgImage2);
};

int main(int argc, char **argv)
{
    ros::init(argc, argv, "listener");
    ros::start();

    StereoGrabber sgb; //Corrected code

    ros::NodeHandle nVO;

    message_filters::Subscriber<sensor_msgs::Image> image1_sub(nVO, "/image_1", 1);
    message_filters::Subscriber<sensor_msgs::Image> image2_sub(nVO, "/image_2", 1);
    typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image> sync_pol1;
    message_filters::Synchronizer<sync_pol1> sync1(sync_pol1(10), image1_sub,image2_sub);
    sync1.registerCallback(boost::bind(&StereoGrabber::GrabImage,&sgb,_1,_2));

    ros::spin();

    ros::shutdown();

    return 0;
}

void StereoGrabber::GrabImage(const sensor_msgs::ImageConstPtr& msgImage1,const sensor_msgs::ImageConstPtr& msgImage2)
{
    //Process image

}
edit flag offensive delete link more

Comments

Why you make a class without individual class constructor? In your case, actually a main-scheme ros implementation is more proper. Because you declare ros stuff in main function and second your callback actually could just declared as a function out of main() without class definition.

waschbaer00 gravatar image waschbaer00  ( 2018-03-23 08:55:01 -0500 )edit

Yes the function can be declared without class definition. I wrote the class implementation for readability and possibility of future expansion of code. Its always better to implement as a member function.

rosusernli gravatar image rosusernli  ( 2018-03-27 06:54:37 -0500 )edit
0

answered 2018-03-23 08:40:00 -0500

waschbaer00 gravatar image

Thanks for sharing, by me it is I forgot "this" argument in the registercallback().

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-09-20 23:46:57 -0500

Seen: 824 times

Last updated: Feb 07 '22