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

Multiple subscribed topics in one callback

asked 2014-03-04 20:42:53 -0500

jpo gravatar image

updated 2014-03-04 20:54:32 -0500

Hi, I'm new to ROS and PCL as well so please excuse my trivial question.

I need to process a PointCloud topic and CameraInfo topic (project the cloud using the camera info). What is the best way to do that? I can see that I cannot have multiple topics as arguments in one callback, I found I can use the function "bind" but I am not sure if it is the right way for me...

Thanks in advance, jp

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2014-03-04 21:18:08 -0500

ahendrix gravatar image

In general, if you want to synchronize the input from two topics and process them in the same callback, you can use the message_filters time synchronizer API.

If you're looking specifically to receive a camera_info message and use the data in it for processing a camera image, it may be better to subscribe to the two topics separately and just save the most recent CameraInfo for use when processing images. This relaxes the timing requirements pretty significantly and means you don't have to run a complex synchronization filter.

You may also find the documentation on the CameraInfo message useful.

For typical uses you should be able to extract XYZ from a structured RGB Point cloud without resorting to CameraInfo.

edit flag offensive delete link more

Comments

Somehow the rospy version of this API does not seem does not seem to be working. The execution never really reaches the callback function (based on the example they have shown there). I wanted it for synchronizing odometry and laser scan messages. But well, I am going to look for a different solution than trying to make this work, or else this could have been a separate question on its own.

shrini96 gravatar image shrini96  ( 2023-05-23 15:23:58 -0500 )edit

So just for anyone else having the same problem, the solution is to use message_filters.ApproximateTimeSynchronizer instead of the tutorial suggestedmessage_filters.TimeSynchronizer. I got this idea from this SE post.

shrini96 gravatar image shrini96  ( 2023-06-04 03:13:11 -0500 )edit
1

answered 2014-03-04 21:19:40 -0500

davinci gravatar image

You can use a message filter to synchronize the topics. But the camera info usually doesn't change much so you can also set this information once.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2014-03-04 20:42:53 -0500

Seen: 9,193 times

Last updated: Mar 04 '14