From da61e79f2e766babeafd0b0edce09ad0b3efdab9 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sun, 26 Apr 2026 17:14:39 -0500 Subject: [PATCH] hud bsm? --- .../opendbc/car/hyundai/carcontroller.py | 6 ++ .../opendbc/car/hyundai/hyundaicanfd.py | 62 +++++++++++++++++++ .../opendbc/car/hyundai/tests/test_hyundai.py | 22 +++++++ .../opendbc/safety/modes/hyundai_canfd.h | 2 + .../safety/tests/test_hyundai_canfd.py | 5 +- 5 files changed, 95 insertions(+), 2 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/carcontroller.py b/opendbc_repo/opendbc/car/hyundai/carcontroller.py index 6c11a60e1..0c74334ec 100644 --- a/opendbc_repo/opendbc/car/hyundai/carcontroller.py +++ b/opendbc_repo/opendbc/car/hyundai/carcontroller.py @@ -244,6 +244,12 @@ class CarController(CarControllerBase): CS.right_blindspot_from_radar, CC.leftBlinker, CC.rightBlinker)) + if self.CP.carFingerprint == CAR.HYUNDAI_IONIQ_6: + can_sends.extend(hyundaicanfd.create_ioniq_6_cluster_blindspot_messages(self.CAN, self.frame, + CS.left_blindspot_from_radar, + CS.right_blindspot_from_radar, + CC.leftBlinker, + CC.rightBlinker)) if self.frame % 2 == 0: can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override, set_speed_in_units, hud_control)) diff --git a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py index 0d6df9420..555e76a10 100644 --- a/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc_repo/opendbc/car/hyundai/hyundaicanfd.py @@ -229,6 +229,68 @@ def create_blindspot_status_messages(packer, CAN, rear_values, front_corner_valu ] +IONIQ_6_CLUSTER_BLINDSPOT_31A = { + "right": ( + bytes.fromhex("fa7c10f0f0ffff03898aff0b0a8678ff000000007e0055550000000000000000"), + bytes.fromhex("ac0e11f0f0ffff03898aff0c0a8678ff000000007e0055550000000000000000"), + bytes.fromhex("76ce12f0f0ffff03898aff0b0a8678ff000000007e0055550000000000000000"), + bytes.fromhex("309713f0f0ffff03898aff0b0a8678ff000000007e0055550000000000000000"), + bytes.fromhex("d32214f0f0ffff03898aff0c0a8678ff000000007e0055550000000000000000"), + bytes.fromhex("957b15f0f0ffff03898aff0c0a8678ff000000007e0055550000000000000000"), + ), + "left": ( + bytes.fromhex("851828f0f0ffff03898aff0a098678ff000000007e0055550000000000000000"), + bytes.fromhex("c34129f0f0ffff03898aff0a098678ff000000007e0055550000000000000000"), + bytes.fromhex("09aa2af0f0ffff03898aff0a098678ff000000007e0055550000000000000000"), + bytes.fromhex("4ff32bf0f0ffff03898aff0a098678ff000000007e0055550000000000000000"), + bytes.fromhex("bc6d2cf0f0ffff03898aff0a098678ff000000007e0055550000000000000000"), + bytes.fromhex("fa342df0f0ffff03898aff0a098678ff000000007e0055550000000000000000"), + ), +} + +IONIQ_6_CLUSTER_BLINDSPOT_3B5 = { + "right": ( + bytes.fromhex("caa95c00000000464600000000000000d7020000000069070000000000000000"), + bytes.fromhex("8cf05d00000000464600000000000000d7020000000069070000000000000000"), + bytes.fromhex("461b5e00000000464600000000000000d7020000000069070000000000000000"), + bytes.fromhex("00425f00000000464600000000000000d7020000000069070000000000000000"), + ), + "left": ( + bytes.fromhex("2c69c500000000464600000000000000da020000000069070000000000000000"), + bytes.fromhex("e682c600000000464600000000000000da020000000069070000000000000000"), + bytes.fromhex("21afc800000000464600000000000000da020000000069070000000000000000"), + bytes.fromhex("67f6c900000000464600000000000000da020000000069070000000000000000"), + ), +} + + +def create_ioniq_6_cluster_blindspot_messages(CAN, frame, left_blindspot=False, right_blindspot=False, + left_blinker=False, right_blinker=False): + side = None + if left_blindspot and not right_blindspot: + side = "left" + elif right_blindspot and not left_blindspot: + side = "right" + elif left_blindspot and right_blindspot: + if left_blinker and not right_blinker: + side = "left" + elif right_blinker and not left_blinker: + side = "right" + + if side is None: + return [] + + ret = [] + if frame % 20 == 0: + seq_3b5 = IONIQ_6_CLUSTER_BLINDSPOT_3B5[side] + ret.append((0x3B5, seq_3b5[(frame // 20) % len(seq_3b5)], CAN.ECAN)) + if frame % 100 == 0: + seq_31a = IONIQ_6_CLUSTER_BLINDSPOT_31A[side] + ret.append((0x31A, seq_31a[(frame // 100) % len(seq_31a)], CAN.ECAN)) + + return ret + + def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_override, set_speed, hud_control): jerk = 5 jn = jerk / 50 diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index 846cccd42..c8ca8c006 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -358,6 +358,28 @@ class TestHyundaiFingerprint: assert decode_ioniq_6_blindspot_radar_state(0x1A) == (True, True) assert decode_ioniq_6_blindspot_radar_state(10.0) == (False, True) + def test_ioniq_6_cluster_blindspot_helper_uses_captured_stock_sequences(self): + CP = CarParams.new_message() + CP.carFingerprint = CAR.HYUNDAI_IONIQ_6 + CP.flags = int(HyundaiFlags.CANFD | HyundaiFlags.CANFD_LKA_STEERING) + + can_bus = CanBus(CP) + + right_msgs = hyundaicanfd.create_ioniq_6_cluster_blindspot_messages(can_bus, 0, False, True) + assert right_msgs == [ + (0x3B5, bytes.fromhex("caa95c00000000464600000000000000d7020000000069070000000000000000"), can_bus.ECAN), + (0x31A, bytes.fromhex("fa7c10f0f0ffff03898aff0b0a8678ff000000007e0055550000000000000000"), can_bus.ECAN), + ] + + left_msgs = hyundaicanfd.create_ioniq_6_cluster_blindspot_messages(can_bus, 100, True, False) + assert left_msgs == [ + (0x3B5, bytes.fromhex("e682c600000000464600000000000000da020000000069070000000000000000"), can_bus.ECAN), + (0x31A, bytes.fromhex("c34129f0f0ffff03898aff0a098678ff000000007e0055550000000000000000"), can_bus.ECAN), + ] + + both_msgs = hyundaicanfd.create_ioniq_6_cluster_blindspot_messages(can_bus, 0, True, True) + assert both_msgs == [] + def test_sportage_angle_jerk_override_is_scoped(self): sportage = CarParams.new_message() sportage.carFingerprint = CAR.KIA_SPORTAGE_HEV_2026 diff --git a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h index ee50b824f..6fde1e0dd 100644 --- a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h +++ b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h @@ -27,6 +27,8 @@ #define HYUNDAI_CANFD_BLINDSPOT_DASH_TX_MSGS(e_can) \ {0x1BA, e_can, 24, .check_relay = false}, /* BLINDSPOTS_REAR_CORNERS */ \ {0x1E5, e_can, 16, .check_relay = false}, /* BLINDSPOTS_FRONT_CORNER_1 */ \ + {0x31A, e_can, 32, .check_relay = false}, /* cluster blindspot overlay */ \ + {0x3B5, e_can, 32, .check_relay = false}, /* cluster blindspot overlay */ \ // *** Addresses checked in rx hook *** // EV, ICE, HYBRID: ACCELERATOR (0x35), ACCELERATOR_BRAKE_ALT (0x100), ACCELERATOR_ALT (0x105) diff --git a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py index 9929bae0a..96e497e18 100755 --- a/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py +++ b/opendbc_repo/opendbc/safety/tests/test_hyundai_canfd.py @@ -451,7 +451,8 @@ class TestHyundaiCanfdLKASteeringAltEV(TestHyundaiCanfdBase): class TestHyundaiCanfdLKASteeringLongEV(HyundaiLongitudinalBase, TestHyundaiCanfdLKASteeringEV): TX_MSGS = [[0x50, 0], [0x1CF, 1], [0x2A4, 0], [0x51, 0], [0x730, 1], [0x12a, 1], [0x160, 1], - [0x1ba, 1], [0x1e0, 1], [0x1e5, 1], [0x1a0, 1], [0x1ea, 1], [0x200, 1], [0x345, 1], [0x1da, 1]] + [0x1ba, 1], [0x1e0, 1], [0x1e5, 1], [0x31a, 1], [0x3b5, 1], + [0x1a0, 1], [0x1ea, 1], [0x200, 1], [0x345, 1], [0x1da, 1]] RELAY_MALFUNCTION_ADDRS = {0: (0x50, 0x2a4), 1: (0x1a0,)} # LKAS, CAM_0x2A4, SCC_CONTROL @@ -480,7 +481,7 @@ class TestHyundaiCanfdLKASteeringLongEV(HyundaiLongitudinalBase, TestHyundaiCanf # Tests longitudinal for ICE, hybrid, EV cars with LFA steering class TestHyundaiCanfdLFASteeringLongBase(HyundaiLongitudinalBase, TestHyundaiCanfdLFASteeringBase): - TX_MSGS = [[0x12A, 0], [0x1A0, 1], [0x1CF, 0], [0x1E0, 0], [0x1BA, 0], [0x1E5, 0]] + TX_MSGS = [[0x12A, 0], [0x1A0, 1], [0x1CF, 0], [0x1E0, 0], [0x1BA, 0], [0x1E5, 0], [0x31A, 0], [0x3B5, 0]] FWD_BLACKLISTED_ADDRS = {2: [0x12a, 0xcb, 0x1e0, 0x1a0, 0x160]} RELAY_MALFUNCTION_ADDRS = {0: (0x12A, 0xCB, 0x1E0, 0x1a0, 0x160)} # LFA, ADAS_CMD_35_10ms, LFAHDA_CLUSTER, SCC_CONTROL, ADRV_0x160