# Cannot record sensor data using rosbag from kinect

Hi, I tried to record the data from Kinect by using rosbag record -a after I opened the openni_node driver for Kinect.

wei@wei-Aspire-4810T:~/ros/bagfiles$roslaunch openni_camera openni_node.launch  Then in another terminal I used rosbag trying to record all topics: wei@wei-Aspire-4810T:~/ros/bagfiles$ rosbag record -a
[ INFO] [1330246493.151671247]: Recording to 2012-02-26-16-54-53.bag.
[ INFO] [1330246494.158586547]: Subscribing to /camera/depth/image
[ INFO] [1330246494.163723907]: Subscribing to /camera/rgb/image_raw
[ INFO] [1330246494.167274829]: Subscribing to /camera/rgb/image_mono/compressed
[ INFO] [1330246494.169913071]: Subscribing to /camera/rgb/image_mono/compressed/parameter_updates
[ INFO] [1330246494.180194984]: Subscribing to /camera/depth/image/theora
[ INFO] [1330246494.185385283]: Subscribing to /camera/depth/image_raw/theora
[ INFO] [1330246494.199527654]: Subscribing to /tf
[ INFO] [1330246494.205979210]: Subscribing to /camera/depth/image_raw/theora/parameter_descriptions
[ INFO] [1330246494.212827463]: Subscribing to /camera/rgb/image_mono/theora/parameter_descriptions
[ INFO] [1330246494.219018234]: Subscribing to /camera/rgb/image_raw/compressed
[ INFO] [1330246494.223620402]: Subscribing to /camera/rgb/image_mono/compressed/parameter_descriptions
[ INFO] [1330246494.226451684]: Subscribing to /camera/rgb/image_mono/theora/parameter_updates
[ INFO] [1330246494.229063037]: Subscribing to /camera/rgb/image_raw/compressed/parameter_updates
[ INFO] [1330246494.231719646]: Subscribing to /camera/depth/image/theora/parameter_updates
[ INFO] [1330246494.234358167]: Subscribing to /openni_node1/parameter_updates
[ INFO] [1330246494.236913228]: Subscribing to /camera/depth/image_raw/compressed/parameter_descriptions
[ INFO] [1330246494.239575774]: Subscribing to /camera/rgb/points
[ INFO] [1330246494.242255780]: Subscribing to /camera/rgb/camera_info
[ INFO] [1330246494.244859171]: Subscribing to /camera/rgb/image_color/compressed
[ INFO] [1330246494.261203557]: Subscribing to /camera/rgb/image_color/compressed/parameter_descriptions
[ INFO] [1330246494.267427571]: Subscribing to /camera/depth/image/compressed
[ INFO] [1330246494.273242877]: Subscribing to /camera/depth/image_raw/theora/parameter_updates
[ INFO] [1330246494.283536873]: Subscribing to /camera/depth/image_raw/compressed
[ INFO] [1330246494.291459070]: Subscribing to /camera/rgb/image_color/theora/parameter_updates
[ INFO] [1330246494.299466124]: Subscribing to /camera/depth/camera_info
[ INFO] [1330246494.302353488]: Subscribing to /camera/rgb/image_color
[ INFO] [1330246494.328684988]: Subscribing to /camera/rgb/image_raw/compressed/parameter_descriptions
[ INFO] [1330246494.337562469]: Subscribing to /rosout
[ INFO] [1330246494.349211658]: Subscribing to /camera/depth/disparity
[ INFO] [1330246494.352240939]: Subscribing to /camera/depth/image_raw
[ INFO] [1330246494.359652878]: Subscribing to /camera/rgb/image_color/compressed/parameter_updates
[ INFO] [1330246494.372313713]: Subscribing to /rosout_agg
[ INFO] [1330246494.380340812]: Subscribing to /camera/depth/image/theora/parameter_descriptions
[ INFO] [1330246494.386094727]: Subscribing to /camera/rgb/image_mono
[ INFO] [1330246494.392173263]: Subscribing to /camera/rgb/image_color/theora
[ INFO] [1330246494.400247295]: Subscribing to /camera/rgb/image_color/theora/parameter_descriptions
[ INFO] [1330246494.410299151]: Subscribing to /camera/depth/points
[ INFO] [1330246494.419197515]: Subscribing to /camera/rgb/image_raw/theora
[ INFO] [1330246494.425615758]: Subscribing to /camera/rgb/image_raw/theora/parameter_updates
[ INFO] [1330246494.432190793]: Subscribing to /camera/depth/image_raw/compressed/parameter_updates
[ INFO] [1330246494.455170068]: Subscribing to /camera/rgb/image_mono/theora
[ INFO] [1330246494.466239857]: Subscribing to /camera/rgb/image_raw/theora/parameter_descriptions
[ INFO] [1330246494.478321710]: Subscribing to /camera/depth/image/compressed/parameter_updates
[ INFO] [1330246494.484514087]: Subscribing to /openni_node1/parameter_descriptions
[ INFO] [1330246494.494957891]: Subscribing to /camera/depth/image/compressed/parameter_descriptions
^C


