Skip to content

Commit

Permalink
Make empty timestamps default everywhere (#430)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
benemer and tizianoGuadagnino authored Jan 24, 2025
1 parent 0a9b916 commit be74a8e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion python/kiss_icp/datasets/apollo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __len__(self):
return len(self.scan_files)

def __getitem__(self, idx):
return self.get_scan(self.scan_files[idx])
return self.get_scan(self.scan_files[idx]), np.array([])

def get_scan(self, scan_file: str):
points = np.asarray(self.o3d.io.read_point_cloud(scan_file).points, dtype=np.float64)
Expand Down
2 changes: 1 addition & 1 deletion python/kiss_icp/datasets/kitti.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __len__(self):
return len(self.scan_files)

def scans(self, idx):
return self.read_point_cloud(self.scan_files[idx])
return self.read_point_cloud(self.scan_files[idx]), np.array([])

def apply_calibration(self, poses: np.ndarray) -> np.ndarray:
"""Converts from Velodyne to Camera Frame"""
Expand Down
4 changes: 3 additions & 1 deletion python/kiss_icp/datasets/mcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import os
import sys

import numpy as np


class McapDataloader:
def __init__(self, data_dir: str, topic: str, *_, **__):
Expand Down Expand Up @@ -58,7 +60,7 @@ def __del__(self):
def __getitem__(self, idx):
msg = next(self.msgs).ros_msg
self.timestamps.append(self.stamp_to_sec(msg.header.stamp))
return self.read_point_cloud(msg)
return self.read_point_cloud(msg), np.array([])

def __len__(self):
return self.n_scans
Expand Down
4 changes: 3 additions & 1 deletion python/kiss_icp/datasets/nclt.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def __len__(self):
return len(self.scan_files)

def __getitem__(self, idx):
return self.read_point_cloud(os.path.join(self.scans_dir, self.scan_files[idx]))
return self.read_point_cloud(os.path.join(self.scans_dir, self.scan_files[idx])), np.array(
[]
)

def read_point_cloud(self, file_path: str):
def _convert(x_s, y_s, z_s):
Expand Down
2 changes: 1 addition & 1 deletion python/kiss_icp/datasets/nuscenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __len__(self):
return len(self.lidar_tokens)

def __getitem__(self, idx):
return self.read_point_cloud(self.lidar_tokens[idx])
return self.read_point_cloud(self.lidar_tokens[idx]), np.array([])

def read_point_cloud(self, token: str):
filename = self.nusc.get("sample_data", token)["filename"]
Expand Down
2 changes: 1 addition & 1 deletion python/kiss_icp/datasets/tum.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ def __getitem__(self, idx):
self.o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault
),
)
return np.array(pcd.points, dtype=np.float64)
return np.array(pcd.points, dtype=np.float64), np.array([])
12 changes: 1 addition & 11 deletions python/kiss_icp/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def run(self):
# Private interface ------
def _run_pipeline(self):
for idx in get_progress_bar(self._first, self._last):
raw_frame, timestamps = self._next(idx)
raw_frame, timestamps = self._dataset[idx]
start_time = time.perf_counter_ns()
source, keypoints = self.odometry.register_frame(raw_frame, timestamps)
self.poses[idx - self._first] = self.odometry.last_pose
Expand All @@ -114,16 +114,6 @@ def _run_pipeline(self):
self._vis_infos,
)

def _next(self, idx):
"""TODO: re-arrange this logic"""
dataframe = self._dataset[idx]
try:
frame, timestamps = dataframe
except ValueError:
frame = dataframe
timestamps = np.array([])
return frame, timestamps

@staticmethod
def save_poses_kitti_format(filename: str, poses: np.ndarray):
def _to_kitti_format(poses: np.ndarray) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion python/kiss_icp/tools/point_cloud2.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def read_point_cloud(msg: PointCloud2) -> Tuple[np.ndarray, np.ndarray]:
max_timestamp = np.max(timestamps)
timestamps = (timestamps - min_timestamp) / (max_timestamp - min_timestamp)
else:
timestamps = np.ones(points.shape[0])
timestamps = np.array([])
return points.astype(np.float64), timestamps


Expand Down

0 comments on commit be74a8e

Please sign in to comment.