首先看一下教程:

http://wiki.ros.org/openni_launch/Tutorials/BagRecordingPlayback

知道了rosbag如何进行使用记录深度数据

但是按照以上教程记录下来的bag file还是很大

于是看了别人写的launch file

摘抄自spencer_people_tracking

<!-- Launch file for playing bagfiles recorded with the SPENCER robot platform -->
<launch>
<!-- CONFIGURABLE ARGUMENTS -->
<arg name="files" default=""/>
<arg name="folder" default=""/> <arg name="urdf" default="false"/>
<arg name="remap_tf" default="true" if="$(arg urdf)"/>
<arg name="remap_tf" default="false" unless="$(arg urdf)"/> <arg name="depth" default="true"/>
<arg name="no_point_clouds" default="false" />
<arg name="front_rgbd" default="true"/>
<arg name="rear_rgbd" default="true"/>
<arg name="laser" default="true"/>
<arg name="uncompress_rgbd" default="true"/>
<arg name="tracked_persons" default="true"/>
<arg name="velodyne" default="false"/> <!-- Playback options -->
<arg name="rqt" default="false"/>
<arg name="pause" default="true"/>
<arg name="initial_wait_time" default="0.0" if="$(arg pause)"/>
<arg name="initial_wait_time" default="45.0" unless="$(arg pause)"/>
<arg name="loop" default="false"/>
<arg name="start" default="0.0"/> <!-- seconds into the bagfile at which to start playing -->
<arg name="duration" default="99999999.9"/> <!-- number of seconds to play -->
<arg name="rate" default="1.0"/> <!-- playback speed -->
<arg name="required" default="true" /> <!-- Visualization options -->
<arg name="visualization" default="true" /> <!-- whether to run RViz with provided config, or not -->
<arg name="panoramas" default="false"/>
<arg name="relay_rgbd_for_visualization" default="true"/>
<arg name="rviz_config_file" default="$(find spencer_bagfile_tools)/launch/components/visualization_robot.rviz"/> <!-- configuration file for RViz to use, if visualization is enabled --> <arg name="rosbag_play_args" default="--clock --queue=5 --delay=0 --start=$(arg start) --duration=$(arg duration) --rate=$(arg rate)" /> <!-- extra arguments used to play back the bagfile --> <!-- Important: Use simulated time published on /clock topic, otherwise TF will be broken -->
<param name="/use_sim_time" value="true"/> <!-- BAG FILE PLAYBACK -->
<group>
<remap from="/tf" to="/spencer/sensors/tf_in_bagfile" if="$(arg remap_tf)"/>
<remap from="/spencer/sensors/clock" to="/clock"/> <remap from="/spencer/perception/tracked_persons" to="/spencer/perception/tracked_persons_in_bagfile" unless="$(arg tracked_persons)"/>
<remap from="/spencer/perception/detected_persons" to="/spencer/perception/detected_persons_in_bagfile" unless="$(arg tracked_persons)"/> <!-- Uncompress RGB-D images -->
<remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_front_top/depth/image_raw/compressedDepth" to="/spencer/sensors/rgbd_front_top/depth_recorded/image_raw/compressedDepth"/>
<remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_front_top/rgb/image_raw/compressed" to="/spencer/sensors/rgbd_front_top/rgb_recorded/image_color/compressed"/> <remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_front_bottom/depth/image_raw/compressedDepth" to="/spencer/sensors/rgbd_front_bottom/depth_recorded/image_raw/compressedDepth"/>
<remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_front_bottom/rgb/image_raw/compressed" to="/spencer/sensors/rgbd_front_bottom/rgb_recorded/image_color/compressed"/> <remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_rear_top/depth/image_raw/compressedDepth" to="/spencer/sensors/rgbd_rear_top/depth_recorded/image_raw/compressedDepth"/>
<remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_rear_top/rgb/image_raw/compressed" to="/spencer/sensors/rgbd_rear_top/rgb_recorded/image_color/compressed"/> <remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_rear_bottom/depth/image_raw/compressedDepth" to="/spencer/sensors/rgbd_rear_bottom/depth_recorded/image_raw/compressedDepth"/>
<remap if="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_rear_bottom/rgb/image_raw/compressed" to="/spencer/sensors/rgbd_rear_bottom/rgb_recorded/image_color/compressed"/> <!-- Hack if uncompressed depth/image_rect was recorded instead of depth/image_raw as recommended at http://wiki.ros.org/openni_launch/Tutorials/BagRecordingPlayback -->
<remap unless="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_front_top/depth/image_rect" to="/spencer/sensors/rgbd_front_top/depth/image_raw"/>
<remap unless="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_front_bottom/depth/image_rect" to="/spencer/sensors/rgbd_front_bottom/depth/image_raw"/> <remap unless="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_rear_top/depth/image_rect" to="/spencer/sensors/rgbd_rear_top/depth/image_raw"/>
<remap unless="$(arg uncompress_rgbd)" from="/spencer/sensors/rgbd_rear_bottom/depth/image_rect" to="/spencer/sensors/rgbd_rear_bottom/depth/image_raw"/> <!-- This script launches either rosbag play or rqt_bag, and searches for all relevant bag files for the active sensor modalities in the given folder -->
<node name="playback_wrapper" pkg="spencer_bagfile_tools" type="play.py" output="screen" required="$(arg required)" ns="/spencer/sensors" clear_params="true"> <!-- sub-namespace only applied for relative topic names in bagfile -->
<!-- Either give a list of files... -->
<param name="files" value="$(arg files)"/> <!-- Or an entire folder containing bagfiles prefixed with laser_, front_rgbd_, etc. -->
<param name="folder" value="$(arg folder)"/>
<param name="laser" value="$(arg laser)"/>
<param name="front_rgbd" value="$(arg front_rgbd)"/>
<param name="rear_rgbd" value="$(arg rear_rgbd)"/> <param name="rqt" value="$(arg rqt)"/>
<param name="pause" value="$(arg pause)"/>
<param name="loop" value="$(arg loop)"/>
<param name="rosbag_play_args" value="$(arg rosbag_play_args)"/>
<param name="initial_wait_time" value="$(arg initial_wait_time)"/>
</node>
</group> <!-- TF EXCLUSIONS -->
<group if="$(arg remap_tf)">
<remap from="tf_old" to="/spencer/sensors/tf_in_bagfile"/>
<node name="tf_filter" pkg="spencer_bagfile_tools" type="tf_filter.py" args="_exclude:='[]'"/>
</group> <!-- RGB-D PROCESSING -->
<group if="$(arg depth)">
<!-- Uncompress RGB-D -->
<group if="$(arg uncompress_rgbd)">
<include file="$(find spencer_bagfile_tools)/launch/components/uncompress_rgbd.launch">
<arg name="sensor_name" value="rgbd_front_top"/>
</include>
<include file="$(find spencer_bagfile_tools)/launch/components/uncompress_rgbd.launch">
<arg name="sensor_name" value="rgbd_front_bottom"/>
</include>
<include file="$(find spencer_bagfile_tools)/launch/components/uncompress_rgbd.launch">
<arg name="sensor_name" value="rgbd_rear_top"/>
</include>
<include file="$(find spencer_bagfile_tools)/launch/components/uncompress_rgbd.launch">
<arg name="sensor_name" value="rgbd_rear_bottom"/>
</include>
</group> <!-- Generate point clouds -->
<group unless="$(arg no_point_clouds)" ns="/spencer/sensors/">
<!-- Front sensors -->
<group if="$(arg front_rgbd)">
<include file="$(find spencer_bagfile_tools)/launch/components/generate_pointcloud.launch">
<arg name="sensor_name" value="rgbd_front_top"/>
</include>
<include file="$(find spencer_bagfile_tools)/launch/components/generate_pointcloud.launch">
<arg name="sensor_name" value="rgbd_front_bottom"/>
</include>
</group> <!-- Rear sensors -->
<group if="$(arg rear_rgbd)">
<include file="$(find spencer_bagfile_tools)/launch/components/generate_pointcloud.launch">
<arg name="sensor_name" value="rgbd_rear_top"/>
</include>
<include file="$(find spencer_bagfile_tools)/launch/components/generate_pointcloud.launch">
<arg name="sensor_name" value="rgbd_rear_bottom"/>
</include>
</group>
</group>
</group> <!-- Relay original RGB-D images to throttled visualization topics (for playback, we don't need compression and throttling) -->
<group if="$(arg relay_rgbd_for_visualization)" ns="relay_rgbd_for_visualization">
<node pkg="nodelet" type="nodelet" name="manager" args="manager" output="screen"/> <include file="$(find spencer_bagfile_tools)/launch/components/relay_rgbd_for_visualization.launch">
<arg name="camera" value="rgbd_front_top"/>
</include> <include file="$(find spencer_bagfile_tools)/launch/components/relay_rgbd_for_visualization.launch">
<arg name="camera" value="rgbd_front_bottom"/>
</include> <include file="$(find spencer_bagfile_tools)/launch/components/relay_rgbd_for_visualization.launch">
<arg name="camera" value="rgbd_rear_top"/>
</include> <include file="$(find spencer_bagfile_tools)/launch/components/relay_rgbd_for_visualization.launch">
<arg name="camera" value="rgbd_rear_bottom"/>
</include>
</group> <!-- Create RGB and depth panoramas for visualization -->
<group if="$(arg panoramas)" ns="/spencer/sensors">
<node if="$(arg front_rgbd)" name="panorama_rgb_front" pkg="spencer_bagfile_tools" type="panorama_builder" args="_topics:='/spencer/sensors/rgbd_front_top/rgb /spencer/sensors/rgbd_front_bottom/rgb' _inplane_rotations:='0.0 180.0' _vertical:=true _output_topic:='/spencer/sensors/rgbd_front_panorama/rgb'"/> <node if="$(arg rear_rgbd)" name="panorama_rgb_rear" pkg="spencer_bagfile_tools" type="panorama_builder" args="_topics:='/spencer/sensors/rgbd_rear_top/rgb /spencer/sensors/rgbd_rear_bottom/rgb' _inplane_rotations:='0.0 180.0' _vertical:=true _output_topic:='/spencer/sensors/rgbd_rear_panorama/rgb'"/> <group if="$(arg depth)">
<node if="$(arg front_rgbd)" name="panorama_depth_front" pkg="spencer_bagfile_tools" type="panorama_builder" args="_topics:='/spencer/sensors/rgbd_front_top/depth /spencer/sensors/rgbd_front_bottom/depth' _inplane_rotations:='0.0 180.0' _vertical:=true _output_topic:='/spencer/sensors/rgbd_front_panorama/depth'"/> <node if="$(arg rear_rgbd)" name="panorama_depth_rear" pkg="spencer_bagfile_tools" type="panorama_builder" args="_topics:='/spencer/sensors/rgbd_rear_top/depth /spencer/sensors/rgbd_rear_bottom/depth' _inplane_rotations:='0.0 180.0' _vertical:=true _output_topic:='/spencer/sensors/rgbd_rear_panorama/depth'"/>
</group>
</group> <!-- VELODYNE POINT CLOUD GENERATION -->
<group if="$(arg velodyne)">
<include file="$(find velodyne_pointcloud)/launch/VLP16_points.launch"/>
</group> <!-- ROBOT URDF -->
<group if="$(arg urdf)">
<include file="$(find spencer_description)/launch/publish.launch"/>
</group> <!-- VISUALIZATION -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_config_file)" required="false" if="$(arg visualization)"/> </launch>

