From 81c26d893adc72d6bca6d5db7a44b03694210ede Mon Sep 17 00:00:00 2001 From: Dom <168790843+firestar5683@users.noreply.github.com> Date: Wed, 18 Nov 2026 15:05:59 -0600 Subject: [PATCH] Retain Honda stock ACC AOL through bounded EPS recovery --- openpilot/starpilot/aol/temporary_steering.py | 7 ++- .../aol/tests/test_honda_eps_recovery_join.py | 53 +++++++++++++++++++ .../tests/test_honda_recovery_lifecycle.py | 17 ++++++ prebuilt.json | 2 +- 4 files changed, 76 insertions(+), 3 deletions(-) diff --git a/openpilot/starpilot/aol/temporary_steering.py b/openpilot/starpilot/aol/temporary_steering.py index 9f8d0fa2c3..58e5b34ac7 100644 --- a/openpilot/starpilot/aol/temporary_steering.py +++ b/openpilot/starpilot/aol/temporary_steering.py @@ -216,7 +216,7 @@ def honda_eps_recovery_intent_current(self, sm, cp, cs, axis, stamp, now_ns, *, """ from opendbc.car.honda.stock_aol import qualified from opendbc.car import structs - from openpilot.starpilot.aol.transport_pause import _configured_transport_native + from openpilot.starpilot.aol.transport_pause import _configured_transport_native, stock_lateral_user_event source = getattr(self, 'honda_eps_source_ns', 0) previous = self.signature @@ -244,7 +244,7 @@ def honda_eps_recovery_intent_current(self, sm, cp, cs, axis, stamp, now_ns, *, previous[14:16] != (producer, self.availability_epoch) or not cs.canValid or cs.canTimeout or (cs.steerFaultTemporary and not axis.desiredLateral) or cs.steerFaultPermanent or cs.accFaulted or cs.doorOpen or cs.seatbeltUnlatched or cs.vehicleSensorsInvalid or cs.steeringDisengage or - (cs.brakePressed and not cs.steerFaultTemporary) or cs.regenBraking or cs.buttonEvents or not cs.cruiseState.available or cs.cruiseState.enabled or + (cs.brakePressed and not cs.steerFaultTemporary) or cs.regenBraking or cs.buttonEvents or not cs.cruiseState.available or cs.cruiseState.enabled and not cp.pcmCruise or cs.gearShifter not in (structs.CarState.GearShifter.drive, structs.CarState.GearShifter.sport, structs.CarState.GearShifter.low, structs.CarState.GearShifter.brake) or str(axis.faultReason) != 'none' or @@ -261,7 +261,9 @@ def honda_eps_recovery_intent_current(self, sm, cp, cs, axis, stamp, now_ns, *, event_ns = int(sm.logMonoTime['onroadEvents']) brake_release = bool(known_eps and not cs.brakePressed and event_ns == self.temporary_eps_event_ns == getattr(self, 'honda_eps_brake_event_ns', 0)) + stock_user = stock_lateral_user_event(cp) if not cs.cruiseState.enabled else None events = tuple(e for e in sm['onroadEvents'] if not ( + e.name == stock_user and e.userDisable and not e.softDisable and not e.immediateDisable) and not ( (cs.steerFaultTemporary and cs.brakePressed or brake_release) and e.name == log.OnroadEvent.EventName.pedalPressed and e.userDisable and not e.softDisable and not e.immediateDisable)) @@ -283,3 +285,4 @@ def honda_eps_recovery_intent_current(self, sm, cp, cs, axis, stamp, now_ns, *, if cs.steerFaultTemporary and cs.brakePressed: self.honda_eps_brake_event_ns = event_ns return retained + diff --git a/openpilot/starpilot/aol/tests/test_honda_eps_recovery_join.py b/openpilot/starpilot/aol/tests/test_honda_eps_recovery_join.py index dfd62375ac..dfb85c826b 100644 --- a/openpilot/starpilot/aol/tests/test_honda_eps_recovery_join.py +++ b/openpilot/starpilot/aol/tests/test_honda_eps_recovery_join.py @@ -303,3 +303,56 @@ def test_new_eps_episode_uses_its_new_actual_active_predecessor(): assert not observe(case, stamp + 10_000_000) assert feedback.honda_eps_source_ns == NOW assert not output(state, native).lateral_active + + + +def stock_acc_recovery_case(identity='HONDA_CIVIC_BOSCH', cruise_enabled=False): + from opendbc.car.honda.tests.test_stock_aol import final_cp + from opendbc.car.honda.values import CAR + from openpilot.starpilot.aol.transport_pause import TransportPauseFeedback + from openpilot.starpilot.tests.test_ford_reverse_intent import sample + + cp = final_cp(getattr(CAR, identity)) + cp.alternativeExperience = 32 + state = structs.CarState(canValid=True, gearShifter='drive', vEgo=15.) + state.cruiseState.available = True + state.cruiseState.enabled = cruise_enabled + feedback = TransportPauseFeedback(cp) + sm, _ = sample(cp, NOW, NOW, 1) + change(sm, 'onroadEvents', lambda events: setattr(events[0], 'userDisable', False)) + assert not feedback.observe(sm, cp, state, NOW, latched=True, intent_producer_session=PRODUCER) + assert feedback.lateral_only_baseline + stamp = NOW + 10_000_000 + state.steerFaultTemporary = state.steeringPressed = True + sm, native = eps_sample(cp, stamp, withdrawn=True) + event = sm.messages['onroadEvents'].as_builder() + if not cruise_enabled: + event.onroadEvents = [*(e.to_dict() for e in event.onroadEvents), {'name': 'cruiseDisabled', 'userDisable': True}] + sm.messages['onroadEvents'] = event.as_reader() + assert not feedback.observe(sm, cp, state, stamp, latched=True, intent_producer_session=PRODUCER) + state.steerFaultTemporary = False + return cp, state, feedback, sm, native, stamp + + +@pytest.mark.parametrize('identity', ['HONDA_CIVIC_BOSCH', 'HONDA_CIVIC', 'HONDA_CIVIC_2022', 'HONDA_CRV_6G']) +@pytest.mark.parametrize('cruise_enabled', [False, True]) +def test_stock_acc_eps_recovery_uses_lateral_owner_event_policy(identity, cruise_enabled): + cp, state, feedback, sm, native, stamp = stock_acc_recovery_case(identity, cruise_enabled) + lease = feedback.lateral_source_ns, feedback.lateral_native_ns, feedback.honda_eps_source_ns + assert not feedback.observe(sm, cp, state, stamp + 10_000_000, latched=True, intent_producer_session=PRODUCER) + assert not feedback.failed and not output(state, native).lateral_active + assert lease == (feedback.lateral_source_ns, feedback.lateral_native_ns, feedback.honda_eps_source_ns) + event = sm.messages['onroadEvents'].as_builder() + event.onroadEvents = [*(e.to_dict() for e in event.onroadEvents), {'name': 'buttonCancel', 'userDisable': True}] + sm.messages['onroadEvents'] = event.as_reader() + assert feedback.observe(sm, cp, state, stamp + 20_000_000, latched=True, intent_producer_session=PRODUCER) + + +@pytest.mark.parametrize('flag', ['softDisable', 'immediateDisable']) +def test_stock_cruise_disabled_fault_flags_remain_authoritative(flag): + case = stock_acc_recovery_case() + _, _, _, sm, _, stamp = case + event = sm.messages['onroadEvents'].as_builder() + event.onroadEvents = [{'name': 'cruiseDisabled', 'userDisable': True, flag: True}] + sm.messages['onroadEvents'] = event.as_reader() + assert observe(case, stamp + 10_000_000) diff --git a/openpilot/starpilot/aol/tests/test_honda_recovery_lifecycle.py b/openpilot/starpilot/aol/tests/test_honda_recovery_lifecycle.py index fa41118885..4ff8fc87bd 100644 --- a/openpilot/starpilot/aol/tests/test_honda_recovery_lifecycle.py +++ b/openpilot/starpilot/aol/tests/test_honda_recovery_lifecycle.py @@ -70,6 +70,22 @@ class TestHondaCurrentCaller(unittest.TestCase): self.run_current_caller(candidate=CAR.HONDA_CIVIC_2022, word=10, alpha=True, hybrid=True, eps_pedal='brake', eps_end=82, eps_repeat=(85, 88)) + def test_classic_stock_repeated_eps_with_gas_before_native_refresh(self): + self.run_current_caller(candidate=CAR.HONDA_CIVIC_BOSCH, word=0, + eps_pedal='gas', eps_end=82, eps_repeat=(85, 88)) + + def test_classic_stock_repeated_eps_with_brake_before_native_refresh(self): + self.run_current_caller(candidate=CAR.HONDA_CIVIC_BOSCH, word=0, + eps_pedal='brake', eps_end=82, eps_repeat=(85, 88)) + + def test_nidec_stock_repeated_eps_with_gas_before_native_refresh(self): + self.run_current_caller(candidate=CAR.HONDA_CIVIC, word=0, + eps_pedal='gas', eps_end=82, eps_repeat=(85, 88)) + + def test_nidec_stock_repeated_eps_with_brake_before_native_refresh(self): + self.run_current_caller(candidate=CAR.HONDA_CIVIC, word=0, + eps_pedal='brake', eps_end=82, eps_repeat=(85, 88)) + def test_diagnostic_during_recovered_reverse(self): self.run_current_caller(candidate=CAR.HONDA_CIVIC_BOSCH, word=0, fault='diagnostic') @@ -487,3 +503,4 @@ class TestHondaCurrentCaller(unittest.TestCase): finally: pandad.close() card.vehicle_startup.close() + diff --git a/prebuilt.json b/prebuilt.json index edef7ebe2f..fde6ea7de6 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "ee565fd6b1a3a5a466ef547d744b9bbaa7aad11c3b5d4a8b1274a85739ad6193", "schema_version": 1} +{"protected_inventory_sha256": "23a54aad6c2abd9da8d06dfc0619f1c25b0d6b0ef290c00d41b9c6058e0ea1e6", "schema_version": 1}