From 54b7f5961c2e108bdff2385fcef59c55f903b4e9 Mon Sep 17 00:00:00 2001 From: royjr Date: Tue, 22 Oct 2024 11:29:57 -0400 Subject: [PATCH 01/15] init --- opendbc/car/hyundai/carstate.py | 2 +- opendbc/car/hyundai/fingerprints.py | 8 ++++++++ opendbc/car/hyundai/values.py | 6 ++++++ opendbc/car/torque_data/override.toml | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/opendbc/car/hyundai/carstate.py b/opendbc/car/hyundai/carstate.py index 9406d858fb..cc74796b8c 100644 --- a/opendbc/car/hyundai/carstate.py +++ b/opendbc/car/hyundai/carstate.py @@ -218,7 +218,7 @@ def update_canfd(self, cp, cp_cam) -> structs.CarState: # TODO: alt signal usage may be described by cp.vl['BLINKERS']['USE_ALT_LAMP'] left_blinker_sig, right_blinker_sig = "LEFT_LAMP", "RIGHT_LAMP" - if self.CP.carFingerprint == CAR.HYUNDAI_KONA_EV_2ND_GEN: + if self.CP.carFingerprint in (CAR.HYUNDAI_KONA_EV_2ND_GEN, CAR.HYUNDAI_SONATA_2024): left_blinker_sig, right_blinker_sig = "LEFT_LAMP_ALT", "RIGHT_LAMP_ALT" ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp(50, cp.vl["BLINKERS"][left_blinker_sig], cp.vl["BLINKERS"][right_blinker_sig]) diff --git a/opendbc/car/hyundai/fingerprints.py b/opendbc/car/hyundai/fingerprints.py index 7496e2bff0..59384c0b60 100644 --- a/opendbc/car/hyundai/fingerprints.py +++ b/opendbc/car/hyundai/fingerprints.py @@ -196,6 +196,14 @@ b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.07 99211-L1000 211223', ], }, + CAR.HYUNDAI_SONATA_2024: { + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00DN8_ RDR ----- 1.00 1.00 99110-L1800 ', + ], + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.01 99211-L1800 230512' + ], + }, CAR.HYUNDAI_SONATA_LF: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00LF__ SCC F-CUP 1.00 1.00 96401-C2200 ', diff --git a/opendbc/car/hyundai/values.py b/opendbc/car/hyundai/values.py index 2eeb337636..0b5b609eaa 100644 --- a/opendbc/car/hyundai/values.py +++ b/opendbc/car/hyundai/values.py @@ -271,6 +271,12 @@ class CAR(Platforms): CarSpecs(mass=1513, wheelbase=2.84, steerRatio=13.27 * 1.15, tireStiffnessFactor=0.65), # 15% higher at the center seems reasonable flags=HyundaiFlags.MANDO_RADAR | HyundaiFlags.CHECKSUM_CRC8, ) + HYUNDAI_SONATA_2024 = HyundaiCanFDPlatformConfig( + [HyundaiCarDocs("Hyundai Sonata 2024", "All", car_parts=CarParts.common([CarHarness.hyundai_a]))], + CarSpecs(mass=1556, wheelbase=2.84, steerRatio=12.81 * 1.15, tireStiffnessFactor=0.65), + # TODO: confirm steerRatio increase + # TODO: confirm tireStiffnessFactor + ) HYUNDAI_SONATA_LF = HyundaiPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2018-19", car_parts=CarParts.common([CarHarness.hyundai_e]))], CarSpecs(mass=1536, wheelbase=2.804, steerRatio=13.27 * 1.15), # 15% higher at the center seems reasonable diff --git a/opendbc/car/torque_data/override.toml b/opendbc/car/torque_data/override.toml index aad06e8e3e..936bb69fb2 100644 --- a/opendbc/car/torque_data/override.toml +++ b/opendbc/car/torque_data/override.toml @@ -72,6 +72,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "HYUNDAI_STARIA_4TH_GEN" = [1.8, 2.0, 0.15] "GENESIS_GV70_ELECTRIFIED_1ST_GEN" = [1.9, 1.9, 0.09] "GENESIS_G80_2ND_GEN_FL" = [2.5819356441497803, 2.5, 0.11244568973779678] +"HYUNDAI_SONATA_2024" = [2.5, 2.5, 0.1] # Dashcam or fallback configured as ideal car "MOCK" = [10.0, 10, 0.0] From 7a276a63691d010746a1acd99f0d7f3de21c8ca9 Mon Sep 17 00:00:00 2001 From: royjr Date: Tue, 12 Nov 2024 14:11:07 -0500 Subject: [PATCH 02/15] Update routes.py --- opendbc/car/tests/routes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/opendbc/car/tests/routes.py b/opendbc/car/tests/routes.py index 2e1eca29a0..3252b22bfb 100644 --- a/opendbc/car/tests/routes.py +++ b/opendbc/car/tests/routes.py @@ -130,6 +130,7 @@ class CarTestRoute(NamedTuple): CarTestRoute("6a42c1197b2a8179|2023-09-21--10-23-44", HYUNDAI.KIA_OPTIMA_H_G4_FL), CarTestRoute("c75a59efa0ecd502|2021-03-11--20-52-55", HYUNDAI.KIA_SELTOS), CarTestRoute("5b7c365c50084530|2020-04-15--16-13-24", HYUNDAI.HYUNDAI_SONATA), + CarTestRoute("4267ea8a353cdb36/00000262--8a427003c7", HYUNDAI.HYUNDAI_SONATA_2024), CarTestRoute("b2a38c712dcf90bd|2020-05-18--18-12-48", HYUNDAI.HYUNDAI_SONATA_LF), CarTestRoute("c344fd2492c7a9d2|2023-12-11--09-03-23", HYUNDAI.HYUNDAI_STARIA_4TH_GEN), CarTestRoute("fb3fd42f0baaa2f8|2022-03-30--15-25-05", HYUNDAI.HYUNDAI_TUCSON), From f6f32d6e940c122630ef029704076cb03be32919 Mon Sep 17 00:00:00 2001 From: royjr Date: Thu, 21 Nov 2024 17:51:19 -0500 Subject: [PATCH 03/15] remove todo --- opendbc/car/hyundai/values.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/opendbc/car/hyundai/values.py b/opendbc/car/hyundai/values.py index 213c50ebfb..d4ff1f2c53 100644 --- a/opendbc/car/hyundai/values.py +++ b/opendbc/car/hyundai/values.py @@ -274,8 +274,6 @@ class CAR(Platforms): HYUNDAI_SONATA_2024 = HyundaiCanFDPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2024", "All", car_parts=CarParts.common([CarHarness.hyundai_a]))], CarSpecs(mass=1556, wheelbase=2.84, steerRatio=12.81 * 1.15, tireStiffnessFactor=0.65), - # TODO: confirm steerRatio increase - # TODO: confirm tireStiffnessFactor ) HYUNDAI_SONATA_LF = HyundaiPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2018-19", car_parts=CarParts.common([CarHarness.hyundai_e]))], From e87ae0190cc9e6d822dfe17b6bdc6d4c82e84df5 Mon Sep 17 00:00:00 2001 From: royjr Date: Thu, 21 Nov 2024 17:51:46 -0500 Subject: [PATCH 04/15] use default tireStiffnessFactor --- opendbc/car/hyundai/values.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendbc/car/hyundai/values.py b/opendbc/car/hyundai/values.py index d4ff1f2c53..1f39d13306 100644 --- a/opendbc/car/hyundai/values.py +++ b/opendbc/car/hyundai/values.py @@ -273,7 +273,7 @@ class CAR(Platforms): ) HYUNDAI_SONATA_2024 = HyundaiCanFDPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2024", "All", car_parts=CarParts.common([CarHarness.hyundai_a]))], - CarSpecs(mass=1556, wheelbase=2.84, steerRatio=12.81 * 1.15, tireStiffnessFactor=0.65), + CarSpecs(mass=1556, wheelbase=2.84, steerRatio=12.81 * 1.15), ) HYUNDAI_SONATA_LF = HyundaiPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2018-19", car_parts=CarParts.common([CarHarness.hyundai_e]))], From 062d866e09acef0e2f86ab4ebd6d3d5eb988d6b9 Mon Sep 17 00:00:00 2001 From: royjr Date: Thu, 21 Nov 2024 17:52:00 -0500 Subject: [PATCH 05/15] remove steerRatio factor --- opendbc/car/hyundai/values.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendbc/car/hyundai/values.py b/opendbc/car/hyundai/values.py index 1f39d13306..4b726757d3 100644 --- a/opendbc/car/hyundai/values.py +++ b/opendbc/car/hyundai/values.py @@ -273,7 +273,7 @@ class CAR(Platforms): ) HYUNDAI_SONATA_2024 = HyundaiCanFDPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2024", "All", car_parts=CarParts.common([CarHarness.hyundai_a]))], - CarSpecs(mass=1556, wheelbase=2.84, steerRatio=12.81 * 1.15), + CarSpecs(mass=1556, wheelbase=2.84, steerRatio=12.81), ) HYUNDAI_SONATA_LF = HyundaiPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2018-19", car_parts=CarParts.common([CarHarness.hyundai_e]))], From 6344abc79b2e823b09a0b40ed7e29e4627aa06b1 Mon Sep 17 00:00:00 2001 From: royjr Date: Thu, 28 Nov 2024 18:06:34 -0500 Subject: [PATCH 06/15] add new messages --- opendbc/dbc/hyundai_canfd.dbc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/opendbc/dbc/hyundai_canfd.dbc b/opendbc/dbc/hyundai_canfd.dbc index 1ef67c044a..1802ef92f6 100644 --- a/opendbc/dbc/hyundai_canfd.dbc +++ b/opendbc/dbc/hyundai_canfd.dbc @@ -658,6 +658,19 @@ BO_ 1264 LOCAL_TIME: 8 XXX SG_ MINUTES : 21|6@0+ (1,0) [0|63] "" XXX SG_ SECONDS : 31|8@0+ (1,0) [0|59] "" XXX +BO_ 353 NEW_MSG_161: 32 XXX + SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX + SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX + SG_ LKA_ICON : 30|2@1+ (1,0) [0|3] "" XXX + SG_ SSC_CONDITIONS_NOT_MET : 154|1@0+ (1,0) [0|1] "" XXX + SG_ LFA_ICON : 224|1@0+ (1,0) [0|1] "" XXX + +BO_ 354 NEW_MSG_162: 32 XXX + SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX + SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX + SG_ FAULT_1 : 219|1@0+ (1,0) [0|1] "" XXX + SG_ FAULT_2 : 246|1@0+ (1,0) [0|1] "" XXX + CM_ 272 "Alternative LKAS message, used on cars such as 2023 Ioniq 6, 2nd gen Kona. Matches LKAS except size is 32 bytes"; CM_ 676 "Contains signals with detailed lane line information. Used by ADAS ECU on HDA 2 vehicles to operate LFA."; CM_ 866 "Contains signals with detailed lane line information. Used by ADAS ECU on HDA 2 vehicles to operate LFA. Used on cars that use message 272."; From 3743da824d60556d2acae7a401662732326149c6 Mon Sep 17 00:00:00 2001 From: royjr Date: Thu, 28 Nov 2024 18:11:50 -0500 Subject: [PATCH 07/15] block faults --- opendbc/car/hyundai/carcontroller.py | 1 + opendbc/car/hyundai/carstate.py | 8 +++++++- opendbc/car/hyundai/hyundaicanfd.py | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/opendbc/car/hyundai/carcontroller.py b/opendbc/car/hyundai/carcontroller.py index b0ef691edc..c66379051e 100644 --- a/opendbc/car/hyundai/carcontroller.py +++ b/opendbc/car/hyundai/carcontroller.py @@ -117,6 +117,7 @@ def update(self, CC, CS, now_nanos): # LFA and HDA icons if self.frame % 5 == 0 and (not hda2 or hda2_long): can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CC.enabled)) + can_sends.append(hyundaicanfd.block_faults(self.packer, self.CAN, CC.enabled, CS.block_faults)) # blinkers if hda2 and self.CP.flags & HyundaiFlags.ENABLE_BLINKERS: diff --git a/opendbc/car/hyundai/carstate.py b/opendbc/car/hyundai/carstate.py index e436c872d0..8dfffc30b2 100644 --- a/opendbc/car/hyundai/carstate.py +++ b/opendbc/car/hyundai/carstate.py @@ -50,6 +50,7 @@ def __init__(self, CP): self.buttons_counter = 0 self.cruise_info = {} + self.block_faults = {} # On some cars, CLU15->CF_Clu_VehicleSpeed can oscillate faster than the dash updates. Sample at 5 Hz self.cluster_speed = 0 @@ -267,6 +268,8 @@ def update_canfd(self, can_parsers) -> structs.CarState: ret.buttonEvents = [*create_button_events(self.cruise_buttons[-1], prev_cruise_buttons, BUTTONS_DICT), *create_button_events(self.main_buttons[-1], prev_main_buttons, {1: ButtonType.mainCruise})] + self.block_faults = copy.copy(cp_cam.vl["NEW_MSG_162"]) + return ret def get_can_parsers_canfd(self, CP): @@ -314,7 +317,10 @@ def get_can_parsers_canfd(self, CP): cam_messages += [ ("SCC_CONTROL", 50), ] - + cam_messages += [ + ("NEW_MSG_162", 20), + ] + return { Bus.pt: CANParser(DBC[CP.carFingerprint][Bus.pt], pt_messages, CanBus(CP).ECAN), Bus.cam: CANParser(DBC[CP.carFingerprint][Bus.pt], cam_messages, CanBus(CP).CAM), diff --git a/opendbc/car/hyundai/hyundaicanfd.py b/opendbc/car/hyundai/hyundaicanfd.py index d3488ff531..cc3db25070 100644 --- a/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc/car/hyundai/hyundaicanfd.py @@ -119,6 +119,14 @@ def create_lfahda_cluster(packer, CAN, enabled): } return packer.make_can_msg("LFAHDA_CLUSTER", CAN.ECAN, values) +def block_faults(packer, CAN, enabled, block_faults): + values = {s: block_faults[s] for s in block_faults.keys()} + values.update({ + "FAULT_1": 0, + "FAULT_2": 0, + }) + return packer.make_can_msg("NEW_MSG_162", CAN.ECAN, values) + def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_override, set_speed, hud_control): jerk = 5 From 480c475d176fa7c048a7b1cc0de0556fd7ff4645 Mon Sep 17 00:00:00 2001 From: royjr Date: Thu, 28 Nov 2024 18:38:12 -0500 Subject: [PATCH 08/15] fix whitespace --- opendbc/car/hyundai/carstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendbc/car/hyundai/carstate.py b/opendbc/car/hyundai/carstate.py index 8dfffc30b2..9425debe79 100644 --- a/opendbc/car/hyundai/carstate.py +++ b/opendbc/car/hyundai/carstate.py @@ -320,7 +320,7 @@ def get_can_parsers_canfd(self, CP): cam_messages += [ ("NEW_MSG_162", 20), ] - + return { Bus.pt: CANParser(DBC[CP.carFingerprint][Bus.pt], pt_messages, CanBus(CP).ECAN), Bus.cam: CANParser(DBC[CP.carFingerprint][Bus.pt], cam_messages, CanBus(CP).CAM), From 264c08db9fe9f1bab1d704863e8f474362f2ec2f Mon Sep 17 00:00:00 2001 From: royjr Date: Sun, 1 Dec 2024 17:21:20 -0500 Subject: [PATCH 09/15] fix fp --- opendbc/car/hyundai/fingerprints.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opendbc/car/hyundai/fingerprints.py b/opendbc/car/hyundai/fingerprints.py index 4a050cbadc..df8cd21f46 100644 --- a/opendbc/car/hyundai/fingerprints.py +++ b/opendbc/car/hyundai/fingerprints.py @@ -199,10 +199,11 @@ }, CAR.HYUNDAI_SONATA_2024: { (Ecu.fwdRadar, 0x7d0, None): [ - b'\xf1\x00DN8_ RDR ----- 1.00 1.00 99110-L1800 ', + b'\xf1\x00DN8_ RDR ----- 1.00 1.00 99110-L1800 ', ], (Ecu.fwdCamera, 0x7c4, None): [ - b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.01 99211-L1800 230512' + b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.01 99211-L1800 230512', + b'\xf1\x00DN8 MFC AT KOR LHD 1.00 1.01 99211-L1800 230512', ], }, CAR.HYUNDAI_SONATA_LF: { From 029cf05951c9027930b604d4ce83f7d815af788b Mon Sep 17 00:00:00 2001 From: royjr Date: Sat, 7 Dec 2024 16:11:30 -0500 Subject: [PATCH 10/15] Update carcontroller.py --- opendbc/car/hyundai/carcontroller.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/opendbc/car/hyundai/carcontroller.py b/opendbc/car/hyundai/carcontroller.py index c66379051e..aab3122be0 100644 --- a/opendbc/car/hyundai/carcontroller.py +++ b/opendbc/car/hyundai/carcontroller.py @@ -115,9 +115,11 @@ def update(self, CC, CS, now_nanos): self.CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING)) # LFA and HDA icons - if self.frame % 5 == 0 and (not hda2 or hda2_long): + if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint not in (CAR.HYUNDAI_SONATA_2024,): can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CC.enabled)) - can_sends.append(hyundaicanfd.block_faults(self.packer, self.CAN, CC.enabled, CS.block_faults)) + if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint in (CAR.HYUNDAI_SONATA_2024,): + can_sends.append(hyundaicanfd.create_msg_161(self.packer, self.CAN, CC.enabled, CS.msg_161)) + can_sends.append(hyundaicanfd.create_msg_162(self.packer, self.CAN, CC.enabled, CS.msg_162)) # blinkers if hda2 and self.CP.flags & HyundaiFlags.ENABLE_BLINKERS: From 205c6a489636a6a3d2c4f45ac478267d6ab5a17f Mon Sep 17 00:00:00 2001 From: royjr Date: Sat, 7 Dec 2024 16:12:49 -0500 Subject: [PATCH 11/15] Update carstate.py --- opendbc/car/hyundai/carstate.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/opendbc/car/hyundai/carstate.py b/opendbc/car/hyundai/carstate.py index 9425debe79..06fd94214e 100644 --- a/opendbc/car/hyundai/carstate.py +++ b/opendbc/car/hyundai/carstate.py @@ -50,7 +50,8 @@ def __init__(self, CP): self.buttons_counter = 0 self.cruise_info = {} - self.block_faults = {} + self.msg_161 = {} + self.msg_162 = {} # On some cars, CLU15->CF_Clu_VehicleSpeed can oscillate faster than the dash updates. Sample at 5 Hz self.cluster_speed = 0 @@ -230,8 +231,9 @@ def update_canfd(self, can_parsers) -> structs.CarState: ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp(50, cp.vl["BLINKERS"][left_blinker_sig], cp.vl["BLINKERS"][right_blinker_sig]) if self.CP.enableBsm: - ret.leftBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FL_INDICATOR"] != 0 - ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"]["FR_INDICATOR"] != 0 + alt = "_ALT" if self.CP.carFingerprint == CAR.HYUNDAI_SONATA_2024 else "" + ret.leftBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"][f"FL_INDICATOR{alt}"] != 0 + ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"][f"FR_INDICATOR{alt}"] != 0 # cruise state # CAN FD cars enable on main button press, set available if no TCS faults preventing engagement @@ -268,7 +270,9 @@ def update_canfd(self, can_parsers) -> structs.CarState: ret.buttonEvents = [*create_button_events(self.cruise_buttons[-1], prev_cruise_buttons, BUTTONS_DICT), *create_button_events(self.main_buttons[-1], prev_main_buttons, {1: ButtonType.mainCruise})] - self.block_faults = copy.copy(cp_cam.vl["NEW_MSG_162"]) + if self.CP.carFingerprint in (CAR.HYUNDAI_SONATA_2024,): + self.msg_161 = copy.copy(cp_cam.vl["MSG_161"]) + self.msg_162 = copy.copy(cp_cam.vl["MSG_162"]) return ret @@ -317,9 +321,11 @@ def get_can_parsers_canfd(self, CP): cam_messages += [ ("SCC_CONTROL", 50), ] - cam_messages += [ - ("NEW_MSG_162", 20), - ] + if self.CP.carFingerprint in (CAR.HYUNDAI_SONATA_2024,): + cam_messages += [ + ("MSG_161", 20), + ("MSG_162", 20), + ] return { Bus.pt: CANParser(DBC[CP.carFingerprint][Bus.pt], pt_messages, CanBus(CP).ECAN), From adc668f4964f7f7a5cac6bc471108949ce40e3e9 Mon Sep 17 00:00:00 2001 From: royjr Date: Sat, 7 Dec 2024 16:13:35 -0500 Subject: [PATCH 12/15] Update hyundaicanfd.py --- opendbc/car/hyundai/hyundaicanfd.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/opendbc/car/hyundai/hyundaicanfd.py b/opendbc/car/hyundai/hyundaicanfd.py index cc3db25070..62d8f1694b 100644 --- a/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc/car/hyundai/hyundaicanfd.py @@ -119,14 +119,30 @@ def create_lfahda_cluster(packer, CAN, enabled): } return packer.make_can_msg("LFAHDA_CLUSTER", CAN.ECAN, values) -def block_faults(packer, CAN, enabled, block_faults): - values = {s: block_faults[s] for s in block_faults.keys()} +def create_msg_161(packer, CAN, enabled, msg_161): + values = msg_161.copy() values.update({ - "FAULT_1": 0, - "FAULT_2": 0, + "LFA_ICON": 2 if enabled else 0, + "LKA_ICON": 4 if enabled else 0, + "LANELINE_LEFT": 2 if enabled else 0, + "LANELINE_RIGHT": 2 if enabled else 0, + "CENTERLINE": 1 if enabled else 0, + "DAW_ICON": 0, }) - return packer.make_can_msg("NEW_MSG_162", CAN.ECAN, values) - + if values.get("ALERTS_5") == 5: # use_switch_or_pedal_to_accelerate + values["ALERTS_5"] = 0 + if values.get("ALERTS_2") == 5: # coffee + values.update({"ALERTS_2": 0, "SOUNDS_2": 0}) + return packer.make_can_msg("MSG_161", CAN.ECAN, values) + +def create_msg_162(packer, CAN, enabled, msg_162): + values = msg_162.copy() + values.update({ + "FAULT_LSS": 0, + "FAULT_HDA": 0, + "FAULT_DAS": 0, + }) + return packer.make_can_msg("MSG_162", CAN.ECAN, values) def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_override, set_speed, hud_control): jerk = 5 From d8c0c389e7f1d8bdabe80b7fd4091dd7fbdf0c53 Mon Sep 17 00:00:00 2001 From: royjr Date: Sat, 7 Dec 2024 16:14:10 -0500 Subject: [PATCH 13/15] Update hyundai_canfd.dbc --- opendbc/dbc/hyundai_canfd.dbc | 123 ++++++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 12 deletions(-) diff --git a/opendbc/dbc/hyundai_canfd.dbc b/opendbc/dbc/hyundai_canfd.dbc index 1802ef92f6..9d28bc84c4 100644 --- a/opendbc/dbc/hyundai_canfd.dbc +++ b/opendbc/dbc/hyundai_canfd.dbc @@ -599,6 +599,8 @@ BO_ 442 BLINDSPOTS_REAR_CORNERS: 24 XXX SG_ FL_INDICATOR : 46|6@0+ (1,0) [0|1] "" XXX SG_ FR_INDICATOR : 54|6@0+ (1,0) [0|63] "" XXX SG_ RIGHT_BLOCKED : 64|1@0+ (1,0) [0|1] "" XXX + SG_ FL_INDICATOR_ALT : 138|1@0+ (1,0) [0|1] "" XXX + SG_ FR_INDICATOR_ALT : 141|1@0+ (1,0) [0|1] "" XXX BO_ 874 BLINDSPOTS_FRONT_CORNER_2: 16 XXX SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX @@ -658,18 +660,115 @@ BO_ 1264 LOCAL_TIME: 8 XXX SG_ MINUTES : 21|6@0+ (1,0) [0|63] "" XXX SG_ SECONDS : 31|8@0+ (1,0) [0|59] "" XXX -BO_ 353 NEW_MSG_161: 32 XXX - SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX - SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX - SG_ LKA_ICON : 30|2@1+ (1,0) [0|3] "" XXX - SG_ SSC_CONDITIONS_NOT_MET : 154|1@0+ (1,0) [0|1] "" XXX - SG_ LFA_ICON : 224|1@0+ (1,0) [0|1] "" XXX - -BO_ 354 NEW_MSG_162: 32 XXX - SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX - SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX - SG_ FAULT_1 : 219|1@0+ (1,0) [0|1] "" XXX - SG_ FAULT_2 : 246|1@0+ (1,0) [0|1] "" XXX +BO_ 353 MSG_161: 32 CCNC + SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX + SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX + SG_ FCA_ICON : 24|3@1+ (1,0) [0|7] "" XXX + SG_ FCA_ALT_ICON : 27|3@1+ (1,0) [0|7] "" XXX + SG_ LKA_ICON : 30|3@1+ (1,0) [0|3] "" XXX + SG_ HBA_ICON : 33|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_1 : 36|4@1+ (1,0) [0|15] "" XXX + SG_ ZEROS_2 : 40|2@1+ (1,0) [0|3] "" XXX + SG_ FCA_IMAGE : 42|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_3 : 45|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_4 : 48|3@1+ (1,0) [0|7] "" XXX + SG_ BCA_LEFT : 51|3@1+ (1,0) [0|7] "" XXX + SG_ BCA_RIGHT : 54|3@1+ (1,0) [0|7] "" XXX + SG_ LCA_LEFT_ARROW : 57|3@1+ (1,0) [0|7] "" XXX + SG_ LCA_RIGHT_ARROW : 60|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_5 : 63|1@0+ (1,0) [0|1] "" XXX + SG_ CENTERLINE : 64|2@1+ (1,0) [0|3] "" XXX + SG_ TARGET : 66|3@1+ (1,0) [0|7] "" XXX + SG_ TARGET_POSITION : 69|11@1+ (1,0) [0|7] "" XXX + SG_ LANELINE_LEFT : 80|4@1+ (1,0) [0|15] "" XXX + SG_ LANELINE_LEFT_POSITION : 84|6@1+ (1,0) [0|15] "" XXX + SG_ LANELINE_RIGHT : 90|4@1+ (1,0) [0|15] "" XXX + SG_ LANELINE_RIGHT_POSITION : 94|6@1+ (1,0) [0|3] "" XXX + SG_ LANELINE_CURVATURE : 100|5@1- (1,15) [0|31] "" XXX + SG_ LANE_HIGHLIGHT : 105|4@1+ (1,0) [0|15] "" XXX + SG_ LANE_HIGHLIGHT_DISTANCE : 109|11@1+ (1,0) [0|7] "" XXX + SG_ LANE_LEFT : 120|3@1+ (1,0) [0|7] "" XXX + SG_ LANE_RIGHT : 123|3@1+ (1,0) [0|7] "" XXX + SG_ LANE_ZOOM : 126|2@1+ (1,0) [0|3] "" XXX + SG_ ALERTS_1 : 128|6@1+ (1,0) [0|63] "" XXX + SG_ ALERTS_2 : 134|5@1+ (1,0) [0|3] "" XXX + SG_ ALERTS_3 : 139|4@1+ (1,0) [0|15] "" XXX + SG_ ALERTS_4 : 143|9@1+ (1,0) [0|511] "" XXX + SG_ ALERTS_5 : 152|5@1+ (1,0) [0|7] "" XXX + SG_ MUTE : 157|3@1+ (1,0) [0|7] "" XXX + SG_ SOUNDS_1 : 160|4@1+ (1,0) [0|3] "" XXX + SG_ SOUNDS_2 : 164|4@1+ (1,0) [0|3] "" XXX + SG_ SOUNDS_3 : 168|4@1+ (1,0) [0|15] "" XXX + SG_ SOUNDS_4 : 172|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_6 : 175|1@0+ (1,0) [0|1] "" XXX + SG_ ZEROS_7 : 176|5@1+ (1,0) [0|31] "" XXX + SG_ SETSPEED_HUD : 181|3@1+ (1,0) [0|3] "" XXX + SG_ DISTANCE_LEAD : 184|5@1+ (1,0) [0|31] "" XXX + SG_ DISTANCE_CAR : 189|3@1+ (1,0) [0|7] "" XXX + SG_ DISTANCE_SPACING : 192|4@1+ (1,0) [0|15] "" XXX + SG_ DISTANCE : 196|4@1+ (1,0) [0|7] "" XXX + SG_ SETSPEED_SPEED : 200|8@1+ (1,0) [0|255] "" XXX + SG_ SETSPEED : 208|4@1+ (1,0) [0|3] "" XXX + SG_ HDA_ICON : 212|4@1+ (1,0) [0|3] "" XXX + SG_ SLA_ICON : 216|4@1+ (1,0) [0|15] "" XXX + SG_ NAV_ICON : 220|4@1+ (1,0) [0|3] "" XXX + SG_ LFA_ICON : 224|4@1+ (1,0) [0|3] "" XXX + SG_ LCA_LEFT_ICON : 228|4@1+ (1,0) [0|15] "" XXX + SG_ LCA_RIGHT_ICON : 232|4@1+ (1,0) [0|15] "" XXX + SG_ BACKGROUND : 236|4@1+ (1,0) [0|15] "" XXX + SG_ DAW_ICON : 240|3@1+ (1,0) [0|7] "" XXX + SG_ CAR_CIRCLE : 243|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_8 : 246|2@1+ (1,0) [0|3] "" XXX + SG_ ZEROS_9 : 248|8@1+ (1,0) [0|255] "" XXX + +BO_ 354 MSG_162: 32 CCNC + SG_ CHECKSUM : 0|16@1+ (1,0) [0|65535] "" XXX + SG_ COUNTER : 16|8@1+ (1,0) [0|255] "" XXX + SG_ SPEEDLIMIT_STYLE : 24|4@1+ (1,0) [0|7] "" XXX + SG_ SPEEDLIMIT_FLASH : 28|4@1+ (1,0) [0|15] "" XXX + SG_ SPEEDLIMIT : 32|8@1+ (1,0) [0|255] "" XXX + SG_ SIGNS : 40|8@1+ (1,0) [0|15] "" XXX + SG_ SPEEDLIMIT_WEATHER : 48|4@1+ (1,0) [0|15] "" XXX + SG_ VIBRATE : 52|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_1 : 55|1@0+ (1,0) [0|1] "" XXX + SG_ ZEROS_2 : 56|8@1+ (1,0) [0|255] "" XXX + SG_ LEAD : 64|5@1+ (1,0) [0|31] "" XXX + SG_ LEAD_DISTANCE : 69|11@1+ (1,0) [0|2047] "" XXX + SG_ LEAD_LATERAL : 80|7@1+ (1,0) [0|127] "" XXX + SG_ ZEROS_3 : 87|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_ALT : 88|5@1+ (1,0) [0|31] "" XXX + SG_ LEAD_ALT_DISTANCE : 93|11@1+ (1,0) [0|2047] "" XXX + SG_ LEAD_ALT_LATERAL : 104|7@1+ (1,0) [0|127] "" XXX + SG_ ZEROS_4 : 111|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_LEFT : 112|5@1+ (1,0) [0|31] "" XXX + SG_ LEAD_LEFT_DISTANCE : 117|11@1+ (1,0) [0|2047] "" XXX + SG_ LEAD_LEFT_LATERAL : 128|7@1+ (1,0) [0|127] "" XXX + SG_ ZEROS_5 : 135|1@0+ (1,0) [0|1] "" XXX + SG_ LEAD_RIGHT : 136|5@1+ (1,0) [0|31] "" XXX + SG_ LEAD_RIGHT_DISTANCE : 141|11@1+ (1,0) [0|2047] "" XXX + SG_ LEAD_RIGHT_LATERAL : 152|7@1+ (1,0) [0|127] "" XXX + SG_ ZEROS_6 : 159|1@0+ (1,0) [0|1] "" XXX + SG_ ZEROS_7 : 160|8@1+ (1,0) [0|255] "" XXX + SG_ ZEROS_8 : 168|8@1+ (1,0) [0|255] "" XXX + SG_ ZEROS_9 : 176|8@1+ (1,0) [0|255] "" XXX + SG_ ZEROS_10 : 184|8@1+ (1,0) [0|255] "" XXX + SG_ ZEROS_11 : 192|8@1+ (1,0) [0|255] "" XXX + SG_ ZEROS_12 : 200|8@1+ (1,0) [0|255] "" XXX + SG_ ZEROS_13 : 208|5@1+ (1,0) [0|31] "" XXX + SG_ FAULT_FSS : 213|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_FCA : 216|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_LSS : 219|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_SLA : 222|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_DAW : 225|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_HBA : 228|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_SCC : 231|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_LFA : 234|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_HDA : 237|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_LCA : 240|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_HDP : 243|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_DAS : 246|3@1+ (1,0) [0|7] "" XXX + SG_ FAULT_ESS : 249|3@1+ (1,0) [0|7] "" XXX + SG_ ZEROS_14 : 252|4@1+ (1,0) [0|15] "" XXX CM_ 272 "Alternative LKAS message, used on cars such as 2023 Ioniq 6, 2nd gen Kona. Matches LKAS except size is 32 bytes"; CM_ 676 "Contains signals with detailed lane line information. Used by ADAS ECU on HDA 2 vehicles to operate LFA."; From 446b0c4b0d03b594bb5e37a26ee4e46458f5326d Mon Sep 17 00:00:00 2001 From: royjr Date: Tue, 10 Dec 2024 08:17:56 -0500 Subject: [PATCH 14/15] new --- opendbc/car/hyundai/carcontroller.py | 4 +- opendbc/car/hyundai/hyundaicanfd.py | 83 +++++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 9 deletions(-) diff --git a/opendbc/car/hyundai/carcontroller.py b/opendbc/car/hyundai/carcontroller.py index aab3122be0..e25cd09f10 100644 --- a/opendbc/car/hyundai/carcontroller.py +++ b/opendbc/car/hyundai/carcontroller.py @@ -118,8 +118,8 @@ def update(self, CC, CS, now_nanos): if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint not in (CAR.HYUNDAI_SONATA_2024,): can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CC.enabled)) if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint in (CAR.HYUNDAI_SONATA_2024,): - can_sends.append(hyundaicanfd.create_msg_161(self.packer, self.CAN, CC.enabled, CS.msg_161)) - can_sends.append(hyundaicanfd.create_msg_162(self.packer, self.CAN, CC.enabled, CS.msg_162)) + can_sends.append(hyundaicanfd.create_msg_161(self.packer, self.CAN, CC.enabled, CS.msg_161, self.CP, hud_control, CS, CC, self.frame)) + can_sends.append(hyundaicanfd.create_msg_162(self.packer, self.CAN, CC.enabled, CS.msg_162, self.CP, hud_control)) # blinkers if hda2 and self.CP.flags & HyundaiFlags.ENABLE_BLINKERS: diff --git a/opendbc/car/hyundai/hyundaicanfd.py b/opendbc/car/hyundai/hyundaicanfd.py index 62d8f1694b..bdc1c626fb 100644 --- a/opendbc/car/hyundai/hyundaicanfd.py +++ b/opendbc/car/hyundai/hyundaicanfd.py @@ -1,4 +1,5 @@ from opendbc.car import CanBusBase +from opendbc.car.common.conversions import Conversions as CV from opendbc.car.common.numpy_fast import clip from opendbc.car.hyundai.values import HyundaiFlags @@ -119,29 +120,97 @@ def create_lfahda_cluster(packer, CAN, enabled): } return packer.make_can_msg("LFAHDA_CLUSTER", CAN.ECAN, values) -def create_msg_161(packer, CAN, enabled, msg_161): +def create_msg_161(packer, CAN, enabled, msg_161, car_params, hud_control, car_state, car_control, frame): values = msg_161.copy() + + # HIDE ALERTS + if values.get("ALERTS_5") == 5: # USE SWITCH OR PEDAL TO ACCELERATE + values["ALERTS_5"] = 0 + if values.get("ALERTS_2") == 5: # CONSIDER TAKING A BREAK + values.update({"ALERTS_2": 0, "SOUNDS_2": 0, "DAW_ICON": 0}) + + # LANELINES + curvature = { + i: (31 if i == -1 else 13 - abs(i + 15)) if i < 0 else 15 + i + for i in range(-15, 16) + } values.update({ + "LANELINE_CURVATURE": curvature.get(max(-15, min(int(car_state.out.steeringAngleDeg / 3), 15)), 14) if enabled else 15, "LFA_ICON": 2 if enabled else 0, "LKA_ICON": 4 if enabled else 0, "LANELINE_LEFT": 2 if enabled else 0, "LANELINE_RIGHT": 2 if enabled else 0, "CENTERLINE": 1 if enabled else 0, - "DAW_ICON": 0, }) - if values.get("ALERTS_5") == 5: # use_switch_or_pedal_to_accelerate - values["ALERTS_5"] = 0 - if values.get("ALERTS_2") == 5: # coffee - values.update({"ALERTS_2": 0, "SOUNDS_2": 0}) + + # LCA + if enabled: + speed_below_threshold = car_state.out.vEgo < 8.94 + values.update({ + "LCA_LEFT_ICON": 0 if car_state.out.leftBlindspot or speed_below_threshold else 2 if car_control.leftBlinker else 1, + "LCA_RIGHT_ICON": 0 if car_state.out.rightBlindspot or speed_below_threshold else 2 if car_control.rightBlinker else 1, + "LCA_LEFT_ARROW": 2 if car_control.leftBlinker else 0, + "LCA_RIGHT_ARROW": 2 if car_control.rightBlinker else 0, + }) + + # LANE DEPARTURE + if hud_control.leftLaneDepart: + values["LANELINE_LEFT"] = 4 if (frame // 50) % 2 == 0 else 1 + if hud_control.rightLaneDepart: + values["LANELINE_RIGHT"] = 4 if (frame // 50) % 2 == 0 else 1 + + if car_params.openpilotLongitudinalControl: + # HIDE ALERTS + if values.get("ALERTS_5") == 4: # SMART CRUISE CONTROL CONDITIONS NOT MET + values["ALERTS_5"] = 0 + + # SETSPEED + values["SETSPEED"] = 3 if enabled else 1 + values["SETSPEED_HUD"] = 2 if enabled else 1 + values["SETSPEED_SPEED"] = 25 if (s := round(car_state.out.vCruiseCluster * CV.KPH_TO_MPH)) > 100 else s + + # DISTANCE + if 1 <= hud_control.leadDistanceBars <= 3: + values["DISTANCE"] = hud_control.leadDistanceBars + values["DISTANCE_SPACING"] = 1 if enabled else 0 + values["DISTANCE_LEAD"] = 2 if enabled and hud_control.leadVisible else 1 if enabled else 0 + values["DISTANCE_CAR"] = 2 if enabled else 1 + values["ALERTS_3"] = hud_control.leadDistanceBars + 6 + else: + values["DISTANCE"] = 0 + values["DISTANCE_SPACING"] = 0 + values["DISTANCE_LEAD"] = 0 + values["DISTANCE_CAR"] = 0 + + # BACKGROUND + values["BACKGROUND"] = 1 if enabled else 7 + return packer.make_can_msg("MSG_161", CAN.ECAN, values) -def create_msg_162(packer, CAN, enabled, msg_162): +def create_msg_162(packer, CAN, enabled, msg_162, car_params, hud_control): values = msg_162.copy() + + # HIDE FAULTS values.update({ "FAULT_LSS": 0, "FAULT_HDA": 0, "FAULT_DAS": 0, }) + + # LANE DEPARTURE + if hud_control.leftLaneDepart or hud_control.rightLaneDepart: + values["VIBRATE"] = 1 + + if car_params.openpilotLongitudinalControl: + # *** TODO *** LEAD_DISTANCE/LEAD_LATERAL + # LEAD + if hud_control.leadVisible: + values["LEAD"] = 2 if enabled else 1 + values["LEAD_DISTANCE"] = 100 + else: + values["LEAD"] = 0 + values["LEAD_DISTANCE"] = 0 + return packer.make_can_msg("MSG_162", CAN.ECAN, values) def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_override, set_speed, hud_control): From 0c57d277de2e897e71991219437e400199cda600 Mon Sep 17 00:00:00 2001 From: royjr Date: Tue, 10 Dec 2024 23:31:31 -0500 Subject: [PATCH 15/15] init --- opendbc/car/hyundai/carcontroller.py | 4 ++-- opendbc/car/hyundai/carstate.py | 8 ++++---- opendbc/car/hyundai/fingerprints.py | 17 ++++++++--------- opendbc/car/hyundai/values.py | 8 ++++---- opendbc/car/tests/routes.py | 2 +- opendbc/car/torque_data/override.toml | 2 +- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/opendbc/car/hyundai/carcontroller.py b/opendbc/car/hyundai/carcontroller.py index e25cd09f10..c235fb8549 100644 --- a/opendbc/car/hyundai/carcontroller.py +++ b/opendbc/car/hyundai/carcontroller.py @@ -115,9 +115,9 @@ def update(self, CC, CS, now_nanos): self.CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING)) # LFA and HDA icons - if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint not in (CAR.HYUNDAI_SONATA_2024,): + if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint not in (CAR.KIA_SORENTO_2024,): can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CC.enabled)) - if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint in (CAR.HYUNDAI_SONATA_2024,): + if self.frame % 5 == 0 and (not hda2 or hda2_long) and self.car_fingerprint in (CAR.KIA_SORENTO_2024,): can_sends.append(hyundaicanfd.create_msg_161(self.packer, self.CAN, CC.enabled, CS.msg_161, self.CP, hud_control, CS, CC, self.frame)) can_sends.append(hyundaicanfd.create_msg_162(self.packer, self.CAN, CC.enabled, CS.msg_162, self.CP, hud_control)) diff --git a/opendbc/car/hyundai/carstate.py b/opendbc/car/hyundai/carstate.py index 06fd94214e..bb2af7975f 100644 --- a/opendbc/car/hyundai/carstate.py +++ b/opendbc/car/hyundai/carstate.py @@ -226,12 +226,12 @@ def update_canfd(self, can_parsers) -> structs.CarState: # TODO: alt signal usage may be described by cp.vl['BLINKERS']['USE_ALT_LAMP'] left_blinker_sig, right_blinker_sig = "LEFT_LAMP", "RIGHT_LAMP" - if self.CP.carFingerprint in (CAR.HYUNDAI_KONA_EV_2ND_GEN, CAR.HYUNDAI_SONATA_2024): + if self.CP.carFingerprint in (CAR.HYUNDAI_KONA_EV_2ND_GEN, CAR.KIA_SORENTO_2024): left_blinker_sig, right_blinker_sig = "LEFT_LAMP_ALT", "RIGHT_LAMP_ALT" ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp(50, cp.vl["BLINKERS"][left_blinker_sig], cp.vl["BLINKERS"][right_blinker_sig]) if self.CP.enableBsm: - alt = "_ALT" if self.CP.carFingerprint == CAR.HYUNDAI_SONATA_2024 else "" + alt = "_ALT" if self.CP.carFingerprint == CAR.KIA_SORENTO_2024 else "" ret.leftBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"][f"FL_INDICATOR{alt}"] != 0 ret.rightBlindspot = cp.vl["BLINDSPOTS_REAR_CORNERS"][f"FR_INDICATOR{alt}"] != 0 @@ -270,7 +270,7 @@ def update_canfd(self, can_parsers) -> structs.CarState: ret.buttonEvents = [*create_button_events(self.cruise_buttons[-1], prev_cruise_buttons, BUTTONS_DICT), *create_button_events(self.main_buttons[-1], prev_main_buttons, {1: ButtonType.mainCruise})] - if self.CP.carFingerprint in (CAR.HYUNDAI_SONATA_2024,): + if self.CP.carFingerprint in (CAR.KIA_SORENTO_2024,): self.msg_161 = copy.copy(cp_cam.vl["MSG_161"]) self.msg_162 = copy.copy(cp_cam.vl["MSG_162"]) @@ -321,7 +321,7 @@ def get_can_parsers_canfd(self, CP): cam_messages += [ ("SCC_CONTROL", 50), ] - if self.CP.carFingerprint in (CAR.HYUNDAI_SONATA_2024,): + if self.CP.carFingerprint in (CAR.KIA_SORENTO_2024,): cam_messages += [ ("MSG_161", 20), ("MSG_162", 20), diff --git a/opendbc/car/hyundai/fingerprints.py b/opendbc/car/hyundai/fingerprints.py index c9d8e49d6c..5e7a7a5d06 100644 --- a/opendbc/car/hyundai/fingerprints.py +++ b/opendbc/car/hyundai/fingerprints.py @@ -197,15 +197,6 @@ b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.07 99211-L1000 211223', ], }, - CAR.HYUNDAI_SONATA_2024: { - (Ecu.fwdRadar, 0x7d0, None): [ - b'\xf1\x00DN8_ RDR ----- 1.00 1.00 99110-L1800 ', - ], - (Ecu.fwdCamera, 0x7c4, None): [ - b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.01 99211-L1800 230512', - b'\xf1\x00DN8 MFC AT KOR LHD 1.00 1.01 99211-L1800 230512', - ], - }, CAR.HYUNDAI_SONATA_LF: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00LF__ SCC F-CUP 1.00 1.00 96401-C2200 ', @@ -1116,6 +1107,14 @@ b'\xf1\x00MQ4_ SCC FHCUP 1.00 1.06 99110-P2000 ', b'\xf1\x00MQ4_ SCC FHCUP 1.00 1.08 99110-P2000 ', ], + }, + CAR.KIA_SORENTO_2024: { + (Ecu.fwdCamera, 0x7c4, None): [ + b'\xf1\x00MQ4 MFC AT AUS RHD 1.01 1.04 99210-P2550 231127', + ], + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00MQ4_ RDR ----- 1.00 1.01 99110-P2500 ', + ], }, CAR.KIA_SORENTO_HEV_4TH_GEN: { (Ecu.fwdCamera, 0x7c4, None): [ diff --git a/opendbc/car/hyundai/values.py b/opendbc/car/hyundai/values.py index 4b726757d3..8352993e63 100644 --- a/opendbc/car/hyundai/values.py +++ b/opendbc/car/hyundai/values.py @@ -271,10 +271,6 @@ class CAR(Platforms): CarSpecs(mass=1513, wheelbase=2.84, steerRatio=13.27 * 1.15, tireStiffnessFactor=0.65), # 15% higher at the center seems reasonable flags=HyundaiFlags.MANDO_RADAR | HyundaiFlags.CHECKSUM_CRC8, ) - HYUNDAI_SONATA_2024 = HyundaiCanFDPlatformConfig( - [HyundaiCarDocs("Hyundai Sonata 2024", "All", car_parts=CarParts.common([CarHarness.hyundai_a]))], - CarSpecs(mass=1556, wheelbase=2.84, steerRatio=12.81), - ) HYUNDAI_SONATA_LF = HyundaiPlatformConfig( [HyundaiCarDocs("Hyundai Sonata 2018-19", car_parts=CarParts.common([CarHarness.hyundai_e]))], CarSpecs(mass=1536, wheelbase=2.804, steerRatio=13.27 * 1.15), # 15% higher at the center seems reasonable @@ -461,6 +457,10 @@ class CAR(Platforms): CarSpecs(mass=3957 * CV.LB_TO_KG, wheelbase=2.81, steerRatio=13.5), # average of the platforms flags=HyundaiFlags.RADAR_SCC, ) + KIA_SORENTO_2024 = HyundaiCanFDPlatformConfig( + [HyundaiCarDocs("Kia Sorento 2024", car_parts=CarParts.common([CarHarness.hyundai_a]))], + CarSpecs(mass=3957 * CV.LB_TO_KG, wheelbase=2.81, steerRatio=13.5), + ) KIA_SORENTO_HEV_4TH_GEN = HyundaiCanFDPlatformConfig( [ HyundaiCarDocs("Kia Sorento Hybrid 2021-23", "All", car_parts=CarParts.common([CarHarness.hyundai_a])), diff --git a/opendbc/car/tests/routes.py b/opendbc/car/tests/routes.py index 3252b22bfb..75310296ba 100644 --- a/opendbc/car/tests/routes.py +++ b/opendbc/car/tests/routes.py @@ -130,7 +130,6 @@ class CarTestRoute(NamedTuple): CarTestRoute("6a42c1197b2a8179|2023-09-21--10-23-44", HYUNDAI.KIA_OPTIMA_H_G4_FL), CarTestRoute("c75a59efa0ecd502|2021-03-11--20-52-55", HYUNDAI.KIA_SELTOS), CarTestRoute("5b7c365c50084530|2020-04-15--16-13-24", HYUNDAI.HYUNDAI_SONATA), - CarTestRoute("4267ea8a353cdb36/00000262--8a427003c7", HYUNDAI.HYUNDAI_SONATA_2024), CarTestRoute("b2a38c712dcf90bd|2020-05-18--18-12-48", HYUNDAI.HYUNDAI_SONATA_LF), CarTestRoute("c344fd2492c7a9d2|2023-12-11--09-03-23", HYUNDAI.HYUNDAI_STARIA_4TH_GEN), CarTestRoute("fb3fd42f0baaa2f8|2022-03-30--15-25-05", HYUNDAI.HYUNDAI_TUCSON), @@ -138,6 +137,7 @@ class CarTestRoute(NamedTuple): CarTestRoute("36e10531feea61a4|2022-07-25--13-37-42", HYUNDAI.HYUNDAI_TUCSON_4TH_GEN), # hybrid CarTestRoute("5875672fc1d4bf57|2020-07-23--21-33-28", HYUNDAI.KIA_SORENTO), CarTestRoute("1d0d000db3370fd0|2023-01-04--22-28-42", HYUNDAI.KIA_SORENTO_4TH_GEN, segment=5), + CarTestRoute("60380edf6d76cb45/00000004--e450afc26c", HYUNDAI.KIA_SORENTO_2024), CarTestRoute("fc19648042eb6896|2023-08-16--11-43-27", HYUNDAI.KIA_SORENTO_HEV_4TH_GEN, segment=14), CarTestRoute("628935d7d3e5f4f7|2022-11-30--01-12-46", HYUNDAI.KIA_SORENTO_HEV_4TH_GEN), # plug-in hybrid CarTestRoute("9c917ba0d42ffe78|2020-04-17--12-43-19", HYUNDAI.HYUNDAI_PALISADE), diff --git a/opendbc/car/torque_data/override.toml b/opendbc/car/torque_data/override.toml index 936bb69fb2..d4866933c5 100644 --- a/opendbc/car/torque_data/override.toml +++ b/opendbc/car/torque_data/override.toml @@ -72,7 +72,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "HYUNDAI_STARIA_4TH_GEN" = [1.8, 2.0, 0.15] "GENESIS_GV70_ELECTRIFIED_1ST_GEN" = [1.9, 1.9, 0.09] "GENESIS_G80_2ND_GEN_FL" = [2.5819356441497803, 2.5, 0.11244568973779678] -"HYUNDAI_SONATA_2024" = [2.5, 2.5, 0.1] +"KIA_SORENTO_2024" = [2.5, 2.5, 0.1] # Dashcam or fallback configured as ideal car "MOCK" = [10.0, 10, 0.0]