ROS使用教程--关于rosbag

原文:https://blog.csdn.net/wendox/article/details/52373488 

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.

1 $ 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

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

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

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

refer
https://zhenshenglee.github.io/2016/08/16/160816ROS-Bag%E4%BB%8B%E7%BB%8D/
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

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

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

1 cd ~
2 mkdir test
3 mv ~/.ros/frame*.jpg test/
4 
5 cd ~/test
6 mencoder "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 未测试.

posted on 2019-06-13 10:23  Feyn  阅读(1164)  评论(0编辑  收藏  举报

导航