Robotics StackExchange | Archived questions

ROS message filter

I have two topics and I want to synchronize them. So, I have used the message filter but it not entering in the callback. The two topics are different and coming at different rate. So kindly help me with the solution.

Asked by shoaibazam on 2019-09-24 01:34:31 UTC

Comments

I would suggest you show some code and provide more information on the message types and application setup.

Without that, I doubt many members here would be able to help you -- we don't have crystal balls.

Asked by gvdhoorn on 2019-09-24 02:31:12 UTC

yes sure. Actually I am subscribing the two topics. One is from camera running at 10Hz and one is gps data running at 100 Hz and I want to fuse their information or to sync them so that for every gps position i have respective image.

Asked by shoaibazam on 2019-09-24 03:40:58 UTC

Since you're claiming that:

I have used the message filter but it not entering in the callback

we're going to need to see said code. Note: we don't need all code. But seeing the callbacks and how you setup the message_filter classes would help.

And examples of the messages that are published on those topics. You can use rostopic echo -n1 --noarr /name/of/topic and copy-paste the output into your question.

Asked by gvdhoorn on 2019-09-24 04:21:36 UTC

Answers

You could use ApproximateTimeSynchronizer for this, but with topics that have such different frequencies you may be better off having two separate callbacks and storing a reference to the most recent data in one of the callbacks, and letting the second callback use the stored data along with its new message.

I'd probably perform the processing in the image callback only, using the most recent (stored) GPS position, since that's going to have the smallest average position error from the image capture position.

If you want to use message_filters, you'll need to use the approximate time policy, since the messages won't have exactly matching timestamps. See https://docs.ros.org/api/message_filters/html/python/#message_filters.ApproximateTimeSynchronizer (Python) or https://wiki.ros.org/message_filters#ApproximateTime_Policy (C++).

Asked by Mark Rose on 2019-10-03 12:17:00 UTC

Comments