Recording and playing back data

This tutorial will teach you how to record data from a running ROS system into a .bag file, and then to play back the data to produce similar behavior in a running system.

rostopic list -v

//This should yield the following output:
Published topics:
* /turtle1/color_sensor [turtlesim/Color] 1 publisher
* /turtle1/cmd_vel [geometry_msgs/Twist] 1 publisher
* /rosout [rosgraph_msgs/Log] 2 publishers
* /rosout_agg [rosgraph_msgs/Log] 1 publisher
* /turtle1/pose [turtlesim/Pose] 1 publisher Subscribed topics:
* /turtle1/cmd_vel [geometry_msgs/Twist] 1 subscriber
* /rosout [rosgraph_msgs/Log] 1 subscriber

只有topic list中列出的类型的msg才可以被record到data log file。

The list of published topics are the only message types that could potentially be recorded in the data log file, as only published messages are recorded.

rosbag用法如下:

suchang@suchang-virtual-machine:~/bagfiles$ rosbag
Usage: rosbag <subcommand> [options] [args] A bag is a file format in ROS for storing ROS message data. The rosbag command can record, replay and manipulate bags. Available subcommands:
check Determine whether a bag is playable in the current system, or if it can be migrated.
compress Compress one or more bag files.
decompress Decompress one or more bag files.
decrypt Decrypt one or more bag files.
encrypt Encrypt one or more bag files.
filter Filter the contents of the bag.
fix Repair the messages in a bag file so that it can be played in the current system.
help
info Summarize the contents of one or more bag files.
play Play back the contents of one or more bag files in a time-synchronized fashion.
record Record a bag file with the contents of specified topics.
reindex Reindexes one or more bag files. For additional information, see http://wiki.ros.org/rosbag

在真的发送bag file中记录的msg之前会等待0.2s,以防止前几个msg丢失.

In its default mode rosbag play will wait for a certain period (.2 seconds) after advertising each message before it actually begins publishing the contents of the bag file. Waiting for some duration allows any subscriber of a message to be alerted that the message has been advertised and that messages may follow. If rosbag play publishes messages immediately upon advertising, subscribers may not receive the first several published messages. The waiting period can be specified with the -d option.

rosbag play可以不从bag file的开始播放,可以用-s 指定从距离文件初始记录时间xx秒开始.

rosbag play -r 2 ./2019-03-25-13-48-22.bag

-r 参数指定播放倍速.

在一个复杂系统里,可能有成百上千个topic,我们不可能记录所有topic上的msg.

// -O means output.生成一个subset.bag文件.  只记录/turtle1/cmd_vel /turtle1/pose这两个topic上的msg.
rosbag record -O subset /turtle1/cmd_vel /turtle1/pose

rosbag record/play的局限

rosbag很难精确地复制一个running systerm中的行为,因为rosrecord记录的msg的时间很难做到足够精确,比方说系统1s的时候发了msg1,2s的时候发了msg2,rosbag记录到的时候可能已经是1.01s和2.02s,这样的话就差出了0.01s,在play back的时候可能就会产生微小误差.

In the previous section you may have noted that the turtle's path may not have exactly mapped to the original keyboard input - the rough shape should have been the same, but the turtle may not have exactly tracked the same path. The reason for this is that the path tracked by turtlesim is very sensitive to small changes in timing in the system, and rosbag is limited in its ability to exactly duplicate the behavior of a running system in terms of when messages are recorded and processed by rosrecord, and when messages are produced and processed when using rosplay. For nodes like turtlesim, where minor timing changes in when command messages are processed can subtly alter behavior, the user should not expect perfectly mimicked behavior.

