我ROS melodic
在Ubuntu 18.04
. 我rosbag
在后台运行一个来模拟消息中的相机rostopics
。我设置了相机名称rosparams
并对其进行迭代以捕获每个相机主题。我message_filter
ApproximateTimeSynchronizer
用来获取官方文档中提到的时间同步数据,
http://wiki.ros.org/message_filters
但大多数时候回调函数ApproximateTimeSynchronizer
没有被调用/延迟。我正在使用的代码片段如下:
我在这里做错了什么?
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()