Working with the KITTI Odometry Dataset in ROS

ROS Setup with KITTI bag files

Posted by Steven on August 5, 2018

Motivation

The KITTI dataset is one of the most popular datasets for benchmarking algorithms relevant to self-driving cars. I used this dataset for my LOAM project as well. The whole process is pretty pain-free, but I write these notes here to help me remember for future projects.

Velodyne Drivers

We need to install Velodyne drivers in order to visualize and work with the lidar point clouds in KITTI. Quite simple to install:

$ sudo apt-get install ros-kinetic-velodyne
$ cd ~/catkin_ws/src && git clone https://github.com/ros-drivers/velodyne.git
$ rosdep install --from-paths src --ignore-src --rosdistro KINETIC -y
$ cd ~/catkin_ws/ %% catkin_make

Converting to bag file format

This open source tool, kitti2bag converts KITTI datasets to ROS bag files. It is essentially a python script that does all the work. Just download synchronized version of KITTI datasets and run the tool. Install it by:

pip install kitti2bag

Run it by:

$ wget http://kitti.is.tue.mpg.de/kitti/raw_data/2011_09_26_drive_0002/2011_09_26_drive_0002_sync.zip
$ wget http://kitti.is.tue.mpg.de/kitti/raw_data/2011_09_26_calib.zip
$ unzip 2011_09_26_drive_0002_sync.zip
$ unzip 2011_09_26_calib.zip
$ kitti2bag -t 2011_09_26 -r 0002 raw_synced .

And done! The resulting bag file can be used with rviz to visualize our algorithms.

Visualizing the bag file with rviz

Once we have a bagfile, it’s easy to visualize by simply opening rviz and subscribing to the right topics. In 1 terminal:

$ rviz 

In another terminal (It’s convenient to open a tab with CTRL-SHIFT-T):

$ rosbag play -r 0.5 ~/Downloads/kitti_2011_09_26_drive_0002_synced.bag

Note: The -r option specifies publish rate, the 0.5 represents half the play speed. In rviz, subscribe to the topics that are of interest. The camera topics are of the sensor_msgs/Image type, and the lidar topics are of the sensor_msgs/PointCloud2 type. By default, the name of the topics are /kitti/camera_color_left/image_raw and /kitti/velo/pointcloud.

– Steven 2018.08