From 8eec2bcbc7ed436a35295e74b1cd86ff0417e0a2 Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Sat, 4 Jul 2026 19:41:52 +0800 Subject: [PATCH] fan/accel: gate accel logger on openpilotLongitudinalControl The accel logger only exists to inform accel-eq's max-accel tuning, and accel-eq only affects the car when OP has longitudinal control. On a stock-long car it was pointlessly logging the driver to a CSV (with periodic flash writes) for data that can never be applied. Skip logging entirely when not CP.openpilotLongitudinalControl. --- dragonpilot/selfdrive/controls/lib/accel_logger.py | 3 +++ .../selfdrive/controls/lib/tests/test_accel_logger.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dragonpilot/selfdrive/controls/lib/accel_logger.py b/dragonpilot/selfdrive/controls/lib/accel_logger.py index bb281f5d7..6bba9b918 100644 --- a/dragonpilot/selfdrive/controls/lib/accel_logger.py +++ b/dragonpilot/selfdrive/controls/lib/accel_logger.py @@ -55,6 +55,7 @@ class AccelLogger: def __init__(self, CP, path=None): self._CP = CP + self._enabled = CP.openpilotLongitudinalControl # accel-eq only applies under OP long self._path = path if path is not None else LOG_PATH self._buf = [] self._frames = 0 @@ -71,6 +72,8 @@ class AccelLogger: cloudlog.warning(f"AccelLogger: write failed (dropped {len(rows)} rows): {e}") def update(self, sm): + if not self._enabled: + return try: self._frames += 1 cs = sm['carState'] diff --git a/dragonpilot/selfdrive/controls/lib/tests/test_accel_logger.py b/dragonpilot/selfdrive/controls/lib/tests/test_accel_logger.py index 627d40824..7c5f98b67 100644 --- a/dragonpilot/selfdrive/controls/lib/tests/test_accel_logger.py +++ b/dragonpilot/selfdrive/controls/lib/tests/test_accel_logger.py @@ -26,7 +26,7 @@ def test_each_condition_blocks(): DRIVE = car.CarState.GearShifter.drive -CP = SimpleNamespace(steerRatio=15.0, wheelbase=2.7) +CP = SimpleNamespace(steerRatio=15.0, wheelbase=2.7, openpilotLongitudinalControl=True) def _sm(**over): cs = dict(vEgo=10.0, aEgo=0.8, gasPressed=True, brakePressed=False, @@ -51,6 +51,13 @@ def test_gate_blocks_dirty_sample(tmp_path): log.update(sm) assert log._buf == [] +def test_no_op_long_disables_logging(tmp_path): + # stock-long car: accel-eq is inert, so the logger must not run at all + stock_cp = SimpleNamespace(steerRatio=15.0, wheelbase=2.7, openpilotLongitudinalControl=False) + log = AccelLogger(stock_cp, path=str(tmp_path / "h.csv")) + log.update(_sm(vEgo=10.0, aEgo=0.8)) # would be a clean sample under OP long + assert log._buf == [] + def test_in_curve_sample_rejected_end_to_end(tmp_path): # large steering -> lateral accel exceeds LAT_ACCEL_MAX -> not buffered log = AccelLogger(CP, path=str(tmp_path / "h.csv"))