可以看到解压缩,rosbag info 以下别人的bag file

topics:

/spencer/sensors/rgbd_front_top/depth/camera_info 720 msgs : sensor_msgs/CameraInfo
/spencer/sensors/rgbd_front_top/depth/image_raw/compressedDepth 720 msgs : sensor_msgs/CompressedImage
/spencer/sensors/rgbd_front_top/rgb/camera_info 691 msgs : sensor_msgs/CameraInfo
/spencer/sensors/rgbd_front_top/rgb/image_raw/compressed 691 msgs : sensor_msgs/CompressedImage

发现记录的都是压缩格式的深度图,和彩色图

于是需要解压缩

别人的uncompress_rgbd.launch

<launch>
<arg name="sensor_name"/> <group ns="/spencer/sensors/$(arg sensor_name)">
     <!--注意这里是base topic就是说这个base topic下的所有topic都会被变换-->
<node name="republish_rgb" pkg="image_transport" type="republish" args="compressed in:=rgb_recorded/image_color raw out:=rgb/image_raw"/>
<node name="republish_depth" pkg="image_transport" type="republish" args="compressedDepth in:=depth_recorded/image_raw raw out:=depth/image_raw"/>
</group> </launch>

发现用到了image_transport

于是去看

http://wiki.ros.org/image_transport

