From 2064eb078f80cfac33f2eeaecdaec7b94f1e59f0 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:56:49 -0600 Subject: [PATCH] Show Hyundai lateral activity independently of cruise engagement --- .../opendbc/car/hyundai/canfd_dash_icons.py | 2 +- .../hyundai/tests/test_classic_aol_dash.py | 21 ++++++++- .../hyundai/tests/test_ioniq6_dash_icons.py | 43 ++++++++++++++++++- .../car/hyundai/tests/test_torque_ev_scc.py | 2 +- prebuilt.json | 2 +- tools/ci/run_vehicle_tests.py | 2 + 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/canfd_dash_icons.py b/opendbc_repo/opendbc/car/hyundai/canfd_dash_icons.py index 80a6e4a8de..86ff212fb2 100644 --- a/opendbc_repo/opendbc/car/hyundai/canfd_dash_icons.py +++ b/opendbc_repo/opendbc/car/hyundai/canfd_dash_icons.py @@ -16,4 +16,4 @@ class CanFDDashIcons: self.disengage_frame = frame blinking = self.disengaging and (frame - self.disengage_frame) * DT_CTRL < 1.0 self.previous_lateral = lateral_active - return 2 if enabled or lateral_active else 3 if blinking else 0 + return 2 if lateral_active else 3 if blinking else 0 diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_classic_aol_dash.py b/opendbc_repo/opendbc/car/hyundai/tests/test_classic_aol_dash.py index e23b75d82e..81c23bce63 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_classic_aol_dash.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_classic_aol_dash.py @@ -75,9 +75,11 @@ def test_qualified_classic_stock_icons_follow_actual_lateral_and_original_blink( @pytest.mark.parametrize('marked', [False, True]) @pytest.mark.parametrize('enabled,lateral,lkas,lfa', [(False, False, 1, 0), (True, False, 2, 2), (True, True, 2, 2)]) -def test_existing_ordinary_and_inactive_dash_behavior_is_preserved(marked, enabled, lateral, lkas, lfa): +def test_icons_follow_lateral_when_marked_and_keep_unmarked_cruise_display(marked, enabled, lateral, lkas, lfa): ci, parser = controller(marked=marked) step(ci, parser, enabled=enabled, lateral=lateral) + if marked and not lateral: + lkas, lfa = 1, 0 assert parser.vl['LKAS11']['CF_Lkas_FcwOpt_USM'] == lkas assert parser.vl['LFAHDA_MFC']['LFA_Icon_State'] == lfa @@ -87,3 +89,20 @@ def test_unmarked_configuration_does_not_gain_lateral_only_icon_override(): step(ci, parser, lateral=True) assert parser.vl['LKAS11']['CF_Lkas_FcwOpt_USM'] == 1 assert parser.vl['LFAHDA_MFC']['LFA_Icon_State'] == 0 + + +@pytest.mark.parametrize('identity', [CAR.HYUNDAI_SONATA_HYBRID, CAR.HYUNDAI_SONATA, + CAR.HYUNDAI_ELANTRA_2021, CAR.HYUNDAI_KONA_EV]) +def test_cruise_stays_engaged_after_lateral_icon_disengages(identity): + ci, parser = controller(identity) + original = ci.CP.to_dict() + for frame in range(135): + lateral = frame < 5 or frame >= 125 + _, packets = step(ci, parser, enabled=True, lateral=lateral) + expected = 2 if lateral else 3 if frame < 104 else 0 + assert parser.vl['LKAS11']['CF_Lkas_FcwOpt_USM'] == (expected or 1) + if frame % 5 == 0: + assert parser.vl['LFAHDA_MFC']['LFA_Icon_State'] == expected + assert parser.vl['LKAS11']['CR_Lkas_StrToqReq'] == 0 + assert not any(address in (0x420, 0x421) for address, _, _ in packets) + assert ci.CP.to_dict() == original diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq6_dash_icons.py b/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq6_dash_icons.py index bb60308119..1ff481cc28 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq6_dash_icons.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_ioniq6_dash_icons.py @@ -13,7 +13,7 @@ class TestCanFDDashIcons(unittest.TestCase): icons = CanFDDashIcons() for frame, enabled, lateral, expected in ((0, False, False, 0), (1, False, True, 2), (2, False, False, 3), (100, False, False, 3), - (101, False, False, 0), (102, True, False, 2), + (101, False, False, 0), (102, True, False, 0), (103, False, True, 2), (104, False, False, 3)): self.assertEqual(icons.update(frame, enabled, lateral), expected) @@ -31,7 +31,7 @@ class TestCanFDDashIcons(unittest.TestCase): if cluster: parser.update([(1_000_000_000 + frame * 10_000_000, cluster)]) value = parser.vl['LFAHDA_CLUSTER'] - expected = 2 if command.enabled or command.latActive else 3 if 10 <= frame < 109 else 0 + expected = 2 if command.latActive else 3 if 10 <= frame < 109 else 0 self.assertEqual(value['LFA_ICON'], expected) self.assertEqual(value['HDA_ICON'], int(command.enabled)) @@ -66,3 +66,42 @@ class TestCanFDDashIcons(unittest.TestCase): control.latActive = 5 <= tick < 15 _, messages = ci.apply(control.as_reader(), stamp) self.assertFalse(any(message[0] == 0x1E0 for message in messages), tick) + + + def test_longitudinal_engagement_cannot_hold_or_relight_lateral_icon(self): + for alternate in (False, True): + for aol in (False, True): + with self.subTest(alternate=alternate, aol=aol): + cp, cs, controller = controller_fixture(alternate, aol=aol) + original = cp.to_dict() + parser = CANParser(DBC[cp.carFingerprint][Bus.pt], [('LFAHDA_CLUSTER', 0)], controller.CAN.ECAN) + command = structs.CarControl(enabled=True, longActive=True) + for frame in range(135): + command.latActive = frame < 5 or frame >= 125 + _, messages = controller.update(command.as_reader(), cs, 1_000_000_000 + frame * 10_000_000) + cluster = [message for message in messages if message[0] == 0x1E0] + self.assertEqual(len(cluster), int(frame % 5 == 0)) + if cluster: + parser.update([(1_000_000_000 + frame * 10_000_000, cluster)]) + value = parser.vl['LFAHDA_CLUSTER'] + expected = 2 if command.latActive else 3 if frame < 104 else 0 + self.assertEqual(value['LFA_ICON'], expected) + self.assertEqual(value['HDA_ICON'], 1) + self.assertEqual(cp.to_dict(), original) + + + def test_cruise_transitions_cannot_invert_lateral_icon_at_standstill(self): + for alternate in (False, True): + cp, cs, controller = controller_fixture(alternate, aol=True) + self.assertEqual(cs.out.vEgo, 0.0) + parser = CANParser(DBC[cp.carFingerprint][Bus.pt], [('LFAHDA_CLUSTER', 0)], controller.CAN.ECAN) + command = structs.CarControl(latActive=True) + for frame in range(40): + command.enabled = 10 <= frame < 30 + command.longActive = command.enabled + _, messages = controller.update(command.as_reader(), cs, 1_000_000_000 + frame * 10_000_000) + cluster = [message for message in messages if message[0] == 0x1E0] + if cluster: + parser.update([(1_000_000_000 + frame * 10_000_000, cluster)]) + self.assertEqual(parser.vl['LFAHDA_CLUSTER']['LFA_ICON'], 2) + self.assertEqual(parser.vl['LFAHDA_CLUSTER']['HDA_ICON'], int(command.enabled)) diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_torque_ev_scc.py b/opendbc_repo/opendbc/car/hyundai/tests/test_torque_ev_scc.py index 10d5f2dd6b..d2a89d7b6a 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_torque_ev_scc.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_torque_ev_scc.py @@ -138,7 +138,7 @@ def test_actual_controller_cluster_lifecycle(cp): if cluster: parser.update([((frame + 1) * 10_000_000, cluster)]) values = parser.vl["LFAHDA_CLUSTER"] - expected = 2 if command.enabled or command.latActive else 3 if 10 <= frame < 109 else 0 + expected = 2 if command.latActive else 3 if 10 <= frame < 109 else 0 assert values["LFA_ICON"] == expected assert values["HDA_ICON"] == int(command.enabled) diff --git a/prebuilt.json b/prebuilt.json index 9cb1083279..a3672e23f1 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "d38c1c1123286de21b2454f96eac8495a50569f924f19b98b2a4bd71c3b827fe", "schema_version": 1} +{"protected_inventory_sha256": "0211afd188b3c8a41965352bd7817c834d718c71aa4daf20581ab71d0ad74cc3", "schema_version": 1} diff --git a/tools/ci/run_vehicle_tests.py b/tools/ci/run_vehicle_tests.py index 43d8200256..039c7a3620 100644 --- a/tools/ci/run_vehicle_tests.py +++ b/tools/ci/run_vehicle_tests.py @@ -441,6 +441,8 @@ RELEASE_TARGETS = ( "opendbc_repo/opendbc/car/hyundai/tests/test_dom_radar_complete_paths.py", "opendbc_repo/opendbc/car/hyundai/tests/test_dom_firmware_catalog.py", "opendbc_repo/opendbc/car/hyundai/tests/test_canfd_lfa_status.py", + "opendbc_repo/opendbc/car/hyundai/tests/test_ioniq6_dash_icons.py", + "opendbc_repo/opendbc/car/hyundai/tests/test_torque_ev_scc.py", "opendbc_repo/opendbc/safety/tests/test_hyundai_classic_long_aol.py", "openpilot/starpilot/aol/tests/test_classic_long_profiles.py", "opendbc_repo/opendbc/safety/tests/test_hyundai_shared_canfd_stock_aol.py",