mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-09 06:52:05 +08:00
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.
This commit is contained in:
@@ -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']
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user