mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 04:53:40 +08:00
can: fix off by one in learned message frequency (#3889)
This commit is contained in:
committed by
firestar5683
parent
4ba5fffeb3
commit
0d7981e02a
@@ -78,7 +78,7 @@ class MessageState:
|
||||
if self.frequency < 1e-5 and len(self.timestamps) >= 3:
|
||||
dt = (self.timestamps[-1] - self.timestamps[0]) * 1e-9
|
||||
if (dt > 1.0 or (self.timestamps.maxlen is not None and len(self.timestamps) >= self.timestamps.maxlen)) and dt != 0:
|
||||
self.frequency = min(len(self.timestamps) / dt, 100.0)
|
||||
self.frequency = min((len(self.timestamps) - 1) / dt, 100.0)
|
||||
self.timeout_threshold = (1_000_000_000 / self.frequency) * 10
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user