Ask Your Question

TimeSynchronizer (boost invalid initialization of reference)

asked 2013-04-29 00:28:13 -0500

Waterplant gravatar image

updated 2013-04-29 00:29:07 -0500

I have again a problem building the boost TimeSynchronizer Callback. I hope you can help me :)

void callback (const ImageConstPtr& right, ImageConstPtr& left) {


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

    ros::NodeHandle nh;

    message_filters::Subscriber<Image> right_image(nh, "/stereo_camera/right/image_rect", 1);
    message_filters::Subscriber<Image> left_image(nh, "/stereo_camera/left/image_rect", 1);

    TimeSynchronizer<Image, Image> sync(right_image, left_image, 10);
    sync.registerCallback(boost::bind(&callback, _1, _2));

    ros::spin ();

    return 0;

The error msg:

error: invalid initialization of reference of type ‘boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&’ from expression of type ‘const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >’
edit retag flag offensive close merge delete


1.Did you add the required header files ? 2.Did you add boost libraries and linked them in the CMakeLists.txt?

sai gravatar image sai  ( 2013-11-09 17:34:38 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2013-11-25 21:28:03 -0500

timster gravatar image

updated 2013-11-25 21:28:33 -0500

Could it be that you are simply missing a const before ImageConstPtr& left in the arguments of your callback?



edit flag offensive delete link more

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: 2013-04-29 00:28:13 -0500

Seen: 947 times

Last updated: Nov 25 '13