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

output ouster timestamps in python pipeline #235

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions python/kiss_icp/datasets/ouster.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ def __init__(
self._scans_num = sum((1 for _ in client.Scans(self._source)))
print(f"Ouster pcap total scans number: {self._scans_num}")

# cached timestamps array
self._timestamps = np.empty(0)
self._timestamps_initialized = False
# frame timestamps array
self._timestamps = np.linspace(0, self._scans_num, self._scans_num, endpoint=False)

# start Scans iterator for consumption in __getitem__
self._source = pcap.Pcap(self._pcap_file, self._info)
Expand All @@ -139,16 +138,19 @@ def __getitem__(self, idx):
scan = next(self._scans_iter)
self._next_idx += 1

if not self._timestamps_initialized:
self._timestamps = np.tile(np.linspace(0, 1.0, scan.w, endpoint=False), (scan.h, 1))
self._timestamps_initialized = True
self._timestamps[self._next_idx - 1] = 1e-9 * scan.timestamp[0]

timestamps = np.tile(np.linspace(0, 1.0, scan.w, endpoint=False), (scan.h, 1))

# filtering our zero returns makes it substantially faster for kiss-icp
sel_flag = scan.field(self._client.ChanField.RANGE) != 0
xyz = self._xyz_lut(scan)[sel_flag]
timestamps = self._timestamps[sel_flag]
timestamps = timestamps[sel_flag]

return xyz, timestamps

def get_frames_timestamps(self):
return self._timestamps

def __len__(self):
return self._scans_num