Recording and playing back data的更多相关文章

  1. Learning ROS: Recording and playing back data

    本文主要部分来源于ROS官网的Tutorials. Description: This tutorial will teach you how to record data from a runnin ...

  2. 论文笔记之:Playing for Data: Ground Truth from Computer Games

    Playing for Data: Ground Truth from Computer Games ECCV 2016 Project Page:http://download.visinf.tu- ...

  3. ROS教程

    Learning ROS 学习ROS Depending on your learning style and preferences, you can take two approaches to ...

  4. 一篇对iOS音频比较完善的文章

    转自:http://www.cnblogs.com/iOS-mt/p/4268532.html 感谢作者:梦想通 前言 从事音乐相关的app开发也已经有一段时日了,在这过程中app的播放器几经修改我也 ...

  5. IOS 音频播放

    iOS音频播放 (一):概述 前言 从事音乐相关的app开发也已经有一段时日了,在这过程中app的播放器几经修改我也因此对于iOS下的音频播放实现有了一定的研究.写这个系列的博客目的一方面希望能够抛砖 ...

  6. iOS苹果官方Demo合集

    Mirror of Apple’s iOS samples This repository mirrors Apple’s iOS samples. Name Topic Framework Desc ...

  7. android录音功能的实现

    这个录音实现是我在Bus上看到并下载的,他那个源码不完整,再次把我整理完整的代码贴出,源码地址在这:http://download.csdn.net/detail/chaozhung/5618649 ...

  8. 通过WinAPI播放PCM声音

    在Windows平台上,播放PCM声音使用的API通常有如下两种. waveOut and waveIn:传统的音频MMEAPI,也是使用的最多的 xAudio2:C++/COM API,主要针对游戏 ...

  9. 小程序-demo:小程序示例-page/api

    ylbtech-小程序-demo:小程序示例-page/api 以下将演示小程序接口能力,具体属性参数详见小程序开发文档. 1. page/component返回顶部 1. a) .js Page({ ...

随机推荐

  1. js、jq事件绑定方式总结——以click事件为例

    一.JavaScript点击事件绑定方法 1.1 HTML onclick事件属性 <button onclick="clickMe(this)">click me&l ...

  2. window10 hello 人脸识别无法启动相机的问题

    win10设置人脸识别的时候无法打开相机.但是在qq,其他软件中可以调用相机,可以打开相机的时候.windows hello 就是打不开,不知道怎么回事. 尝试打开电源选项,有一个   选项,还原一下 ...

  3. 百度推出 MIP Baidu Path链接

    在站长将站点 MIP 化时,需要关注 URL 的一共有三个:MIP URL, MIP-Cache URL 以及 MIP Baidu Path. 从 URL 说起 在互联网中,URL 定义页面的地址,每 ...

  4. 微服务架构 - SpringBoot整合Jooq和Flyway

    在一次学习分布式跟踪系统zipkin中,发现了jooq这个组件,当时不知这个组件是干嘛的,后来抽空学习了一下,感觉这个组件还挺用的.它主要有以下作用: 通过DSL(Domain Specific La ...

  5. react源码总览(翻译)

    用react也有段时间了, 是时候看看人家源码了. 看源码之前看到官方文档 有这么篇文章介绍其代码结构了, 为了看源码能顺利些, 遂决定将其翻译来看看, 小弟英语也是半瓢水, 好多单词得查词典, 不当 ...

  6. 一段简单的显示当前页面FPS的代码

    写前端代码,尤其是做一个前端框架的时候,经常需要及时知道代码的大致性能,这时候如果能有个好的办法能一直看到当前页面的fps就好了. 整体思路是一秒有一千毫秒,先记录当前时间作为最后一次记录fps的时间 ...

  7. Gradle入门到实战(二) — ImageOptimization安卓图片转换压缩插件

    上一篇我们了解了Gradle的各个方面,本篇介绍一款安卓图片优化转换插件,目前已在项目中使用,可一键批量转换压缩图片,webp转换与png/jpg压缩就是那么简单 GitHub项目地址:ImageOp ...

  8. 第一周Python学习笔记

    Python 基本语法: ①  Python程序的格式:1.用代码高亮来标识函数丶语句等等 本身的代码高亮并没有实际的意义,只是用来辅助编程人员和阅读人员 更好的识别 2.程序以缩进来标识语句,缩进用 ...

  9. 搭建属于自己的GIT服务器——pingg

    1.下载并安装jdk. 下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htm ...

  10. PHP全栈学习笔记9

    php的会话控制,什么是会话控制,http等. 什么是会话控制思想,http协议. cookie 和 session http是超文本传输协议,是网络上最广泛的一种网络协议. http最大特点是无连接 ...