tomas789 / kitti2bag

Convert KITTI dataset to ROS bag file the easy way!
MIT License
702 stars 256 forks source link

Unable to generate rosbag from the KITTI odometry Velodyne dataset #10

Open vkee opened 6 years ago

vkee commented 6 years ago

Hi,

I'm unable to generate a rosbag from the KITTI odometry Velodyne dataset (http://www.cvlibs.net/download.php?file=data_odometry_velodyne.zip).

I get a AttributeError: odometry instance has no attribute 'load_calib' when I try to run kitti2bag odom_color -s 01.

Has anyone been able to do this successfully?

Thanks!

tomas789 commented 6 years ago

I'm currently downloading the dataset to try it but it will take a while since it is very large. This is probably caused by pykitti since they changed API. It should be already fixed. Can you try it with current version please? Try the version from Github although newest version from pip should work too.

vkee commented 6 years ago

I installed everything today and had this issue. Please let me know if you are able to get it to work.

Thanks!

vkee commented 6 years ago

Any updates on this? I tried both the latest version from Github along with the latest from pip.

Thanks!

bartville commented 6 years ago

Hi guys, I've got the same exactly issue while converting a sequence of kitti velodyne datasets

AttributeError: odometry instance has no attribute 'load_calib'

Any updates?

Update I had a look at https://github.com/utiasSTARS/pykitti/tree/master/pykitti, and modified the content of the /usr/local/bin/kitti2bag script. load_calib becomes _load_calib same for load_timestamps to _load_timestamps

a problem still remains with load_poses() that seems not be used anymore in pyKitti

Update 2.0 I checkout pyKitti to an old commit (before june 2017) and start again. Still problems with a wrong call to load_rgb instad of load_velo I give up for the moment.

CtfChan commented 6 years ago

Hey bartville I am having the exact same issue as you with the stereo dataset. kitti2bag calls on nonexistent functions from pykitti and the script just crashes.

AbnerCSZ commented 6 years ago

I have encountered the same problem as yours.#16 And I solved it. The odometry datasets are just subsets of the raw data. We can't use kitti2bag to directly convert odometry data to rosbag. But we can find the mapping from odometry sequences to raw sequences in the readme.txt file included with the odometry development kit, and then use kitti2bag.

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

wutongyu98 commented 5 years ago

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.')**
  3. Install kitti2bag: pip install kitti2bag

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

    kitti.load_calib() kitti.load_timestamps() To:

    kitti._load_calib()
    kitti._load_timestamps()
  5. 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).

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

getupgetup commented 5 years ago

I have encountered the same problem as yours.#16 And I solved it. The odometry datasets are just subsets of the raw data. We can't use kitti2bag to directly convert odometry data to rosbag. But we can find the mapping from odometry sequences to raw sequences in the readme.txt file included with the odometry development kit, and then use kitti2bag.

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

But this means I need to download raw data again which contains large amount of images that I don't need.Is there anyway to get rosbag from the pure velodyne data sequence?

HongweiSunny commented 5 years ago

I have encountered the same problem as yours.#16 And I solved it. The odometry datasets are just subsets of the raw data. We can't use kitti2bag to directly convert odometry data to rosbag. But we can find the mapping from odometry sequences to raw sequences in the readme.txt file included with the odometry development kit, and then use kitti2bag.

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

But this means I need to download raw data again which contains large amount of images that I don't need.Is there anyway to get rosbag from the pure velodyne data sequence?

@getupgetup Hi, is this probelm solved?

getupgetup commented 5 years ago

I have encountered the same problem as yours.#16 And I solved it. The odometry datasets are just subsets of the raw data. We can't use kitti2bag to directly convert odometry data to rosbag. But we can find the mapping from odometry sequences to raw sequences in the readme.txt file included with the odometry development kit, and then use kitti2bag.

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

But this means I need to download raw data again which contains large amount of images that I don't need.Is there anyway to get rosbag from the pure velodyne data sequence?

@getupgetup Hi, is this probelm solved?

