参考网址:

(59条消息) Rosbag详细操作_Sun的博客-CSDN博客

rosbag –clock_newbeixue的博客-CSDN博客

Rosbag基础使用

保存

1
2
3
4
5
6
7
8
# 保存所有topic
rosbag record -a
# 只记录某些感兴趣的 topic
rosbag record /topic_name1 /topic_name2 /topic_name3
# 指定生成数据包的名字,则用-O /-o 参数
rosbag record -O filename.bag /topic_name1
# launch 文件中使用 rosbag record 命令
<node pkg="rosbag" type="record" name="bag_record" args="/topic1 /topic2"/>

显示信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
rosbag info filename.bag
rosbag info -y filename.bag
# 示例
xiaohu@xiaohu:~/bagfiles$ rosbag info -y 1.bag
path: 1.bag
version: 2.0
duration: 3.295966
start: 1566653873.351150
end: 1566653876.647117
size: 8103
messages: 20
indexed: True
compression: none
types:
- type: geometry_msgs/Twist
md5: 9f195f881246fdfa2798d1d3eebca84a
topics:
- topic: /turtle1/cmd_vel
type: geometry_msgs/Twist
messages: 20

rosbag play

1
2
3
4
5
6
7
8
9
10
11
# 简单播放
rosbag play <bagfile>
# -r 2 表示2倍速播放
rosbag play -r 2 <bagfile>
# 循环播放
rosbag play -l <bagfile> # -l== --loop
# 只播放一部分topic
rosbag play <bagfile> --topic /topic1
# 开始播放立刻暂停,按空格继续
rosbag play --pause record.bag

rosbag –clock

1
2
3
4
5
6
rosbag play --clock recorded1.bag
# -k, --keep-alive
rosbag play -k --clock recorded1.bag
# -r FACTOR, --rate=FACTOR
# 将发布频率降低为原来的10%,留给滤波节点足够的时间进行处理。
rosbag play -r 0.1 --clock recorded1.bag

常用命令

1
2
rosparam set /use_sim_time true
rosbag play --pause --clock -k scan_odom.bag --topic /topic1