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

What is exact sync message filter?

asked 2021-09-27 00:19:09 -0500

shankk gravatar image

I am writing a ROS node for a stereo camera. It publishes sensor_msgs::Image objects to two topics, one for left camera and another for right camera. The subsequent node uses ExactSync synchronizer to subscribe to the published topics. I assume it is for making sure all the published images have the same timestamp. But this is just the guess. Can someone here help me understand what an ExactSync message filter is?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-09-27 01:03:38 -0500

janindu gravatar image

Publishers and subscribers in ROS are agnostic to each other. So

I assume it is for making sure all the published images have the same timestamp.

No. In ROS, what you do on the subscriber's end will have no effect on what (and how) the publisher does.

Here is the message_filter wiki page. A message filter is defined as something which a message arrives into and may or may not be spit back out of at a later point in time.

What the ExactSync message filter does is that it will only spit out messages with the exact timestamp. If they are few nanoseconds different, they will not be identified as a matching pair. To quote the documentation,

The message_filters::sync_policies::ExactTime policy requires messages to have exactly the same timestamp in order to match. Your callback is only called if a message has been received on all specified channels with the same exact timestamp. The timestamp is read from the header field of all messages (which is required for this policy).

Therefore this subscriber will only work if your publisher explicitly synchronizes the left and right images using the timestamps. That is something you have to implement on your publisher node. If the left and right images are not explicitly synchronized, but you want to logically synchronize them based on the timestamp on the subscriber node, perhaps you can use the Approximate Time Policy instead.

edit flag offensive delete link more


Okay. I understand this better now. Since I have a while loop which publishes image messages for both cameras in each iteration, I think the appropriate thing to do is to explicitly set the same value for the header timestamp of both. I think the reason why we use the ExactTime policy is to make sure that the left image from one capture does not erroneously get matched with the right image from another capture instance. Right?

shankk gravatar image shankk  ( 2021-09-27 01:26:43 -0500 )edit

Yes, that should work if you explicitly set the same timestamp to both image messages.

janindu gravatar image janindu  ( 2021-09-27 01:29:35 -0500 )edit

Question Tools



Asked: 2021-09-27 00:19:09 -0500

Seen: 283 times

Last updated: Sep 27 '21