bags
包通常是由一个像 rosbag 这样的工具创建的,该工具订阅一个或多个 ROS 主题,并将序列化的消息数据存储在接收到的文件中。
rosbag 工具包含一个发布模拟时钟的选项,该时钟对应于在文件中记录数据的时间。
离线使用
像 rqt _ bag 这样的工具允许您可视化袋文件中的数据,包括绘制字段和显示图像。您还可以使用 rostopic 命令从控制台快速检查袋文件数据。Rostopic 支持列表袋文件主题以及回音数据屏幕。Bag 文件格式存储相应消息数据的 msg 文件
- rosbag;
- rqt_bag;
- rostopic;
- Webviz;
rosbag comond-line
-
rosbag record
rosbag record topic-name
有规律的topic name
rosbag record -e “/(.)_stereo/(left|right)/image_rect_color"
记录所有含有 sensors的:
rosbag record -e "(.)sensors(.)"
当开始记录消息的时候,发布“begin_write”
rosbag record -p
排除与给定规律的表达式匹配的主题(从-a 或-e 减去)
rosbag record -e "/wide_stereo(.)” -x “(.)/points(.)”
指定记录袋文件的最大持续时间
$ rosbag record --duration=30 /chatter
$ rosbag record --duration=5m /chatter
$ rosbag record --duration=2h /chatter
Prepend PREFIX to beginning of bag name before date stamp,bag name 之前加上前缀
rosbag record -o session1 /chatter
记录名为XXX的bag文件中
rosbag record -O session2_090210.bag /chatter
Split the bag when maximum size or duration is reached 当达到最大尺寸或持续时间时分裂袋
$ rosbag record --split --size=1024 /chatter
$ rosbag record --split --duration=30 /chatter
$ rosbag record --split --duration=5m /chatter
$ rosbag record --split --duration=2h /chatter
-l NUM, --limit=NUM
Only record NUM messages on each topic. 只记录每个主题上的 NUM 消息
$ rosbag record -l 1000 /chatter
Record all topics subscribed to by a specific node 记录特定节点订阅的所有主题
$ rosbag record --node=/joy_teleop -
rosbag info
Display a summary of the contents of the bag files. 显示包文件内容的摘要
$ rosbag info session*.bag
Print information in YAML format.以 YAML 格式打印信息。
$ rosbag info -y /path/to/my.bag -
rosbag play
Rosbag play 读取一个或多个 bag 文件的内容,并以时间同步的方式回放它们。时间同步是根据接收消息的全局时间戳进行的。
Additionally, during playing, you can pause at any time by pressing space. When paused, you can step through messages by pressing s.
Play back (publish) the contents of the given bags. 回放(发布)给定袋子的内容
$ rosbag play recorded1.bag recorded2.bag
specify which topics to play back 指定播放哪些主题
$ rosbag play recorded1.bag --topics /topic1 /topic2 /topic3
… -
rosbag check
Determine whether or not a bag is playable in the current system. 确定一个包在当前系统中是否可以播放
$ rosbag check old.bag -
rosbag fix
-
rosbag filter
-
rosbag compress
Rosbag compress 是一个命令行工具,用来压缩袋子文件。 -
rosbag decompress
Rosbag 解压缩是一个用于解压缩袋文件的命令行工具。它自动确定袋子使用的压缩格式。 -
ronag reindex
Rosbag 重新索引是一个命令行工具,用于修复破损的袋文件(或记录在 ROS 版本0.11之前的袋文件)如果某个包由于任何原因没有清洁地关闭,则索引信息可能已损坏。使用此工具重新读取消息数据并重新生成索引。
更多参考
http://wiki.ros.org/rosbag/Commandline
rqt_bag
rqt_bag is an application for recording and managing bag files. Primary features:
Rqt _ bag 是一个用于记录和管理包文件的应用程序。主要特点:
show bag message contents 显示袋子里的信息
display image messages (optionally as thumbnails on a timeline)
显示图像消息(时间轴上的缩略图)
plot configurable time-series of message values
可配置的信息值时间序列
publish/record messages on selected topics to/from ROS
就选定的主题向/来自 ROS 发布/记录讯息
export messages in a time range to a new bag
将时间范围内的信息导出到新的包中
rqt_bag can be extended via a plugin mechanism. Core plugins are contained in the rqt_bag_plugins package available in the rqt_common_plugins metapackage.
- run
rqt_bag
主窗口显示一个时间线,表示按主题列出的 bag 文件中包含的消息流。
更多详细用法
http://wiki.ros.org/rqt_bag
Code API
http://wiki.ros.org/rosbag/Code%20API
这个页面包含一组代码片段,演示了如何使用 rosbag api。
http://wiki.ros.org/rosbag/Cookbook
更多参考
http://wiki.ros.org/ROS/Tutorials/reading%20msgs%20from%20a%20bag%20file
Reading messages from a bag file
从包文件夹中读取信息
Description: Learn two ways to read messages from desired topics in a bag file, including using the 学习两种从袋文件中所需主题中读取信息的方法,包括使用ros_readbagfile 文件 script. 脚本