没有,不过一个可行的方案:参考楼上的方法修改kitti2bag代码,然后把raw data下载后转换为rosbag,如果不需要图像等其他数据,就在kitti2bag源码中注释掉不需要的部分.

AbnerCSZ commented 5 years ago

@getupgetup @HongweiSunny If you only want to get rosbag from velodyne, you can just download the velodyne .bin data and use my tool: lidar2rosbag_KITTI .

getupgetup commented 5 years ago

@getupgetup @HongweiSunny If you only want to get rosbag from velodyne, you can just download the velodyne .bin data and use my tool: lidar2rosbag_KITTI .

还没细看,谢谢~

HongweiSunny commented 5 years ago

@getupgetup @HongweiSunny If you only want to get rosbag from velodyne, you can just download the velodyne .bin data and use my tool: lidar2rosbag_KITTI .

Thanks for your replying! @getupgetup 可否加个微信之类的平时可以交流一下 wechatID:sunhongwei0930

pangchenglin commented 5 years ago

@getupgetup @HongweiSunny If you only want to get rosbag from velodyne, you can just download the velodyne .bin data and use my tool: lidar2rosbag_KITTI .

Thanks for your replying! @getupgetup 可否加个微信之类的平时可以交流一下 wechatID:sunhongwei0930

Are you fixed this problem? if you can fix it ,could you please tell me how to fix it???

nobinov commented 5 years ago

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.')**

3. Install kitti2bag: pip install kitti2bag

4. Modify kitti2bag located in /usr/local/bin/. Change from:
   kitti.load_calib()
   kitti.load_timestamps()
   To:
   ```
    kitti._load_calib()
    kitti._load_timestamps()
   ```

5. 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).

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

I've tried this, and this error occured :

AttributeError: odometry instance has no attribute 'load_poses'

So, I changed kitti.load_poses() to kitti._load_poses() . After that, it give output like this : AttributeError: odometry instance has no attribute 'T_w_cam0'

Anyone knows what 'T_w_cam0' is?

UPDATE: From example of pykitti for odometry data in https://github.com/utiasSTARS/pykitti/blob/master/demos/demo_odometry.py , T_w_cam0is a list of ground truth poses. so kitti.T_w_cam0 can be replaced by kitti.poses . And now it's working.

n.b. : Apparently odom_color and odom_gray only didn't include velodyne data to the rosbag. Anyone knows how to include velodyne data to the bag?

getupgetup commented 5 years ago

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.')**

3. Install kitti2bag: pip install kitti2bag

4. Modify kitti2bag located in /usr/local/bin/. Change from:
   kitti.load_calib()
   kitti.load_timestamps()
   To:
kitti._load_calib()
kitti._load_timestamps()

5. 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).

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

I've tried this, and this error occured :

AttributeError: odometry instance has no attribute 'load_poses'

So, I changed kitti.load_poses() to kitti._load_poses() . After that, it give output like this : AttributeError: odometry instance has no attribute 'T_w_cam0'

Anyone knows what 'T_w_cam0' is?

UPDATE: From example of pykitti for odometry data in https://github.com/utiasSTARS/pykitti/blob/master/demos/demo_odometry.py , T_w_cam0is a list of ground truth poses. so kitti.T_w_cam0 can be replaced by kitti.poses . And now it's working.

n.b. : Apparently odom_color and odom_gray only didn't include velodyne data to the rosbag. Anyone knows how to include velodyne data to the bag?

I'm sorry that I've forgot how I solved the problem. I think the velodyne data with image/pose/etc data is included in the whole text file.Then different types of data are write to rosbag simultaneously by pykitti. PS: Version incompatibility is really annoying. I think you can learn some basic python which is not hard. Then you can modify code in pykitti according to error messages. (That is the way I have done to solve it)

chubukeji commented 2 years ago

hello,the 03: 2011_09_26_drive_0067 can't be found in official website. Do you have this dataset? Or,do you know why it can't be found? my Email 2661076951@qq.com

chubukeji commented 2 years ago

@AbnerCSZ hello,the 03: 2011_09_26_drive_0067 can't be found in official website. Do you have this dataset? Or,do you know why it can't be found? my Email 2661076951@qq.com