message_filters doesn't call the callback function
I'm trying to use the message_filters in order to subscribe to two topics. Here's my code
class sync_listener:
def __init__(self):
self.image_sub = message_filters.Subscriber('camera/rgb/image_color', Image)
self.info_sub = message_filters.Subscriber('camera/rgb/camera_info', CameraInfo)
self.ts = message_filters.TimeSynchronizer([self.image_sub, self.info_sub], 10)
self.ts.registerCallback(self.callback)
def callback(self, image, camera_info):
print("done")
def main(args):
ls = sync_listener()
rospy.init_node('sample_message_filters', anonymous=True)
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
if __name__ == '__main__':
main(sys.argv)
But it never goes to the callback function. It just freezes. I found a similar question here Rospy problem with time synchronizer message filter but there was no answer.