However, the openni_node crushed immediately after I started recording all topics. The error messages were:

OpenCV Error: Image step is wrong () in cvInitMatHeader, file /tmp/buildd/libopencv-2.3.1+svn6514+branch23/modules/core/src/array.cpp, line 162
terminate called after ...
edit retag close merge delete

Sort by » oldest newest most voted

Don't use the -a flag, rosbag will subscribe to all offered topics, even if some are meant as alternatives and might not be used in combination. So, think about what you want to do with the data and only subscribe to the relevant topics. The most commonly used topics are

• /tf
• /camera/rgb/image_mono
• /camera/rgb/image_color
• /camera/rgb/points
• /camera/rgb/camera_info
• /camera/depth/image
• /camera/depth/points
• /camera/depth/camera_info

But still you will only need a subset of those.

Edit: I just stumbled upon this again and want to add, that I recently wrote a small tool to assemble point clouds from (rgb and) depth images. It can be found in our repository. The wiki page will be generated in a few page. Until then have a look into the manifest for usage information.

more

Thanks. Besides, why I said "openni_node crushed" is that the bag file only recorded some info or parameter_description instead of the real sensor data. But why did this happened? (Should I open a new question for this?) Now I specify the topics I want and this don't happened again. Thanks a lot.

( 2012-02-26 03:29:10 -0600 )edit

@Felix Endres is right. Note that you can save space in the bags by saving compressed images like /camera/rgb/image_image/compressed, etc.

( 2012-02-26 04:00:57 -0600 )edit

Felix Endres is right. You should not try to record all the topics at the same time.

And if you are going to capture Kinect-Data it is worth having a look at the bandwidth of the topics in advance. When working at 640x480/30 fps the /camera/rgb/points topic will generate almost 300 MByte/s of data. That would lead to really huge bag-files... If you need the pointclouds later on you should consider capturing the raw image topics and reassemble the clouds on playback like described in this answer.

It may be necessary though to switch to the newer openni_launch for this to work. I am not sure if the older openni_camera driver can be broken up in single nodelets.

more

Hi, I'm wondering what you mean by saying "if the older openni_camera driver can be broken up in single nodelets." Thanks.

( 2012-03-05 00:54:57 -0600 )edit

The answer i linked relies on the fact, that the newer openni-driver has the different functions organized in nodelets which dont need to run in the same process and can be distributed. I dont know if the old driver supports the pointcloud-generation on another machine.

( 2012-03-05 01:45:53 -0600 )edit

Hi there. There is now a tutorial available about this very question, which I just finished following successfully. The tutorial is at http://mirror.umd.edu/roswiki/openni_launch(2f)Tutorials(2f)BagRecordingPlayback.html

The approach described there is very similar to the answer given by Felix Endres. The main idea is again to capture the raw data and then run the post-processing during playback. For using the Kinect pre-registered images the suggestion is to run openni_launch and then record only the following channels:

• camera/depth_registered/image_raw.
• camera/depth_registered/camera_info.
• camera/rgb/image_raw.
• camera/rgb/camera_info.

For playback it is necessary to:

• Set the /use_sim_time parameter to true.
• Get rosbag to publish /clock.
• Stop openni_launch from starting the OpenNI driver.

More details are at the source.

I would like to thank the author of the tutorial; very helpful.

I have some launch files which approximately follow this tutorial for recording sense data and playing it back, for fuerte: https://bitbucket.org/damienjadeduff/openni_bag/src

The two files you will want there, play.launch and record.launch do approximately what you'd think they should.

more