Ask Your Question
4

How to use ApproximateTime in python

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

whiterose gravatar image

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

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: http://answers.ros.org/question/60903/timesynchronizer-callback-problem/

But how to do it in python? I have looked at the Python API (http://docs.ros.org/api/message_filters/html/python/) for message filters, but it says nothing about approximatetime.

Thanks in advance.

edit retag flag offensive close merge delete

Comments

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 imageAnanthakrishnan ( 2015-10-18 12:51:15 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
3

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

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

edit flag offensive delete link more

Comments

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

Mehdi. gravatar imageMehdi. ( 2018-12-03 06:37:19 -0500 )edit
1

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

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))
ats.registerCallback(gotimage)

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

Stats

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

Seen: 5,641 times

Last updated: Nov 25 '17