Skip to content

Commit

Permalink
output ouster timestamps in python pipeline (#235)
Browse files Browse the repository at this point in the history
* output ouster timestamps in python pipeline

* fix typo

---------

Co-authored-by: pbenet <pierre.benet@sbg-systems.com>
  • Loading branch information
pierrebenet and pbenet committed Oct 12, 2023
1 parent c4e980d commit ecb24f0
Showing 1 changed file with 9 additions and 7 deletions.
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

0 comments on commit ecb24f0

Please sign in to comment.