Preserve stopped Subaru AOL intent after brake release

This commit is contained in:
firestar5683
2026-11-20 07:49:06 -06:00
parent 6709d6743d
commit cb3bfc720b
5 changed files with 35 additions and 5 deletions
@@ -22,7 +22,7 @@ class StoppedIntentProof:
def stopped_state(cp, state):
return bool(cp.carFingerprint == CAR.SUBARU_IMPREZA_2020 and qualified(cp, marked_only=True) and
state.canValid and not state.canTimeout and state.standstill and state.brakePressed and
state.canValid and not state.canTimeout and state.standstill and state.vEgoRaw == 0. and
isfinite(state.vEgo) and isfinite(state.vEgoRaw) and
state.gearShifter == structs.CarState.GearShifter.drive and state.cruiseState.available and
not state.cruiseState.enabled and not state.gasPressed and not state.regenBraking and
@@ -48,7 +48,7 @@ def test_stopped_source_retains_original_intent_only_and_never_reanchors():
assert not retain_stopped_source(sd, state, intent, stamp, stamp + 30_000_000)
@pytest.mark.parametrize('fault', ('moving', 'brake', 'main', 'acc', 'gas', 'regen', 'can', 'timeout',
@pytest.mark.parametrize('fault', ('moving', 'wheel_speed', 'main', 'acc', 'gas', 'regen', 'can', 'timeout',
'eps', 'permanent', 'door', 'belt', 'sensors', 'driver_off', 'cancel', 'reverse', 'epoch', 'producer',
'integrity', 'drain', 'future_pair', 'queue', 'critical', 'active_lat', 'desired_lat', 'active_long',
'desired_long', 'enabled', 'authority_lost', 'new_state', 'off', 'settings', 'pause', 'raw_epoch',
@@ -56,7 +56,7 @@ def test_stopped_source_retains_original_intent_only_and_never_reanchors():
'native_long', 'native_inventory', 'native_session', 'hard_event', 'user_off', 'no_history'))
def test_stopped_source_independent_vetoes_remain_authoritative(fault):
sd, state, intent, stamp, _, native = source_case()
physical = {'moving': ('standstill', False), 'brake': ('brakePressed', False), 'gas': ('gasPressed', True),
physical = {'moving': ('standstill', False), 'wheel_speed': ('vEgoRaw', 0.1), 'gas': ('gasPressed', True),
'regen': ('regenBraking', True), 'can': ('canValid', False), 'timeout': ('canTimeout', True),
'eps': ('steerFaultTemporary', True), 'permanent': ('steerFaultPermanent', True), 'door': ('doorOpen', True),
'belt': ('seatbeltUnlatched', True), 'sensors': ('vehicleSensorsInvalid', True), 'driver_off': ('steeringDisengage', True)}
@@ -379,3 +379,18 @@ def test_subaru_temporary_intent_depends_on_accepted_proof_not_actuation_phase(
latched=True, producer=PRODUCER)
assert retained == (current_role != 'active' or native_granted)
assert (leases(feedback), feedback.signature, sm['aolAxisState'].to_dict()) == before
@pytest.mark.parametrize('brake_pressed', (False, True))
def test_stopped_source_proof_depends_on_zero_wheel_speed_not_brake(brake_pressed):
sd, state, intent, stamp, feedback, _ = source_case()
state.brakePressed = brake_pressed
record_stopped_intent(sd, state, sd.sm.messages['aolAxisState'], stamp)
proof = sd.aol_stopped_intent_proof
assert proof is not None
before = leases(feedback), feedback.signature, intent.validUntilMonoTime, sd.aol_axis_decision
for age in (30_000_001, 35_000_000, 100_000_000, 190_000_000):
assert retain_stopped_source(sd, state, intent, stamp, stamp + age)
assert sd.aol_stopped_intent_proof is proof
assert (leases(feedback), feedback.signature, intent.validUntilMonoTime, sd.aol_axis_decision) == before
assert not retain_stopped_source(sd, state, intent, stamp, stamp + 200_000_001)
@@ -102,6 +102,8 @@ def test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(candidate,
temporary = not guard_brake_release and 225 <= tick < 260
main = not 310 <= tick < 350 and (tick >= 30 or not main_only)
stopped = stop_resume and (125 <= tick < 135 if hard_stop_native_first or host_first_stop or stop_creep_eps else 185 <= tick < 195)
if stopped_source_gap == 2 and stopped:
brake = elapsed < 130
if stop_creep_eps:
stopped = tick < 135 and (cold_stop or tick >= 125)
brake = bool(stopped and tick < 129)
@@ -285,7 +287,8 @@ def test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(candidate,
expired, _ = controls.state_control()
assert not expired.latActive and not expired.longActive
driven_new = selfdrive_step(sd, published, new_native, previous_controls, cp, safety, now, calibration='calibrated',
source_timeout=source_missing or stopped_source_gap and 130 <= elapsed <= 133)
source_timeout=source_missing or stopped_source_gap and
(166 <= elapsed <= 169 if stopped_source_gap == 2 else 130 <= elapsed <= 133))
if deadline_gap and elapsed == gap_tick:
current = driven_new['aolAxisState'].aolAxisState
assert current.lateralActive and not sd.aol_authority_lost, 'SUBARU_FRESH_SUCCESSOR_LOST_LATERAL'
@@ -732,3 +735,14 @@ def test_actual_subaru_stop_creep_restriction_preserves_armed_intent(
CAR.SUBARU_IMPREZA_2025, CAR.SUBARU_FORESTER, CAR.SUBARU_OUTBACK, CAR.SUBARU_OUTBACK_2023))
def test_actual_subaru_family_stop_creep_restriction(candidate, subaru_native_pair, tmp_path):
test_actual_subaru_stop_creep_restriction_preserves_armed_intent(subaru_native_pair, tmp_path, 2, False, candidate=candidate)
def test_actual_stopped_brake_release_source_gap_keeps_armed_intent(subaru_native_pair, tmp_path):
test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(
CAR.SUBARU_IMPREZA_2020, subaru_native_pair, tmp_path, main_only=True,
stop_resume=True, hard_stop_native_first=True, stopped_source_gap=2)
rows = json.loads((tmp_path / (str(CAR.SUBARU_IMPREZA_2020) + '-True-actual.json')).read_text())
paused = [row for row in rows if 166 <= row['elapsed'] <= 170]
assert any(row['fault'] == 'availabilityPause' for row in paused)
assert all(row['cardLatch'] and row['armed'] and not row['lat'] and not row['long'] and row['permission'] == 0 for row in paused)
assert all('controlsMismatch' not in row['events'] for row in rows)
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "60c2ed541f431f2f22c64ab995f02028caa9ccfb2c0a8e4c8246d4b2d426fc2b", "schema_version": 1}
{"protected_inventory_sha256": "2d7c1fdad31a4a13ccceac06a49a027af628f97d656b059b4e734556e8f70104", "schema_version": 1}
+1
View File
@@ -279,6 +279,7 @@ RELEASE_TARGETS = (
"openpilot/starpilot/car/subaru/tests/test_stock_aol_callers.py::test_actual_main_during_temporary_eps_waits_for_clear",
"openpilot/starpilot/car/subaru/tests/test_stock_aol_callers.py::test_actual_stopped_feedback_gap_retains_only_armed_intent",
"openpilot/starpilot/car/subaru/tests/test_stock_aol_callers.py::test_actual_stopped_source_gap_retains_intent_without_renewing_output",
"openpilot/starpilot/car/subaru/tests/test_stock_aol_callers.py::test_actual_stopped_brake_release_source_gap_keeps_armed_intent",
"openpilot/starpilot/car/subaru/tests/test_stock_aol_callers.py::test_actual_paused_subaru_restriction_keeps_armed_intent",
"openpilot/starpilot/car/subaru/tests/test_stock_aol_callers.py::test_actual_subaru_eps_clear_during_blinker_pause_keeps_armed_intent",
"openpilot/starpilot/car/subaru/tests/test_stock_aol_callers.py::test_actual_subaru_family_eps_recovery_join",