From 1f06ce685c1aba68d37b5967c4a04dbfa4a936f6 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sun, 22 Nov 2026 14:49:21 -0600 Subject: [PATCH] Restore Niro EV AOL with camera-SCC Alpha Long --- .../opendbc/car/hyundai/canfd_stock_aol.py | 4 +- .../tests/test_ioniq5_camera_long_aol.py | 44 +++++++++++++------ prebuilt.json | 2 +- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/canfd_stock_aol.py b/opendbc_repo/opendbc/car/hyundai/canfd_stock_aol.py index ed80ad0332..1e928b44c3 100644 --- a/opendbc_repo/opendbc/car/hyundai/canfd_stock_aol.py +++ b/opendbc_repo/opendbc/car/hyundai/canfd_stock_aol.py @@ -120,7 +120,7 @@ CCNC_LONG_AOL_WORDS = frozenset((0x0C0C, 0x0C0E, 0x0C2C, 0x0C2E)) LONG_EV_CARS = frozenset((CAR.HYUNDAI_IONIQ_5, CAR.HYUNDAI_KONA_EV_2ND_GEN)) LONG_AOL_WORDS |= CCNC_LONG_AOL_WORDS INDEPENDENT_LONG_BUTTON_CARS = LONG_EV_CARS | CCNC_LONG_CARS | { - CAR.KIA_EV6, CAR.HYUNDAI_IONIQ_6, CAR.GENESIS_GV70_ELECTRIFIED_1ST_GEN, + CAR.KIA_EV6, CAR.KIA_NIRO_EV_2ND_GEN, CAR.HYUNDAI_IONIQ_6, CAR.GENESIS_GV70_ELECTRIFIED_1ST_GEN, CAR.GENESIS_GV60_EV_1ST_GEN, CAR.KIA_SPORTAGE_5TH_GEN, CAR.KIA_CARNIVAL_2025, } @@ -136,7 +136,7 @@ def qualified_long(cp, *, marked_only=False): if not eligible(cp): return False word = _base_word(cp, experiences=(0, 32)) - if cp.carFingerprint in (CAR.KIA_EV6, CAR.GENESIS_GV60_EV_1ST_GEN, CAR.HYUNDAI_IONIQ_6): + if cp.carFingerprint in (CAR.KIA_EV6, CAR.KIA_NIRO_EV_2ND_GEN, CAR.GENESIS_GV60_EV_1ST_GEN, CAR.HYUNDAI_IONIQ_6): if word != 0x09: return False elif cp.carFingerprint in CCNC_LONG_CARS: diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq5_camera_long_aol.py b/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq5_camera_long_aol.py index 6b00aad0d2..27f38795f3 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq5_camera_long_aol.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq5_camera_long_aol.py @@ -8,12 +8,15 @@ from opendbc.car.hyundai.values import CAR, HyundaiFlags from openpilot.starpilot.car.hyundai.aol import independent_cruise_buttons_supported, native_accepts_cp, policy_for -def camera_long(offset, alpha=True): +CAMERA_LONG_CARS = (CAR.HYUNDAI_IONIQ_5, CAR.KIA_NIRO_EV_2ND_GEN) + + +def camera_long(offset, alpha=True, *, identity=CAR.HYUNDAI_IONIQ_5): fp = gen_empty_fingerprint() fp[offset].update({0x1CF: 8, 0x35: 32, 0x175: 24, 0xA0: 24, 0xEA: 24, 0x1BA: 24, 0x1E5: 16}) fp[offset + 2].update({0x12A: 16, 0x1A0: 32}) fp[offset + 1].update({0x110: 32, 0x100: 24}) - cp = CarInterface.get_params(CAR.HYUNDAI_IONIQ_5, fp, [], alpha, False, False) + cp = CarInterface.get_params(identity, fp, [], alpha, False, False) assert cp.openpilotLongitudinalControl and not cp.pcmCruise assert cp.flags & HyundaiFlags.CANFD_CAMERA_SCC assert not cp.flags & HyundaiFlags.CANFD_LKA_STEER_MSG @@ -23,8 +26,9 @@ def camera_long(offset, alpha=True): @pytest.mark.parametrize('offset', [0, 4]) -def test_factory_ioniq5_camera_long_uses_existing_paired_axis_profile(offset): - cp = camera_long(offset) +@pytest.mark.parametrize('identity', CAMERA_LONG_CARS) +def test_factory_camera_long_uses_existing_paired_axis_profile(identity, offset): + cp = camera_long(offset, identity=identity) before = cp.to_dict() assert qualified_long(cp) assert independent_cruise_buttons_supported(cp) @@ -44,9 +48,10 @@ def test_factory_ioniq5_camera_long_uses_existing_paired_axis_profile(offset): @pytest.mark.parametrize('offset', [0, 4]) -@pytest.mark.parametrize('mutation', ['alternate_buttons', 'unknown_word', 'wrong_experience', 'passive', 'angle']) -def test_camera_long_extension_keeps_unrecognized_contracts_closed(offset, mutation): - cp = camera_long(offset) +@pytest.mark.parametrize('mutation', ['alternate_buttons', 'unknown_word', 'wrong_experience', 'passive', 'angle', 'hda2']) +@pytest.mark.parametrize('identity', CAMERA_LONG_CARS) +def test_camera_long_extension_keeps_unrecognized_contracts_closed(identity, offset, mutation): + cp = camera_long(offset, identity=identity) owner = config_index(cp) cp.safetyConfigs[owner].safetyParam = 0x80D cp.alternativeExperience = 32 @@ -59,18 +64,22 @@ def test_camera_long_extension_keeps_unrecognized_contracts_closed(offset, mutat cp.alternativeExperience = 0 elif mutation == 'passive': cp.passive = True - else: + elif mutation == 'angle': cp.flags |= int(HyundaiFlags.CANFD_ANGLE_STEERING) - assert not qualified_long(cp, marked_only=True) + elif mutation == 'hda2': + cp.flags = (cp.flags & ~int(HyundaiFlags.CANFD_CAMERA_SCC)) | int(HyundaiFlags.CANFD_LKA_STEER_MSG) + cp.safetyConfigs[owner].safetyParam = 0x815 + assert qualified_long(cp, marked_only=True) == (mutation == 'hda2' and identity == CAR.HYUNDAI_IONIQ_5) @pytest.mark.parametrize('offset', [0, 4]) @pytest.mark.parametrize('button', ['lkas', 'mainCruise']) -def test_default_physical_button_arms_and_brake_cancel_keep_intent(offset, button): +@pytest.mark.parametrize('identity', CAMERA_LONG_CARS) +def test_default_physical_button_arms_and_brake_cancel_keep_intent(identity, offset, button): from openpilot.starpilot.aol.intent import AolSettings from openpilot.starpilot.car.hyundai.aol import create_intent - cp = camera_long(offset) + cp = camera_long(offset, identity=identity) cp.safetyConfigs[config_index(cp)].safetyParam = 0x80D cp.alternativeExperience = 32 settings = AolSettings(enabled=True, pause_brake_mps=0.0, lkas_action=0, main_action=0, @@ -96,7 +105,7 @@ def test_default_physical_button_arms_and_brake_cancel_keep_intent(offset, butto assert not intent.output(cs)[0] -@pytest.mark.parametrize('identity', [CAR.HYUNDAI_KONA_EV_2ND_GEN, CAR.HYUNDAI_IONIQ_5_N, CAR.KIA_NIRO_EV_2ND_GEN]) +@pytest.mark.parametrize('identity', [CAR.HYUNDAI_KONA_EV_2ND_GEN, CAR.HYUNDAI_IONIQ_5_N, CAR.KIA_NIRO_HEV_2ND_GEN]) def test_camera_extension_does_not_admit_unqualified_identities(identity): cp = camera_long(0) cp.carFingerprint = identity @@ -108,15 +117,17 @@ def test_camera_extension_does_not_admit_unqualified_identities(identity): @pytest.mark.parametrize('offset', [0, 4]) @pytest.mark.parametrize('enabled', [False, True]) -def test_actual_card_marks_camera_owner_with_recorded_default_buttons(offset, enabled): +@pytest.mark.parametrize('identity', CAMERA_LONG_CARS) +def test_actual_card_marks_camera_owner_with_recorded_default_buttons(identity, offset, enabled): import os from unittest.mock import patch from opendbc.car.hyundai.radar_interface import RadarInterface from openpilot.common.params import Params from openpilot.common.prefix import OpenpilotPrefix from openpilot.selfdrive.car.card import Car + from openpilot.starpilot.ui.feature_settings_owner import FeatureSettingsOwner - cp = camera_long(offset) + cp = camera_long(offset, identity=identity) with OpenpilotPrefix(), patch.dict(os.environ, {'SIMULATION': '1'}): saved = Params() saved.put_bool('OpenpilotEnabledToggle', True, block=True) @@ -135,6 +146,11 @@ def test_actual_card_marks_camera_owner_with_recorded_default_buttons(offset, en assert qualified_long(published, marked_only=enabled) assert config_index(published) == offset // 4 assert not CarInterface.startup_required(published) + features = FeatureSettingsOwner(saved, lambda _: True, vehicle_fingerprint=lambda: str(published.carFingerprint), + vehicle_params=lambda: published) + page = features.snapshot('wheel', parked=True, system_long=True, lateral_context=True, metric=False) + row = next(row for row in page.rows if row.key == 'wheel:LKASButtonControl') + assert 'Toggle AOL' in row.choices assert card.aol_qualified == enabled if enabled: assert card.aol_card_intent.explicit_latch and card.aol_card_intent.independent_cruise_buttons diff --git a/prebuilt.json b/prebuilt.json index e22d317c30..c9f801f15d 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "914d15f852c2e21345bc31ea7e4e14964e85feacda3086e019c0e4fc7f058e36", "schema_version": 1} +{"protected_inventory_sha256": "c61d9a08fa10e89ab804cdbf11415b69b151758302da50d613c93e5a2c57bf60", "schema_version": 1}