Ask Your Question
1

boost::bind with image_msg

asked 2012-05-11 22:45:58 -0600

Fred99 gravatar image

updated 2012-05-12 14:41:18 -0600

Eric Perko gravatar image

Hi, I'm trying to write code to take two image messages called /stereocam/left/image_raw, and /stereocam/right/image_raw, each from two different cameras. I want to combine them to both into one image, however I can't figure out how to set up one callback function to determine which camera the particular image came from. I tried this, but it won't compile.

image_transport::Subscriber sub1 = it.subscribe<sensor_msgs::image> ("/stereocam/left/image_raw", 1, boost::bind(imageCallback, _1, 1)); image_transport::Subscriber sub2 = it.subscribe<sensor_msgs::image> ("/stereocam/right/image_raw", 1, boost::bind(imageCallback, _1,2));

and

void imageCallback(const sensor_msgs::ImageConstPtr& msg, int queue_id) { }

I tried a variation of this using just ROS instead of image_transport and it compiles just fine, but this doesn't.

Any help would be greatly appreciated.

edit retag flag offensive close merge delete

Comments

Offhand, it's sensor_msgs::Image, with a capital I. Can you post your complete code, or at least the smallest snippet that doesn't compile?

Mac gravatar imageMac ( 2012-05-12 07:52:03 -0600 )edit

image_transport::Subscriber sub = it.subscribe<sensor_msgs::Image>("/stereocam/left/image_raw", 1, boost::bind(imageCallback, _1, 1));

That is the part that it says doesn't have a matching function call.

Fred99 gravatar imageFred99 ( 2012-05-12 09:30:48 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-05-12 14:49:10 -0600

Eric Perko gravatar image

You need to remove the template parameter for the subscribe call. According to the image_transport api docs, the version of it.subscribe that accepts a boost::function object for the callback is not templated.

edit flag offensive delete link more

Comments

1

Thank you! It compiles now. Much appreciated :)

Fred99 gravatar imageFred99 ( 2012-05-12 16:09:17 -0600 )edit

Please use the checkmark to mark this answer as "accepted" if it solved your issue. That way, the next person to have this problem can easily find the solution. Thanks for helping to keep ROS Answers organized and easy to use!

Eric Perko gravatar imageEric Perko ( 2012-05-12 16:39:06 -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

1 follower

Stats

Asked: 2012-05-11 22:45:58 -0600

Seen: 622 times

Last updated: May 12 '12