Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamps - KITTI, Rosbag #120

Merged
merged 9 commits into from
Apr 5, 2023
Merged
5 changes: 5 additions & 0 deletions python/kiss_icp/datasets/kitti.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def _lidar_pose_gt(poses_gt):
poses = poses.reshape((n, 4, 4)) # [N, 4, 4]
return _lidar_pose_gt(poses)

def get_frames_timestamps(self) -> np.ndarray:
timestamps = np.loadtxt(os.path.join(self.kitti_sequence_dir, "times.txt")).reshape(-1, 1)
return timestamps

@staticmethod
def read_calib_file(file_path: str) -> dict:
calib_dict = {}
Expand All @@ -102,3 +106,4 @@ def read_calib_file(file_path: str) -> dict:
key = tokens[0][:-1]
calib_dict[key] = values
return calib_dict
nachovizzo marked this conversation as resolved.
Show resolved Hide resolved

7 changes: 6 additions & 1 deletion python/kiss_icp/datasets/rosbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, data_dir: Path, topic: str, *_, **__):
# Get an iterable
self.n_scans = self.bag.get_message_count(topic_filters=self.topic)
self.msgs = self.bag.read_messages(topics=[self.topic])
self.timestamps = []

# Visualization Options
self.use_global_visualizer = True
Expand All @@ -55,8 +56,12 @@ def __len__(self):

def __getitem__(self, idx):
# TODO: implemnt [idx], expose field_names
nachovizzo marked this conversation as resolved.
Show resolved Hide resolved
_, msg, _ = next(self.msgs)
_, msg, time = next(self.msgs)
self.timestamps.append(time.to_sec())
return self.read_point_cloud(msg)

def get_frames_timestamps(self) -> list:
return self.timestamps

def check_topic(self, topic: str) -> str:
# when user specified the topic don't check
Expand Down