1.1 载入
ROS提供了解析 bag
的python API,载入一个 bag
文件可以:
import rosbag
bag_file = 'test.bag'
bag = rosbag.Bag(bag_file, "r")
1.2 读取信息
info = bag.get_type_and_topic_info()
print(info)
可以得到类似如下的信息:
TypesAndTopicsTuple(
msg_types={
'sensor_msgs/PointCloud2': '1158d486dd51d683ce2f1be655c3c181',
'sensor_msgs/CompressedImage': '8f7a12909da2c9d3332d540a0977563f'
},
topics={
'/pandora/sensor/pandora/hesai40/PointCloud2':
TopicTuple(
msg_type='sensor_msgs/PointCloud2',
message_count=1183,
connections=1,
frequency=10.071482170278314),
'/pa