http://wiki.ros.org/image_transport_plugins

下面是本文采用的launch file,使用compressed imge节省了空间

在弄这个launch file 的时候出了错误,rosbag记录正确,但是image_view就是没有图像,问题在于remap出错了,应该放在node里,或者放在rosbag node前面

<launch>
<!-- Important: Use simulated time published on /clock topic, otherwise TF will be broken -->
<param name="/use_sim_time" value="true"/>
<node pkg="rosbag" type="play" name="rosbag" args="--clock --queue=5 --delay=0 --start=0 --duration=99999999 --rate=1 --loop $(find vision_obstacles_avoidance)/bags/xtion.bag">
<remap from="/vision_obstacles_avoidance/xtion/depth_registered/image_raw/compressedDepth" to="/vision_obstacles_avoidance/xtion/depth_registered_recorded/image_raw/compressedDepth"/>
<remap from="/vision_obstacles_avoidance/xtion/rgb/image_raw/compressed" to="/vision_obstacles_avoidance/xtion/rgb_recorded/image_color/compressed"/>
</node>
<!--注意这里是base topic就是说这个base topic下的所有topic都会被变换-->
<group ns="/vision_obstacles_avoidance/xtion">
<node name="republish_rgb" pkg="image_transport" type="republish" args="compressed in:=rgb_recorded/image_color raw out:=rgb/image_raw"/>
<node name="republish_depth" pkg="image_transport" type="republish" args="compressedDepth in:=depth_registered_recorded/image_raw raw out:=depth_registered/image_raw"/>
</group>
</launch>

 

