Skip to content

Commit

Permalink
count_events improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored and spektor56 committed Jun 29, 2022
1 parent 0dcd68d commit 442c0f1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion selfdrive/debug/count_events.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env python3
import sys
import math
import datetime
from collections import Counter
from pprint import pprint
from tqdm import tqdm
from typing import cast

from cereal.services import service_list
from tools.lib.route import Route
Expand All @@ -17,6 +20,8 @@
cams = [s for s in service_list if s.endswith('CameraState')]
cnt_cameras = dict.fromkeys(cams, 0)

start_time = math.inf
end_time = -math.inf
for q in tqdm(r.qlog_paths()):
if q is None:
continue
Expand All @@ -31,6 +36,10 @@
if not msg.valid:
cnt_valid[msg.which()] += 1

end_time = max(end_time, msg.logMonoTime)
start_time = min(start_time, msg.logMonoTime)

duration = (end_time - start_time) / 1e9

print("Events")
pprint(cnt_events)
Expand All @@ -42,4 +51,9 @@
print("\n")
print("Cameras")
for k, v in cnt_cameras.items():
print(" ", k.ljust(20), v)
s = service_list[k]
expected_frames = int(s.frequency * duration / cast(float, s.decimation))
print(" ", k.ljust(20), f"{v}, {v/expected_frames:.1%} of expected")

print("\n")
print("Route duration", datetime.timedelta(seconds=duration))

0 comments on commit 442c0f1

Please sign in to comment.