Ask Your Question

How to use ApproximateTime in python

asked 2013-09-19 04:43:28 -0600

whiterose gravatar image

updated 2014-01-28 17:18:00 -0600

ngrennan gravatar image

Hi all,

I'm trying to synchronize (approximately since the stamps of the topics are different) 4 topics.

I have looked at the ApproximateTime example here:

But how to do it in python? I have looked at the Python API ( for message filters, but it says nothing about approximatetime.

Thanks in advance.

edit retag flag offensive close merge delete


one = message_filters.Subscriber('robot0/sonar_0', Range) two = message_filters.Subscriber('robot0/sonar_1', Range) ts = message_filters.ApproximateTimeSynchronizer([one, two],10,1) ts.registerCallback(callback)

Here 10 is the size of queue and 1 is the time in sec to consider for aprox

Ananthakrishnan gravatar image Ananthakrishnan  ( 2015-10-18 12:51:15 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-04-05 12:17:33 -0600

ApproximateTime was added for python in indigo, and is documented in the indigo version of the api docs.

edit flag offensive delete link more


It seems that this kind of subscriber cannot be unregistered, can you confirm?

Mehdi. gravatar image Mehdi.  ( 2018-12-03 06:37:19 -0600 )edit

answered 2017-11-25 17:04:39 -0600

jayess gravatar image

Just in case someone has some trouble getting going with this, here's an example:

from message_filters import ApproximateTimeSynchronizer, Subscriber

def gotimage(image, camerainfo):
    assert image.header.stamp == camerainfo.header.stamp
    print "got an Image and CameraInfo"

image_sub = Subscriber("/wide_stereo/left/image_rect_color", sensor_msgs.msg.Image)
camera_sub = Subscriber("/wide_stereo/left/camera_info", sensor_msgs.msg.CameraInfo)

ats = ApproximateTimeSynchronizer([image_sub, camera_sub], queue_size=5, slop=0.1))

I adapted this from the docs.

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

1 follower


Asked: 2013-09-19 04:43:28 -0600

Seen: 7,927 times

Last updated: Nov 25 '17