rosbag record --duration=15  /vision_obstacles_avoidance/xtion/depth_registered/image_raw/compressedDepth /vision_obstacles_avoidance/xtion/depth_registered/camera_info /vision_obstacles_avoidance/xtion/rgb/image_raw/compressed /vision_obstacles_avoidance/xtion/rgb/camera_info -O xtion

rosbag record --duration=15 /vision_obstacles_avoidance/xtion/depth/image_raw/compressedDepth /vision_obstacles_avoidance/xtion/depth/camera_info /vision_obstacles_avoidance/xtion/rgb/image_raw/compressed /vision_obstacles_avoidance/xtion/rgb/camera_info -O xtion

 

rosbag使用--记录深度相机数据的更多相关文章

  1. 【计算机视觉】深度相机(一)--TOF总结

    http://www.voidcn.com/blog/lg1259156776/article/p-6302915.html 1.1 TOF初探 TOF是Time of flight的简写,直译为飞行 ...

  2. 【计算机视觉】深度相机(九)--OpenNI API及中间件说明

    本文由官方文档翻译而来 总览 目的 OpenNI 2.0 API(应用程序编程接口)提供了访问PrimerSense的兼容深度传感器.这就使得一个应用程序能够初始化传感器和从设备接收深度(depth) ...

  3. 【计算机视觉】深度相机(四)--Realsense概览

    本文参考下文,做一点个人使用补充. http://blog.csdn.net/app_12062011/article/details/52662143 转自: http://blog.csdn. ...

  4. 深度学习数据特征提取:ICCV2019论文解析

    深度学习数据特征提取:ICCV2019论文解析 Goal-Driven Sequential Data Abstraction 论文链接: http://openaccess.thecvf.com/c ...

  5. [Unity3D]深度相机 Depth Camera

    作为3D世界里最重要的窗口,摄像机的应用就显得很重要,毕竟在屏幕上看到的一切都得用摄像机矩阵变换得来的嘛.论坛上看到了一篇帖子讲非天空盒的背景做法,让我想起其实很多界面合成画面可以用摄像机之间的交互来 ...

  6. Atitit.并发测试解决方案(2) -----获取随机数据库记录 随机抽取数据 随机排序 原理and实现

    Atitit.并发测试解决方案(2) -----获取随机数据库记录 随机抽取数据 随机排序 1. 应用场景 1 2. 随机抽取数据原理 1 3. 常用的实现方法:::数据库随机函数 1 4. Mssq ...

  7. Entity Framework入门教程(17)---记录和拦截数据库命令

    记录和拦截数据库命令 这一节介绍EF6怎么记录和拦截发送给数据库的查询和操作命令. 1.记录EF发送给数据库命令(DbContext.Database.Log) 以前给了查看EF发送给数据库的命令我们 ...

  8. ROS与深度相机入门教程-在ROS使用kinect v1摄像头

    ROS与深度相机入门教程-在ROS使用kinect v1摄像头 说明: 介绍在ros安装和使用kinect v1摄像头 介绍freenect包 安装驱动 deb安装 $ sudo apt-get in ...

  9. ASP.NET Web API 记录请求响应数据到日志的一个方法

    原文:http://blog.bossma.cn/dotnet/asp-net-web-api-log-request-response/ ASP.NET Web API 记录请求响应数据到日志的一个 ...

