openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

#!/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
from tools.lib.logreader import LogReader
if __name__ == "__main__":
r = Route(sys.argv[1])
4 years ago
cnt_valid: Counter = Counter()
cnt_events: Counter = Counter()
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
4 years ago
lr = list(LogReader(q))
for msg in lr:
if msg.which() == 'carEvents':
for e in msg.carEvents:
cnt_events[e.name] += 1
elif msg.which() in cams:
cnt_cameras[msg.which()] += 1
4 years ago
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
4 years ago
print("Events")
pprint(cnt_events)
print("\n")
4 years ago
print("Not valid")
pprint(cnt_valid)
print("\n")
print("Cameras")
for k, v in cnt_cameras.items():
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))