From 865948a00e0f2777aaa1eb6ee1f720474344b419 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sun, 1 Nov 2026 23:00:18 -0600 Subject: [PATCH] Preserve mixed HKG AOL after stock cruise disengages --- openpilot/selfdrive/selfdrived/selfdrived.py | 7 ++- .../aol/tests/test_hkg_cancel_joined.py | 52 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/openpilot/selfdrive/selfdrived/selfdrived.py b/openpilot/selfdrive/selfdrived/selfdrived.py index 2e15880257..ab11404e00 100755 --- a/openpilot/selfdrive/selfdrived/selfdrived.py +++ b/openpilot/selfdrive/selfdrived/selfdrived.py @@ -1408,9 +1408,14 @@ class SelfdriveD: if stock_lateral_role(self, CS, native, intent, allow_independent_cancel=True, allow_independent_brake=True, allow_independent_gas=True, now_ns=now_ns): user_disable = False + from opendbc.car.hyundai.blended_stock_aol import qualified as blended_stock_qualified if (user_disable and fresh_successor and proof[6] and not proof[7] and proof[8] and not proof[9] and decision.desired_lateral and not decision.desired_longitudinal and not decision.longitudinal_active and - not self.enabled and not self.active and self.CP.brand == 'toyota' and toyota_qualified(self.CP, marked_only=True) and + not self.enabled and not self.active and ( + self.CP.brand == 'toyota' and toyota_qualified(self.CP, marked_only=True) or + self.CP.brand == 'hyundai' and blended_stock_qualified(self.CP, marked_only=True) and + not physical_cancel(CS, self.CP) and not any(physical_cancel(sample, self.CP) + for sample, _ in getattr(self, 'car_state_samples', ()))) and CS.cruiseState.available and not CS.cruiseState.enabled and self.CS_prev.cruiseState.available and not self.CS_prev.cruiseState.enabled and all(valid and sample.cruiseState.available and not sample.cruiseState.enabled diff --git a/openpilot/starpilot/aol/tests/test_hkg_cancel_joined.py b/openpilot/starpilot/aol/tests/test_hkg_cancel_joined.py index 931e709f9a..d0fa464f86 100644 --- a/openpilot/starpilot/aol/tests/test_hkg_cancel_joined.py +++ b/openpilot/starpilot/aol/tests/test_hkg_cancel_joined.py @@ -787,3 +787,55 @@ def test_startup_native_wait_retains_fault_and_permission_checks(fault): assert axis.faultReason == 'critical' finally: case.doCleanups() + + +@pytest.mark.parametrize('topology', ('hdai', 'hdaii')) +@pytest.mark.parametrize('fault', ('none', 'native_denied', 'native_invalid', 'can_invalid', 'permanent_eps', + 'rx_fault', 'relay_fault', 'old_intent', 'cancel', 'wrong_gear')) +def test_mixed_stock_cruise_off_keeps_only_fresh_permitted_lateral(topology, fault): + from opendbc.car.hyundai.tests.test_palisade_2023 import params as blended_params + + with OpenpilotPrefix(): + case = caller_fixture.IoniqAvailabilityTests(methodName='runTest') + try: + cp = blended_params(topology) + sd, _, step, card, receive = case._ioniq_availability_callers(False, cp=cp) + axis, _, command = step(2, brake=True, native_request_lat=True, native_request_long=False) + assert axis.lateralActive and command.latActive + assert receive(10_020_000_000, axis=sd.pm.messages['aolAxisState'], event=sd.pm.messages['onroadEvents']) + prior = sd.aol_published_input_proof + now = 10_061_516_362 + assert now > prior[3] + observed = caller_fixture.car_state() + kwargs = {} + if fault == 'native_denied': + kwargs['allowed'] = False + elif fault == 'native_invalid': + kwargs['native_valid'] = False + elif fault == 'can_invalid': + observed.canValid = False + elif fault == 'permanent_eps': + observed.steerFaultPermanent = True + elif fault == 'rx_fault': + kwargs['panda_fault'] = True + elif fault == 'relay_fault': + kwargs['relay_fault'] = True + elif fault == 'old_intent': + kwargs['old_intent'] = True + elif fault == 'cancel': + observed.buttonEvents = [structs.CarState.ButtonEvent(type='cancel', pressed=True)] + elif fault == 'wrong_gear': + observed.gearShifter = 'unknown' + axis, state, command = step(6, offset_ns=1_516_362, observed_state=observed, + native_request_lat=True, native_request_long=False, **kwargs) + assert not command.longActive and not axis.longitudinalActive and not state.enabled + if fault == 'none': + assert axis.lateralActive and command.latActive + assert axis.sourceCarStateMonoTime == now and axis.validUntilMonoTime == now + 30_000_000 + assert str(axis.faultReason) == 'none' + assert receive(now, axis=sd.pm.messages['aolAxisState'], event=sd.pm.messages['onroadEvents']) + assert card.aol_card_intent.allowed_latch + else: + assert not axis.lateralActive and not command.latActive + finally: + case.doCleanups() diff --git a/prebuilt.json b/prebuilt.json index 5a4e9a0d53..ca7bbaff5b 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "7a5367f4e7de8fcfda84fcef36fd862b3431f5a23aa9bc84342442e73cd129ef", "schema_version": 1} +{"protected_inventory_sha256": "b1d97b7008d6b691c0ab1be89789b81b3a68217e1dfaa48c1bccdaef6532ae30", "schema_version": 1}