Script to check for lags in message reception

old-commit-hash: dd676f3236
This commit is contained in:
Willem Melching 2020-03-20 16:35:23 -07:00
parent 1f461cd205
commit 1272a95e9b
1 changed files with 26 additions and 0 deletions

26
selfdrive/debug/check_lag.py Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import cereal.messaging as messaging
from cereal.services import service_list
TO_CHECK = ['carState']
if __name__ == "__main__":
sm = messaging.SubMaster(TO_CHECK)
prev_t = {}
while True:
sm.update()
for s in TO_CHECK:
if sm.updated[s]:
t = sm.logMonoTime[s] / 1e9
if s in prev_t:
expected = 1.0 / (service_list[s].frequency)
dt = t - prev_t[s]
if dt > 10 * expected:
print(t, s, dt)
prev_t[s] = t