How to invoke a subscriber's callback periodically?
Hello everyone,
I would like to sample messages from my sensors' topics every 15 seconds (mostly) synchronically, using message_filters.ApproximateTimeSynchronizer. Is that any possible way to register a callback, that will be invoked, for example, every 15 seconds? I've already check out rospy.Timer, but it seems to be not an appropriate way in my case.
My basic code:
def callback(sensor1, sensor2):
#write messages into csv
def listener():
sensor0 = message_filters.Subscriber("/sensor0/topic", Int32)
sensor1 = message_filters.Subscriber("/sensor1/topic", Int32)
ts = message_filters.ApproximateTimeSynchronizer([sensor0,sensor1], 10, 0.1)
ts.registerCallback(callback)
rospy.spin()