Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python message_filter ApproximateTimeSynchronizer issue

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 ApproximateTimeSynchronizer to 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 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?

Python message_filter ApproximateTimeSynchronizer issue

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 ApproximateTimeSynchronizer to 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 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?

Python Rospy message_filter ApproximateTimeSynchronizer issue

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 ApproximateTimeSynchronizer to 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?