ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Rospy message_filter ApproximateTimeSynchronizer issue

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

Ajith gravatar image

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

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 -0500

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

Question Tools

1 follower

Stats

Asked: 2019-08-31 22:45:35 -0500

Seen: 658 times

Last updated: Sep 04 '19