随机推荐

  1. js中迭代元素特性与DOM中的DocumentFragment类型 笔记

    JS中迭代元素特性 在需要将DOM结构序列化为XML或者HTML字符串时,多数都会涉及遍历元素的特性,这个时候attributes属性就可以派上用场. 以下代码展示了如何迭代元素的每一个特性,然后将他 ...

  2. springboot ueditor 使用心得

    1.将ueditor引入项目中会发现,图片不能上传,返回值意思是因配置文件错误,导致图片无法上传 默认情况是使用jsp初始配置文件,这就需要项目支持jsp解析 在maven中引入 <!--添加对 ...

  3. JAXB使用方式

    JAXB(Java Architecture for XML Binding) 是一个业界的标准,是一项可以根据XML Schema产生Java类的技术.该过程中,JAXB也提供了将XML实例文档反向 ...

  4. JVM GC Q&A(补充ing)

    1.如果一个对象没有与其相连的GC ROOT,一定会被回收吗? 这个对象并非是非死不可的,这时他只是处于死缓阶段,要真正宣告一个对象的死亡,至少要经历两次标记过程:如果对象在进行可达性分析后发现并没有 ...

  5. [POJ1784]Huffman's Greed

    题面在这里 题意 给出一棵\(n\)个节点的二叉查找树的中序遍历中每个节点的访问次数\(p[i]\),和相邻两节点\(i\)和\(i+1\)的访问次数\(q[i]\),构造一棵二叉查找树使得\(\su ...

  6. 【BZOJ 1409】 Password 数论(扩展欧拉+矩阵快速幂+快速幂)

    读了一下题就会很愉快的发现,这个数列是关于p的幂次的斐波那契数列,很愉快,然后就很愉快的发现可以矩阵快速幂一波,然后再一看数据范围就......然后由于上帝与集合对我的正确启示,我就发现这个东西可以用 ...

  7. POJ2236:Wireless Network(并查集)

    Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 39772   Accepted: 164 ...

  8. bzoj5091 [Lydsy1711月赛]摘苹果 概率题

    [Lydsy1711月赛]摘苹果 Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 174  Solved: 135[Submit][Status][Dis ...

  9. hive 动态分区(Dynamic Partition)异常处理

    Changing Hive Dynamic Partition Limits Symptoms: Hive enforces limits on the number of dynamic parti ...

  10. scrapy 为每个pipeline配置spider

    在settings.py里面配置pipeline,这里的配置的pipeline会作用于所有的spider,我们可以为每一个spider配置不同的pipeline, 设置 Spider 的 custom ...