【ROS笔记本】——Rosbag录制,回放数据

1.rosbag命令

2.rosbag简介

rosbag 既可以指命令行中数据包相关命令,也可以指 c++/python 的 rosbag 库。这里的 rosbag 是指前者。
rosbag 主要用于记录、回放、分析 rostopic 中的数据。它可以将指定 rostopic 中的数据记录到 .bag 后缀的数据包中,便于对其中的数据进行离线分析和处理。
对于 subscribe 某个 topic 的节点来说,它无法区分这个 topic 中的数据到底是实时获取的数据还是从 rosbag 中回放的数据。这就有助于我们基于离线数据快速重现曾经的实际场景,进行可重复、低成本的分析和调试。
3.rosbag  录制使用

rosbag record /topic_name    录制话题

rosbag record -b 4092 /topic_name   扩大录制内存限制

Record a bag file with the contents of specified topics.
 
Options:
  -h, --help            show this help message and exit
  -a, --all             record all topics
  -e, --regex           match topics using regular expressions
  -x EXCLUDE_REGEX, --exclude=EXCLUDE_REGEX
                        exclude topics matching the follow regular expression
                        (subtracts from -a or regex)
  -q, --quiet           suppress console output
  -o PREFIX, --output-prefix=PREFIX
                        prepend PREFIX to beginning of bag name (name will
                        always end with date stamp)
  -O NAME, --output-name=NAME
                        record to bag with name NAME.bag
  --split               split the bag when maximum size or duration is reached
  --max-splits=MAX_SPLITS
                        Keep a maximum of N bag files, when reaching the
                        maximum erase the oldest one to keep a constant number
                        of files.
  --size=SIZE           record a bag of maximum size SIZE MB. (Default:
                        infinite)
  --duration=DURATION    record a bag of maximum duration DURATION in seconds,
                        unless 'm', or 'h' is appended.
  -b SIZE, --buffsize=SIZE
                        use an internal buffer of SIZE MB (Default: 256, 0 =
                        infinite)
  --chunksize=SIZE      Advanced. Record to chunks of SIZE KB (Default: 768)
  -l NUM, --limit=NUM   only record NUM messages on each topic
  --node=NODE           record all topics subscribed to by a specific node
  -j, --bz2             use BZ2 compression
  --lz4                 use LZ4 compression
  --tcpnodelay          Use the TCP_NODELAY transport hint when subscribing to
                        topics.
  --udp                 Use the UDP transport hint when subscribing to topics.

rosbag record --all  录制全部话题

rosbag record -O (大写)录制包重命名

rosbag record -o (小写)为数据加前缀

4.rosbag 回放使用

rosbag info 查看话题名称、类型、消息数量

rosbag play name.bag 回放数据包

rosbag play -r 3 name.bag  3倍速回放,按一定频率回放,-r选项用来设定消息发布速率;

rosbag play name.bag -l 按一定频率回放,-l选项用来设定循环播放;

rosbag play name.bag --topic /topic1 只播放感兴趣的topic;

-d 用来指定延迟播放的时间(sec);

-s参数用来指定从几秒开始;rosbag play -s 10 xx.bag

-u 参数表示仅播放包的前几秒信息;rosbag play -u 10 xx.bag

-r 参数用来指定播放速度

-l 循环播放

猜你喜欢

转载自blog.csdn.net/weixin_51060040/article/details/123542463