Converting the KITTI dataset to rosbags

The KITTI Vision Benchmark Suite dataset is a popular robotics dataset from Karlsruhe Institute of Technology and Toyota Technological Institute at Chicago. Several benchmarking datasets are provided including stereo, flow, scene flow, depth, odomerty, object, tracking, road, semantics and the raw data.

To use this dataset in ROS, the streams should first be converted to ROS messages and published over various topics.  This tutorials provides a step-by-step guide of how to achieve this.

Find corresponding raw file

Kitti provides domain specific datasets for stereo, flow, scene flow, depth, odometery, object, tracking, road and semantics. Each of these datasets has a corresponding raw dataset. For the odometry dataset, the readme.txt file in the odometry development kit has a section on mapping to raw data which is extracted below:

Mapping to Raw Data
===================
Note that this section is additional to the benchmark, and not required for
solving the object detection task.

In order to allow the usage of the laser point clouds, gps data, the right
camera image and the grayscale images for the TRAINING data as well, we
provide the mapping of the training set to the raw data of the KITTI dataset.
The following table lists the name, start and end frame of each sequence that
has been used to extract the visual odometry / SLAM training set:

Nr.     Sequence name     Start   End
---------------------------------------
00: 2011_10_03_drive_0027 000000 004540
01: 2011_10_03_drive_0042 000000 001100
02: 2011_10_03_drive_0034 000000 004660
03: 2011_09_26_drive_0067 000000 000800
04: 2011_09_30_drive_0016 000000 000270
05: 2011_09_30_drive_0018 000000 002760
06: 2011_09_30_drive_0020 000000 001100
07: 2011_09_30_drive_0027 000000 001100
08: 2011_09_30_drive_0028 001100 005170
09: 2011_09_30_drive_0033 000000 001590
10: 2011_09_30_drive_0034 000000 001200

The raw sequences can be downloaded from
http://www.cvlibs.net/datasets/kitti/raw_data.php
in the respective category (mostly: Residential).

From the above file, it is evident that for the visual odometry dataset 00 the corresponding raw file is 2011_10_03_drive_0027.

Download the raw dataset

Once the corresponding raw dataset is identified, download and unzip the files via terminal:

  1. Download the drive file: wget https://s3.eu-central-1.amazonaws.com/avg-kitti/raw_data/2011_10_03_drive_0027/2011_10_03_drive_0027_sync.zip
  2. Download the calibration file: wget https://s3.eu-central-1.amazonaws.com/avg-kitti/raw_data/2011_10_03_calib.zip
  3. Unzip the drive file: unzip 2011_10_03_drive_0027_sync.zip
  4. Unzip the calibration file: unzip 2011_10_03_calib.zip

Create the rosbag file

In a terminal, install and run kitti2bag:

  1. set up pyenv
    • Create a virtual environment: virtualenv -p /usr/bin/python my_project
    • Activate the virtual environment: source my_project/bin/activate
    • Update Python pip: python -m pip install --upgrade pip
  2. install kitti2bag and ROS dependencies
    • Install kitti2bag: pip install kitti2bag
    • Install ROS Python dependencies: pip install rospkg catkin_pkg
  3. create the bag file
    • Change directory to storage location: cd /location/to/store/bag/file
    • Create the rosbag file: kitti2bag -t 2011_10_03 -r 0027 raw_synced

This will create a bag file named kitti_2011_10_03_drive_0027_synced.bag. The process does take a while so go ahead and brew a cup of coffee. When all is done you should see the following output in terminal:

Exporting static transformations
Exporting time dependent transformations
Exporting IMU
Exporting camera 0
100% (4544 of 4544) |##################################################################################################################################| Elapsed Time: 0:03:01 Time:  0:03:01
Exporting camera 1
100% (4544 of 4544) |##################################################################################################################################| Elapsed Time: 0:03:37 Time:  0:03:37
Exporting camera 2
100% (4544 of 4544) |##################################################################################################################################| Elapsed Time: 0:05:22 Time:  0:05:22
Exporting camera 3
100% (4544 of 4544) |##################################################################################################################################| Elapsed Time: 0:05:48 Time:  0:05:48
Exporting velodyne data
100% (4544 of 4544) |##################################################################################################################################| Elapsed Time: 0:16:49 Time:  0:16:49
## OVERVIEW ##
path:        kitti_2011_10_03_drive_0027_synced.bag
version:     2.0
duration:    7:50s (470s)
start:       Oct 03 2011 12:55:34.00 (1317642935.00)
end:         Oct 03 2011 13:03:25.83 (1317643405.83)
size:        24.0 GB
messages:    63616
compression: none [18184/18184 chunks]
types:       
geometry_msgs/TwistStamped [98d34b0043a2093cf9d9345ab6eef12e]
sensor_msgs/CameraInfo     [c9a58c1b0b154e0e6da7578cb991d214]
sensor_msgs/Image          [060021388200f6f0f447d0fcd9c64743]
sensor_msgs/Imu            [6a62c6daae103f4ff57a132d6f95cec2]
sensor_msgs/NavSatFix      [2d3a8cd499b9b4a0249fb98fd05cfa48]
sensor_msgs/PointCloud2    [1158d486dd51d683ce2f1be655c3c181]
tf2_msgs/TFMessage         [94810edda583a504dfda3829e70d7eec]
topics:      
/kitti/camera_color_left/camera_info    4544 msgs    : sensor_msgs/CameraInfo
/kitti/camera_color_left/image_raw      4544 msgs    : sensor_msgs/Image
/kitti/camera_color_right/camera_info   4544 msgs    : sensor_msgs/CameraInfo
/kitti/camera_color_right/image_raw     4544 msgs    : sensor_msgs/Image
/kitti/camera_gray_left/camera_info     4544 msgs    : sensor_msgs/CameraInfo
/kitti/camera_gray_left/image_raw       4544 msgs    : sensor_msgs/Image
/kitti/camera_gray_right/camera_info    4544 msgs    : sensor_msgs/CameraInfo
/kitti/camera_gray_right/image_raw      4544 msgs    : sensor_msgs/Image
/kitti/oxts/gps/fix                     4544 msgs    : sensor_msgs/NavSatFix
/kitti/oxts/gps/vel                     4544 msgs    : geometry_msgs/TwistStamped
/kitti/oxts/imu                         4544 msgs    : sensor_msgs/Imu
/kitti/velo/pointcloud                  4544 msgs    : sensor_msgs/PointCloud2
/tf                                     4544 msgs    : tf2_msgs/TFMessage
/tf_static                              4544 msgs    : tf2_msgs/TFMessage

Using the rosbag file

To use the bag file, just run roscore in a terminal and play it back using rosbag play kitti_2011_10_03_drive_0027_synced.bag.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s