diff --git a/opendbc_repo/opendbc/car/hyundai/fingerprints.py b/opendbc_repo/opendbc/car/hyundai/fingerprints.py index 05d6305dd3..8d860036e7 100644 --- a/opendbc_repo/opendbc/car/hyundai/fingerprints.py +++ b/opendbc_repo/opendbc/car/hyundai/fingerprints.py @@ -1536,12 +1536,18 @@ FW_VERSIONS = { (Ecu.eps, 0x7d4, None): [ b'\xf1\x00OS MDPS C 1.00 1.05 56310J9030\x00 4OSDC105', b'\xf1\x00OS MDPS C 1.00 1.04 56310J9030\x00 4OSDC104', + b'\xf1\x00OS MDPS C 1.00 1.05 56310/J9500 4OSDC105', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00OS9 LKAS AT USA LHD 1.00 1.00 95740-J9200 g30', + b'\xf1\x00OS9 LKAS AT AUS RHD 1.00 1.00 95740-J9200 g30', + ], + (Ecu.fwdRadar, 0x7d0, None): [ + b'\xf1\x00OS__ FCA --CUP 1.00 1.00 95655-J9100 ', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x006T6J0_C2\x00\x006T6K1051\x00\x00TOS4N20NS2\x00\x00\x00\x00', + b'\xf1\x006U2V0_C2\x00\x006U2V1051\x00\x00DOS4T16AS2\x00\x00\x00\x00', ], }, CAR.KIA_FORTE_2019_NON_SCC: { diff --git a/opendbc_repo/opendbc/car/hyundai/interface.py b/opendbc_repo/opendbc/car/hyundai/interface.py index 3d122a2657..a043060b4e 100644 --- a/opendbc_repo/opendbc/car/hyundai/interface.py +++ b/opendbc_repo/opendbc/car/hyundai/interface.py @@ -24,6 +24,7 @@ ENABLE_BUTTONS = (ButtonType.accelCruise, ButtonType.decelCruise, ButtonType.can # Track when ECU disable happened - used to permanently suppress CAN errors from disabled ECU ECU_DISABLE_TIMESTAMP = 0.0 +KONA_NON_SCC_FCA_RADAR_ADDR = 0x602 def apply_platform_longitudinal_params(ret: structs.CarParams) -> None: @@ -45,6 +46,18 @@ def apply_ecu_disable_failure_fallback(CP: structs.CarParams, params) -> None: CP.pcmCruise = True +def detect_kona_non_scc_radar_fca(candidate, fingerprint, car_fw) -> bool: + if candidate != CAR.HYUNDAI_KONA_NON_SCC: + return False + + if any(fw.ecu == Ecu.fwdRadar for fw in car_fw): + return True + + # Some non-SCC Kona trims have FCA radar tracks without SCC. Use PT FCA11 + # status on those cars; camera-bus FCA11 is not continuously published. + return KONA_NON_SCC_FCA_RADAR_ADDR in fingerprint[1] + + class CarInterface(CarInterfaceBase): CarState = CarState CarController = CarController @@ -136,6 +149,8 @@ class CarInterface(CarInterfaceBase): # These cars use the FCA11 message for the AEB and FCW signals, all others use SCC12 if 0x38d in fingerprint[CAN.ECAN] or 0x38d in fingerprint[CAN.CAM]: ret.flags |= HyundaiFlags.USE_FCA.value + if detect_kona_non_scc_radar_fca(candidate, fingerprint, car_fw): + ret.flags |= HyundaiFlags.NON_SCC_RADAR_FCA.value if ret.flags & HyundaiFlags.LEGACY: # these cars require a special panda safety mode due to missing counters and checksums in the messages diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index 5a2100172b..0303d1cd35 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -289,6 +289,21 @@ class TestHyundaiFingerprint: elantra_hev = CarInterface.get_params(CAR.HYUNDAI_ELANTRA_HEV_2022_NON_SCC, gen_empty_fingerprint(), [], True, False, False, None) assert elantra_hev.flags & HyundaiFlags.HYBRID + kona = CarInterface.get_params(CAR.HYUNDAI_KONA_NON_SCC, gen_empty_fingerprint(), [], True, False, False, None) + assert not (kona.flags & HyundaiFlags.NON_SCC_RADAR_FCA) + assert kona.radarUnavailable + + fingerprint = gen_empty_fingerprint() + fingerprint[0][0x38d] = 8 + fingerprint[1][MRREVO14F_RADAR_START_ADDR] = 8 + kona_radar_fca = CarInterface.get_params(CAR.HYUNDAI_KONA_NON_SCC, fingerprint, [], True, False, False, None) + assert kona_radar_fca.flags & HyundaiFlags.NON_SCC_RADAR_FCA + assert not kona_radar_fca.radarUnavailable + + car_fw = [CarParams.CarFw(ecu=Ecu.fwdRadar, fwVersion=b"", address=0x7d0, brand="hyundai")] + kona_radar_fw = CarInterface.get_params(CAR.HYUNDAI_KONA_NON_SCC, gen_empty_fingerprint(), car_fw, True, False, False, None) + assert kona_radar_fw.flags & HyundaiFlags.NON_SCC_RADAR_FCA + forte_2019 = CarInterface.get_params(CAR.KIA_FORTE_2019_NON_SCC, gen_empty_fingerprint(), [], True, False, False, None) assert forte_2019.flags & HyundaiFlags.NON_SCC_NO_FCA assert not (forte_2019.flags & HyundaiFlags.NON_SCC_RADAR_FCA) @@ -487,6 +502,24 @@ class TestHyundaiFingerprint: def test_kona_ev_non_scc_has_no_dedicated_fw_coverage(self): assert CAR.HYUNDAI_KONA_EV_NON_SCC not in FW_VERSIONS + def test_kona_non_scc_fca_radar_fw_is_optional(self): + fw_versions = FW_VERSIONS[CAR.HYUNDAI_KONA_NON_SCC] + car_fw = [ + CarParams.CarFw( + ecu=ecu, + fwVersion=versions[0], + address=address, + subAddress=0 if sub_address is None else sub_address, + brand="hyundai", + ) + for (ecu, address, sub_address), versions in fw_versions.items() + if ecu != Ecu.fwdRadar + ] + + exact, matches = match_fw_to_car(car_fw, "", allow_exact=True, allow_fuzzy=False, log=False) + assert exact + assert CAR.HYUNDAI_KONA_NON_SCC in matches + def test_kia_forte_2019_non_scc_does_not_require_fca11_or_scc12(self): toggles = get_test_toggles() CP = CarInterface.get_params(CAR.KIA_FORTE_2019_NON_SCC, gen_empty_fingerprint(), [], True, False, False, toggles) diff --git a/opendbc_repo/opendbc/car/hyundai/values.py b/opendbc_repo/opendbc/car/hyundai/values.py index ccc2c96f1d..0a439161b7 100644 --- a/opendbc_repo/opendbc/car/hyundai/values.py +++ b/opendbc_repo/opendbc/car/hyundai/values.py @@ -254,8 +254,12 @@ class HyundaiCanFDPlatformConfig(PlatformConfig): @dataclass class HyundaiNonSccPlatformConfig(PlatformConfig): dbc_dict: DbcDict = field(default_factory=lambda: {Bus.pt: "hyundai_kia_generic"}) + radar_dbc: str | None = None def init(self): + if self.radar_dbc is not None: + self.dbc_dict = {Bus.pt: "hyundai_kia_generic", Bus.radar: self.radar_dbc} + self.flags |= HyundaiFlags.NON_SCC if self.flags & HyundaiFlags.MIN_STEER_32_MPH: @@ -882,6 +886,7 @@ class CAR(Platforms): [HyundaiNonSccCarDocs("Hyundai Kona Non-SCC 2019", car_parts=CarParts.common([CarHarness.hyundai_b]))], HYUNDAI_KONA.specs, flags=HyundaiFlags.ALT_LIMITS, + radar_dbc=HYUNDAI_MRREVO14F_RADAR_DBC, ) HYUNDAI_KONA_EV_NON_SCC = HyundaiNonSccPlatformConfig( [HyundaiNonSccCarDocs("Hyundai Kona Electric Non-SCC 2019", car_parts=CarParts.common([CarHarness.hyundai_g]))], @@ -1104,6 +1109,7 @@ FW_QUERY_CONFIG = FwQueryConfig( Ecu.abs: [CAR.HYUNDAI_PALISADE, CAR.HYUNDAI_SONATA, CAR.HYUNDAI_SANTA_FE_2022, CAR.KIA_K5_2021, CAR.HYUNDAI_ELANTRA_2021, CAR.HYUNDAI_SANTA_FE, CAR.HYUNDAI_KONA_EV_2022, CAR.HYUNDAI_KONA_EV, CAR.HYUNDAI_CUSTIN_1ST_GEN, CAR.KIA_SORENTO, CAR.KIA_CEED, CAR.KIA_SELTOS], + Ecu.fwdRadar: [CAR.HYUNDAI_KONA_NON_SCC], }, extra_ecus=[ (Ecu.adas, 0x730, None), # ADAS Driving ECU on platforms with LKA steering diff --git a/selfdrive/controls/lib/latcontrol_torque.py b/selfdrive/controls/lib/latcontrol_torque.py index 12615885f1..3c469842bf 100644 --- a/selfdrive/controls/lib/latcontrol_torque.py +++ b/selfdrive/controls/lib/latcontrol_torque.py @@ -375,10 +375,10 @@ IONIQ_5_TURN_IN_FRICTION_BOOST_LEFT = 0.04 IONIQ_5_TURN_IN_FRICTION_BOOST_RIGHT = 0.00 IONIQ_5_UNWIND_FRICTION_REDUCTION_LEFT = 0.26 IONIQ_5_UNWIND_FRICTION_REDUCTION_RIGHT = 0.26 -IONIQ_5_CENTER_TAPER_MAX = 0.08 -IONIQ_5_CENTER_TAPER_LAT = 0.16 +IONIQ_5_CENTER_TAPER_MAX = 0.10 +IONIQ_5_CENTER_TAPER_LAT = 0.14 IONIQ_5_CENTER_TAPER_LAT_WIDTH = 0.03 -IONIQ_5_CENTER_TAPER_SPEED = 20.0 +IONIQ_5_CENTER_TAPER_SPEED = 18.0 IONIQ_5_CENTER_TAPER_SPEED_WIDTH = 2.5 IONIQ_EV_OLD_BASE_LAT_ACCEL_FACTOR_MULT = 1.16 @@ -472,29 +472,29 @@ IONIQ_6_OUTPUT_DIRECTIONAL_TAPER_BLEND = 0.97 KIA_EV6_LATERAL_TESTING_GROUND_ID = testing_ground.id_6 KIA_EV6_LATERAL_TESTING_GROUND_VARIANT = "C" -KIA_EV6_FF_GAIN_LEFT = 0.07 -KIA_EV6_FF_GAIN_RIGHT = 0.075 +KIA_EV6_FF_GAIN_LEFT = 0.06 +KIA_EV6_FF_GAIN_RIGHT = 0.07 KIA_EV6_FF_ONSET = 0.08 KIA_EV6_FF_ONSET_WIDTH = 0.04 KIA_EV6_FF_CUTOFF = 0.60 KIA_EV6_FF_CUTOFF_WIDTH = 0.14 KIA_EV6_TRANSITION_SPEED = 11.0 KIA_EV6_PHASE_SCALE = 0.09 -KIA_EV6_TURN_IN_BOOST_LEFT = 0.14 -KIA_EV6_TURN_IN_BOOST_RIGHT = 0.16 -KIA_EV6_UNWIND_TAPER_LEFT = 0.40 -KIA_EV6_UNWIND_TAPER_RIGHT = 0.36 +KIA_EV6_TURN_IN_BOOST_LEFT = 0.18 +KIA_EV6_TURN_IN_BOOST_RIGHT = 0.12 +KIA_EV6_UNWIND_TAPER_LEFT = 0.48 +KIA_EV6_UNWIND_TAPER_RIGHT = 0.46 KIA_EV6_FRICTION_MULT = 1.01 KIA_EV6_FRICTION_LAT_RISE = 0.18 KIA_EV6_FRICTION_JERK_RISE = 0.22 KIA_EV6_TURN_IN_THRESHOLD_REDUCTION_LEFT = 0.10 KIA_EV6_TURN_IN_THRESHOLD_REDUCTION_RIGHT = 0.14 -KIA_EV6_UNWIND_THRESHOLD_INCREASE_LEFT = 0.22 -KIA_EV6_UNWIND_THRESHOLD_INCREASE_RIGHT = 0.18 -KIA_EV6_TURN_IN_FRICTION_BOOST_LEFT = 0.03 +KIA_EV6_UNWIND_THRESHOLD_INCREASE_LEFT = 0.28 +KIA_EV6_UNWIND_THRESHOLD_INCREASE_RIGHT = 0.24 +KIA_EV6_TURN_IN_FRICTION_BOOST_LEFT = 0.04 KIA_EV6_TURN_IN_FRICTION_BOOST_RIGHT = 0.05 -KIA_EV6_UNWIND_FRICTION_REDUCTION_LEFT = 0.22 -KIA_EV6_UNWIND_FRICTION_REDUCTION_RIGHT = 0.16 +KIA_EV6_UNWIND_FRICTION_REDUCTION_LEFT = 0.28 +KIA_EV6_UNWIND_FRICTION_REDUCTION_RIGHT = 0.22 KIA_EV6_CENTER_TAPER_MAX = 0.08 KIA_EV6_CENTER_TAPER_LAT = 0.16 KIA_EV6_CENTER_TAPER_LAT_WIDTH = 0.035 diff --git a/selfdrive/controls/tests/test_latcontrol.py b/selfdrive/controls/tests/test_latcontrol.py index 170977ac07..6dd6c62487 100644 --- a/selfdrive/controls/tests/test_latcontrol.py +++ b/selfdrive/controls/tests/test_latcontrol.py @@ -462,7 +462,7 @@ class TestLatControl: right_turn_in = get_kia_ev6_friction_threshold(6.0, -0.5, -0.8) left_unwind = get_kia_ev6_friction_threshold(6.0, 0.5, -0.8) right_unwind = get_kia_ev6_friction_threshold(6.0, -0.5, 0.8) - assert right_turn_in < left_turn_in < base < right_unwind < left_unwind + assert right_turn_in < left_turn_in < base < right_unwind <= left_unwind def test_kia_ev6_friction_scale_curve(self): base = get_kia_ev6_friction_scale(25.0, 0.5, 0.8)