ROS使用教程--关于rosbag

来源:互联网 发布:mac office行高 编辑:程序博客网 时间:2024/04/28 13:01

overview

rosbag package提供了一个命令行工具以及cpp类和python的API. rosbag使用命令行能够:录制,从包重新发布,获取包的概括信息,检查包的消息类型,使用Python表达式过滤包中信息,压缩解压缩包,重新索引包
命令行工具

This is the current list of supported commands:
- record. Record a bag file with the contents of specified topics.

$ rosbag record rosout tf cmd_vel
  • info. Summarize the contents of a bag file.
  • play. Play back the contents of one or more bag files.
  • check. Determine whether a bag is playable in the current system, or if it can be migrated.
  • fix. Repair the messages in a bag file so that it can be played in the current system.
  • filter. Convert a bag file using Python expressions.
  • compress. Compress one or more bag files.
  • decompress. Decompress one or more bag files.
  • reindex. Reindex one or more broken bag files.

如果记录一个高带宽的信息,例如图像信息,最好是在同一个相机节点运行的机器上记录,并指定文件的目的地所属的机器的硬盘
可以使用regex, 指令是-e, -regex

$ rosbag record -e "/(.*)_stereo/(left|right)/image_rect_color"

rosbage info

该工具将保存的bag文件显示出来,包含起止时间,toppics以及其类型,信息数量等.

rqt_bag

提供全方位的图形化界面,具有录制,播放,显示,保存,加载文件,暂停等功能

refer

  1. https://zhenshenglee.github.io/2016/08/16/160816ROS-Bag%E4%BB%8B%E7%BB%8D/
  2. http://chenjunjun.bitbucket.org/2016/03/22/ROS-%E6%B6%88%E6%81%AF%E5%BD%95%E5%88%B6%E5%92%8C%E5%9B%9E%E6%94%BE/

rosbag文件中提取视频

方法1

[refer ros wiki page]http://wiki.ros.org/rosbag/Tutorials/Exporting%20image%20and%20video%20data#CA-b03834a5a0917593e18fb84cfab917fbab79f52a_1

<launch>  <node pkg="rosbag" type="play" name="rosbag" args="-d 2 $(find image_view)/test.bag"/>  <node name="extract" pkg="image_view" type="extract_images" respawn="false" output="screen" cwd="ROS_HOME">    <remap from="image" to="/camera/image_raw"/>  </node></launch>

$(find image_view)/test.bag在使用的时候换成自己的bag文件的路径,然后生成一些文件,文件名统一格式为’frame%04d.jpg’,位置在.ros文件中.因此执行一下命令,移动文件,并录制成视频.

cd ~mkdir testmv ~/.ros/frame*.jpg test/cd ~/testmencoder "mf://*.jpg" -mf type=jpg:fps=15 -o output.mpg -speed 1 -ofps 30 -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=2500 -oac copy -of mpeg

方法2

https://github.com/OSUrobotics/bag2video 未测试.

0 0
原创粉丝点击