1.截取
(1)按照时间截取
rosbag filter 原始包名.bag 截取后的包名.bag "t.to_sec() > 开始时间 and t.to_sec() < 结束时间"
for example
rosbag filter lidar_zed4.bag lidar_zed4_filter.bag "t.to_sec() > 1641196460.608130 and t.to_sec() < 1641196485.7"
注意:时间是Bag Time,可以在回放rosbag包的时候看到。
(2)按照时间和多个topic进行截取
rosbag filter input.bag output.bag "(topic == '/velodyne_point_cloud' or topic =='/visensor/imu' or topic == '/visensor/left/image_raw') and (t.to_sec() >= 1506117983.884751 and t.to_sec() <= 1506118069.884751)"
2.bag转为txt
rostopic echo -b bagfiles_name.bag /topic_name > txt_name.txt