Ask Your Question
0

Rospy message_filter ApproximateTimeSynchronizer issue

asked 2019-08-31 22:45:35 -0600

Ajith gravatar image

updated 2019-08-31 22:55:08 -0600

Hi All,

I installed ROS melodic version in Ubuntu 18.04. I'm running a rosbag in the background to mock cameras in messages rostopics. I set the camera names in rosparams and iterated through it to capture each camera topics. I'm using message_filter ApproximateTimeSynchronizerto get time synchronized data as mentioned in the official documentation, http://wiki.ros.org/message_filters

But most of the time the callback function to ApproximateTimeSynchronizer is not being called/is having too much delay. The code snippet I'm using is given below:

def  camera_callback(*args):
    pass # Other logic comes here
rospy.init_node('my_listener', anonymous=True) 
camera_object_data = []
for camera_name in rospy.get_param('/my/cameras'):
    camera_object_data.append(message_filters.Subscriber(
        '/{}/hd/camera_info'.format(camera_name), CameraInfo))
    camera_object_data.append(message_filters.Subscriber(
        '/{}/hd/image_color_rect'.format(camera_name), Image))
    camera_object_data.append(message_filters.Subscriber(
        '/{}/qhd/image_depth_rect'.format(camera_name), Image))
    camera_object_data.append(message_filters.Subscriber(
        '/{}/qhd/points'.format(camera_name), PointCloud2)
 topic_list = [filter_obj for filter_obj in camera_object_data]
 ts = message_filters.ApproximateTimeSynchronizer(topic_list, 10, 1,  allow_headerless=True)
 ts.registerCallback(camera_callback)
 rospy.spin()

What am I doing wrong here?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-09-04 07:07:15 -0600

Choco93 gravatar image

You can try increasing the slop value as defined here, and just for sanity check maybe check what is the actual time difference in the headers of your topics.

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: 2019-08-31 22:45:35 -0600

Seen: 50 times

Last updated: Sep 04