Skip to content

Commit 50f535d

Browse files
authored
Fix timestamp offset bug in BLFWriter
In the BLF files, the frame timestamp are stored as a delta from the "start time". The "start time" stored in the file is the first frame timestamp rounded to 3 decimals. When we calculate the timestamp delta for each frame, we were previously calculating it using the non-rounded "start time". This new code, use the "start time" as the first frame timestamp truncated to 3 decimals.
1 parent 2bd4758 commit 50f535d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

can/io/blf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def _add_object(self, obj_type, data, timestamp=None):
530530
if timestamp is None:
531531
timestamp = self.stop_timestamp or time.time()
532532
if self.start_timestamp is None:
533-
self.start_timestamp = timestamp
533+
self.start_timestamp = int(timestamp * 1000) / 1000
534534
self.stop_timestamp = timestamp
535535
timestamp = int((timestamp - self.start_timestamp) * 1e9)
536536
header_size = OBJ_HEADER_BASE_STRUCT.size + OBJ_HEADER_V1_STRUCT.size

0 commit comments

Comments
 (0)