Skip to content

Instantly share code, notes, and snippets.

@zhanghanduo
Last active April 14, 2023 07:11
Show Gist options
  • Select an option

  • Save zhanghanduo/f3b7fc8bf5cdbaaece77f835b546e111 to your computer and use it in GitHub Desktop.

Select an option

Save zhanghanduo/f3b7fc8bf5cdbaaece77f835b546e111 to your computer and use it in GitHub Desktop.
KITTI data to rosbag #software #experiments

Usage of kitti2bag for KITTI dataset with grayscale odometry images

modified version of *https://github.com/tomas789/kitti2bag*
  1. Install pykitti pip install pykitti

  2. Modify pykitti/odometry.py file located in /usr/local/lib/python2.7/dist-packages/pykitti. At the end of the odometry.py, add:

   def load_poses(self):
        """Load ground truth poses from file."""
        print('Loading poses for sequence ' + self.sequence + '...')
 
        pose_file = os.path.join(self.pose_path, self.sequence + '.txt')
 
        # Read and parse the poses
        self.T_w_cam0 = []
        with open(pose_file, 'r') as f:
             for line in f.readlines():
                 T = np.fromstring(line, dtype=float, sep=' ')
                 T = T.reshape(3, 4)
                 T = np.vstack((T, [0, 0, 0, 1]))
                 self.T_w_cam0.append(T)
        print('done.')
  1. Install kitti2bag: pip install kitti2bag

  2. Modify kitti2bag located in /usr/local/bin/. Change from:

	kitti.load_calib()
        kitti.load_timestamps()

To:

        kitti._load_calib()
        kitti._load_timestamps()
  1. enter the dataset folder with image sequence and pose gt. e.g.: enter dataset/, create poses (00.txt, 01.txt, ...), and /sequences (00/image_0, 00/image_1, 00/calib.txt, 00/times.txt).

  2. Enter kitti2bag -s 00 odom_gray . to convert 00 bag to rosbag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment