modified version of *https://github.com/tomas789/kitti2bag*
-
Install pykitti
pip install pykitti -
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.')
-
Install kitti2bag:
pip install kitti2bag -
Modify kitti2bag located in
/usr/local/bin/. Change from:
kitti.load_calib()
kitti.load_timestamps()
To:
kitti._load_calib()
kitti._load_timestamps()
-
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).
-
Enter
kitti2bag -s 00 odom_gray .to convert 00 bag to rosbag