diff --git a/tools/longitudinal_maneuvers/generate_report.py b/tools/longitudinal_maneuvers/generate_report.py index 1592a97d65ec3b..88f78416b4c1c0 100755 --- a/tools/longitudinal_maneuvers/generate_report.py +++ b/tools/longitudinal_maneuvers/generate_report.py @@ -4,6 +4,7 @@ import io import os import pprint +from collections import defaultdict from pathlib import Path import matplotlib.pyplot as plt @@ -19,6 +20,7 @@ def report(platform, route, CP, maneuvers): output_path = Path(__file__).resolve().parent / "longitudinal_reports" output_fn = output_path / f"{platform}_{route.replace('/', '_')}.html" output_path.mkdir(exist_ok=True) + target_cross_times = defaultdict(list) with open(output_fn, "w") as f: f.write("

Longitudinal maneuver report

\n") f.write(f"

{platform}

\n") @@ -57,6 +59,8 @@ def report(platform, route, CP, maneuvers): if (0 < aTarget < cs.aEgo) or (0 > aTarget > cs.aEgo): f.write(f', crossed in {t:.3f}s') target_cross_time = t + if maneuver_valid: + target_cross_times[description].append(t) break else: f.write(', not crossed') @@ -101,6 +105,14 @@ def report(platform, route, CP, maneuvers): f.write(f"\n") f.write("\n") + f.write("

Summary

\n") + for description, runs in maneuvers: + times = target_cross_times[description] + f.write(f"

{description}

\n") + f.write(f"

Target crossed {len(times)} out of {len(runs)} runs

\n") + if len(times): + f.write(f"

Mean time to cross: {sum(times) / len(times):.3f}s, min: {min(times):.3f}s, max: {max(times):.3f}s

\n") + print(f"\nReport written to {output_fn}\n")