ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

My recommendation is to use existing tools: If you want to reuse the data with a ROS node, record a bagfile, e.g.:

rosbag record -o kinect-data /tf /the-rgb-image-topic /the-depth-image-topic /the-camera-info-topic

If you want the raw images, use image_saver from the image_view package:

rosrun image_view image_saver image:=/the-rgb-image-topic &
rosrun image_view image_saver image:=/the-depth-image-topic

If you still want to do it from your code, maybe because you need to be absolutely sure you get every frame, you can use the sequence number of the message to check whether you lost something. It's some integer you can access via msg->header->seq. It should always increase by one.

Also have a look at the approximate time synchronizing message filter, which can help you get associated rgb and depth in a single callback.

My recommendation is to use existing tools: If you want to reuse the data with a ROS node, record a bagfile, e.g.:

rosbag record -o kinect-data /tf /the-rgb-image-topic /the-depth-image-topic /the-camera-info-topic

If you want the raw images, use image_saver from the image_view package:

rosrun image_view image_saver image:=/the-rgb-image-topic &
rosrun image_view image_saver image:=/the-depth-image-topic

If you still want to do it from your code, maybe because you need to be absolutely sure you get every frame, you can use the sequence number of the message to check whether you lost something. It's some integer you can access via msg->header->seq. It should always increase by one.

Also have a look at the approximate time synchronizing message filter, which can help you get associated rgb and depth in a single callback.

You will record with 30Hz if your machine is fast enough. If not, there are few things you can do.

P.S: Just some general C++ advise: Don't use global variables if you can avoid it. Static variables within the callback functions would make more sense here.