Skip to content

Commit be74a8e

Browse files
Benedikt MerschtizianoGuadagnino
andauthored
Make empty timestamps default everywhere (#430)
* Add timestamps in open3d dataloading, now it is the first option in generic * Need o3d>=0.16 * Not used * Formatting * Add normalization * Use empty timestamps everywhere --------- Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>
1 parent 0a9b916 commit be74a8e

File tree

8 files changed

+12
-18
lines changed

8 files changed

+12
-18
lines changed

python/kiss_icp/datasets/apollo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __len__(self):
4949
return len(self.scan_files)
5050

5151
def __getitem__(self, idx):
52-
return self.get_scan(self.scan_files[idx])
52+
return self.get_scan(self.scan_files[idx]), np.array([])
5353

5454
def get_scan(self, scan_file: str):
5555
points = np.asarray(self.o3d.io.read_point_cloud(scan_file).points, dtype=np.float64)

python/kiss_icp/datasets/kitti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __len__(self):
5454
return len(self.scan_files)
5555

5656
def scans(self, idx):
57-
return self.read_point_cloud(self.scan_files[idx])
57+
return self.read_point_cloud(self.scan_files[idx]), np.array([])
5858

5959
def apply_calibration(self, poses: np.ndarray) -> np.ndarray:
6060
"""Converts from Velodyne to Camera Frame"""

python/kiss_icp/datasets/mcap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import os
2424
import sys
2525

26+
import numpy as np
27+
2628

2729
class McapDataloader:
2830
def __init__(self, data_dir: str, topic: str, *_, **__):
@@ -58,7 +60,7 @@ def __del__(self):
5860
def __getitem__(self, idx):
5961
msg = next(self.msgs).ros_msg
6062
self.timestamps.append(self.stamp_to_sec(msg.header.stamp))
61-
return self.read_point_cloud(msg)
63+
return self.read_point_cloud(msg), np.array([])
6264

6365
def __len__(self):
6466
return self.n_scans

python/kiss_icp/datasets/nclt.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def __len__(self):
5454
return len(self.scan_files)
5555

5656
def __getitem__(self, idx):
57-
return self.read_point_cloud(os.path.join(self.scans_dir, self.scan_files[idx]))
57+
return self.read_point_cloud(os.path.join(self.scans_dir, self.scan_files[idx])), np.array(
58+
[]
59+
)
5860

5961
def read_point_cloud(self, file_path: str):
6062
def _convert(x_s, y_s, z_s):

python/kiss_icp/datasets/nuscenes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __len__(self):
7676
return len(self.lidar_tokens)
7777

7878
def __getitem__(self, idx):
79-
return self.read_point_cloud(self.lidar_tokens[idx])
79+
return self.read_point_cloud(self.lidar_tokens[idx]), np.array([])
8080

8181
def read_point_cloud(self, token: str):
8282
filename = self.nusc.get("sample_data", token)["filename"]

python/kiss_icp/datasets/tum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ def __getitem__(self, idx):
9393
self.o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault
9494
),
9595
)
96-
return np.array(pcd.points, dtype=np.float64)
96+
return np.array(pcd.points, dtype=np.float64), np.array([])

python/kiss_icp/pipeline.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def run(self):
9898
# Private interface ------
9999
def _run_pipeline(self):
100100
for idx in get_progress_bar(self._first, self._last):
101-
raw_frame, timestamps = self._next(idx)
101+
raw_frame, timestamps = self._dataset[idx]
102102
start_time = time.perf_counter_ns()
103103
source, keypoints = self.odometry.register_frame(raw_frame, timestamps)
104104
self.poses[idx - self._first] = self.odometry.last_pose
@@ -114,16 +114,6 @@ def _run_pipeline(self):
114114
self._vis_infos,
115115
)
116116

117-
def _next(self, idx):
118-
"""TODO: re-arrange this logic"""
119-
dataframe = self._dataset[idx]
120-
try:
121-
frame, timestamps = dataframe
122-
except ValueError:
123-
frame = dataframe
124-
timestamps = np.array([])
125-
return frame, timestamps
126-
127117
@staticmethod
128118
def save_poses_kitti_format(filename: str, poses: np.ndarray):
129119
def _to_kitti_format(poses: np.ndarray) -> np.ndarray:

python/kiss_icp/tools/point_cloud2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def read_point_cloud(msg: PointCloud2) -> Tuple[np.ndarray, np.ndarray]:
8686
max_timestamp = np.max(timestamps)
8787
timestamps = (timestamps - min_timestamp) / (max_timestamp - min_timestamp)
8888
else:
89-
timestamps = np.ones(points.shape[0])
89+
timestamps = np.array([])
9090
return points.astype(np.float64), timestamps
9191

9292

0 commit comments

Comments
 (0)