Install
# install catkin-tools
sudo apt install python-catkin-tools # if your ros distro is new enough to use python3 (since ubuntu 20.04), use python3-catkin-tools instead
# install packages
mkdir -p kitti_to_rosbag_ws/src
cd kitti_to_rosbag_ws/src
git clone https://github.com/ethz-asl/kitti_to_rosbag.git
git clone https://github.com/catkin/catkin_simple.git
git clone https://github.com/ethz-asl/gflags_catkin.git
git clone https://github.com/ethz-asl/glog_catkin.git
git clone https://github.com/ethz-asl/minkindr.git
git clone https://github.com/ethz-asl/eigen_catkin.git
git clone https://github.com/ethz-asl/eigen_checks.git
git clone https://github.com/ethz-asl/catkin_boost_python_buildtool.git
git clone https://github.com/ethz-asl/minkindr_ros
git clone https://github.com/ethz-asl/numpy_eigen
# build
cd ..
catkin build --cmake-args -DCMAKE_CXX_STANDARD=14 # you can choose different version, on 20.04, c++14 is needed, prior versions might require c++11
Note: you may need to change *image = cv::imread(filename, CV_LOAD_IMAGE_UNCHANGED);
into cv::IMREAD_UNCHANGED
for newer version of opencv, at kitti_to_rosbag_ws/src/kitti_to_rosbag/kitti_to_rosbag/src/kitti_parser.cpp:497
.
Usage
Rosbag converter usage example
rosrun kitti_to_rosbag kitti_rosbag_converter calibration_path dataset_path output_path
(No trailing slashes).
rosrun kitti_to_rosbag kitti_rosbag_converter ~/data/kitti/2011_09_26 ~/data/kitti/2011_09_26/2011_09_26_drive_0035_sync ~/data/kitti/2011_09_26/2011_09_26_drive_0035_sync/testbag.bag
Library API Example
#include <opencv2/highgui/highgui.hpp>
#include "kitti_to_rosbag/kitti_parser.h"
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, false);
const std::string calibration_path = "/Users/helen/data/kitti/2011_09_26";
const std::string dataset_path =
"/Users/helen/data/kitti/2011_09_26/2011_09_26_drive_0035_sync";
kitti::KittiParser parser(calibration_path, dataset_path, true);
parser.loadCalibration();
parser.loadTimestampMaps();
uint64_t timestamp;
kitti::Transformation pose;
parser.getPoseAtEntry(0, ×tamp, &pose);
std::cout << "Timestamp: " << timestamp << " Pose: " << pose << std::endl;
pcl::PointCloud<pcl::PointXYZI> ptcloud;
parser.getPointcloudAtEntry(0, ×tamp, &ptcloud);
std::cout << "Timestamp: " << timestamp << " Num points: " << ptcloud.size()
<< std::endl;
cv::Mat image;
parser.getImageAtEntry(0, 3, ×tamp, &image);
cv::imshow("Display window", image);
cv::waitKey(0);
return 0;
}