rosbag使用--記錄深度相機數據
首先看一下教程:
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
rosbag使用--記錄深度相機數據