The KITTI Vision Suite benchmark was introduced in the previous post. In this post we are going to convert to “rosbags”, a format that is designed for development of ROS based autonomous systems.

What are rosbags?

Rosbag (or bag) is a file format for storing ROS message data. Bags are often created by subscribing to one or more ROS topics on a running system, and storing the received message data. But they can also be created programatically if sensor data is already saved in another format. Once you hava a bag you can replay the messages using the rosbag ROS package to aid testing and troubleshooting your robotics applications as well as developing new functionality.

Rosbag playback

To make this more concrete lets jump ahead and look at vizualising an example conversion. These videos were captured from RViz configured to subsribe to Pointcloud and Image data that originated as KITTI “raw_data” collected on {datetime} for drive number {drive}.

Pointcloud data from a Velodyne 360 laser scanner

Monochrome image from the left-hand monochrome stereo camera

The messages are contained in the file kitti_date_drive.bag and we would like to know what topics are available to playback. We can do this simply by using the rosbag info command after we have setup the ROS environment for our ROS distro {e.g. melodic, noetic} in the usual way:

source /opt/ros/{distro}/setup.bash
rosbag info kitti_{type}_{date}_{drive}.bag

This will generate output similar to this

path:        kitti_raw_2011_10_03_0027.bag
version:     2.0
duration:    1:23s (83s)
start:       Oct 03 2011 12:55:34.00 (1317639335.00)
end:         Oct 03 2011 12:56:58.19 (1317639418.19)
size:        3.4 GB
messages:    14436
compression: none [3079/3079 chunks]
types:       sensor_msgs/CameraInfo  [c9a58c1b0b154e0e6da7578cb991d214]
             sensor_msgs/Image       [060021388200f6f0f447d0fcd9c64743]
             sensor_msgs/PointCloud2 [1158d486dd51d683ce2f1be655c3c181]
             tf2_msgs/TFMessage      [94810edda583a504dfda3829e70d7eec]
topics:      /camera/00/camera_info   4544 msgs    : sensor_msgs/CameraInfo 
             /camera/00/image_rect    4544 msgs    : sensor_msgs/Image      
             /tf_static               4544 msgs    : tf2_msgs/TFMessage     
             /velo/pointcloud          804 msgs    : sensor_msgs/PointCloud2

Now that we know what topics will be published we can configure coresponding subscriptions in RViz, but first we should ensure that bagfile is correctly indexed.

rosbag reindex kitti_{type}_{date}_{drive}.bag

If you are not using ROS2 we need to start ROS core in a new console (after setting up ROS):

source /opt/ros/{distro}/setup.bash
roscore

which should give you something like this

Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://workstation:45613/
ros_comm version 1.15.13


SUMMARY
========

PARAMETERS
 * /rosdistro: noetic
 * /rosversion: 1.15.13

NODES

auto-starting new master
process[master]: started with pid [6757]
ROS_MASTER_URI=http://workstation:11311/

setting /run_id to 4f23107c-4780-11ec-a8e7-e7a893b0327d
process[rosout-1]: started with pid [6775]
started core service [/rosout]


Now just hit play and our messages will be streamed just as if they were comming from a live source.

rosbag play kitti_{type}_{date}_{drive}.bag

producing something like this

[ INFO] [1637138257.188600355]: Opening kitti_raw_2011_10_03_0027.bag

Waiting 0.2 seconds after advertising topics... done.

Hit space to toggle paused, or 's' to step.
 [RUNNING]  Bag Time: 1317639334.934675   Duration: 0.000000 / 470.899880
 [RUNNING]  Bag Time: 1317639334.934833   Duration: 0.000158 / 470.899880
 [RUNNING]  Bag Time: 1317639334.998265   Duration: 0.063590 / 470.899880
 [RUNNING]  Bag Time: 1317639335.038506   Duration: 0.103831 / 470.899880
 [RUNNING]  Bag Time: 1317639335.098377   Duration: 0.163702 / 470.899880
 [RUNNING]  Bag Time: 1317639335.142415   Duration: 0.207740 / 470.899880
 [RUNNING]  Bag Time: 1317639335.198251   Duration: 0.263576 / 470.899880
 ...