From 4486dc2f14011b114960188e6e8948a4540fdfc2 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 28 Aug 2026 23:12:10 -0500 Subject: [PATCH] steer errors --- opendbc_repo/opendbc/car/hyundai/carcontroller.py | 8 ++++++++ .../opendbc/car/hyundai/tests/test_hyundai.py | 11 ++++++++++- opendbc_repo/opendbc/car/toyota/carcontroller.py | 9 +-------- opendbc_repo/opendbc/car/toyota/tests/test_toyota.py | 5 ----- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/carcontroller.py b/opendbc_repo/opendbc/car/hyundai/carcontroller.py index eab034279..278f5389e 100644 --- a/opendbc_repo/opendbc/car/hyundai/carcontroller.py +++ b/opendbc_repo/opendbc/car/hyundai/carcontroller.py @@ -431,6 +431,12 @@ def suppress_redundant_gv70_brake_cancel(CP, brake_pressed: bool, lat_active: bo ) +def clear_ioniq_6_torque_when_request_inactive(CP, apply_torque: int, apply_steer_req: bool) -> int: + if CP.carFingerprint == CAR.HYUNDAI_IONIQ_6 and not apply_steer_req: + return 0 + return apply_torque + + class CarController(CarControllerBase): def __init__(self, dbc_names, CP): super().__init__(dbc_names, CP) @@ -613,6 +619,8 @@ class CarController(CarControllerBase): if not CC.latActive: apply_torque = 0 + apply_torque = clear_ioniq_6_torque_when_request_inactive(self.CP, apply_torque, apply_steer_req) + # Hold torque with induced temporary fault when cutting the actuation bit # FIXME: we don't use this with CAN FD? torque_fault = CC.latActive and not apply_steer_req diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index 824876b5b..2024b2f53 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -20,7 +20,8 @@ from opendbc.car.hyundai.carcontroller import CarController, Ioniq6LongitudinalT should_track_stop_accel_directly_for_car, \ preserve_stock_canfd_lfa_status, \ preserve_stock_canfd_lkas_status, \ - suppress_redundant_gv70_brake_cancel + suppress_redundant_gv70_brake_cancel, \ + clear_ioniq_6_torque_when_request_inactive from opendbc.car.hyundai.carstate import CarState, decode_canfd_camera_lead, decode_ioniq_6_blindspot_radar_state, \ get_canfd_cruise_available from opendbc.car.hyundai.interface import CarInterface, KIA_EV9_ACCEL_MAX @@ -554,6 +555,14 @@ class TestHyundaiFingerprint: assert not (CP.flags & HyundaiFlags.CANFD_LKA_STEERING) assert bool(CP.flags & HyundaiFlags.CANFD_CAMERA_SCC) + def test_ioniq_6_clears_torque_with_inactive_safety_request(self): + ioniq_6_cp = SimpleNamespace(carFingerprint=CAR.HYUNDAI_IONIQ_6) + other_cp = SimpleNamespace(carFingerprint=CAR.KIA_EV6) + + assert clear_ioniq_6_torque_when_request_inactive(ioniq_6_cp, -409, False) == 0 + assert clear_ioniq_6_torque_when_request_inactive(ioniq_6_cp, -409, True) == -409 + assert clear_ioniq_6_torque_when_request_inactive(other_cp, -409, False) == -409 + palisade_2023 = CarInterface.get_params(CAR.HYUNDAI_PALISADE_2023, gen_empty_fingerprint(), [], True, False, False, None) assert palisade_2023.flags & HyundaiFlags.CAN_CANFD_BLENDED assert DBC[palisade_2023.carFingerprint][Bus.pt] == "hyundai_palisade_2023_generated" diff --git a/opendbc_repo/opendbc/car/toyota/carcontroller.py b/opendbc_repo/opendbc/car/toyota/carcontroller.py index df7548977..fe6c84964 100644 --- a/opendbc_repo/opendbc/car/toyota/carcontroller.py +++ b/opendbc_repo/opendbc/car/toyota/carcontroller.py @@ -42,7 +42,6 @@ TOYOTA_NO_LEAD_CRUISE_SIGN_FLIP_MIN_SET_SPEED_ERROR = 0.35 # m/s # EPS faults if you apply torque while the steering rate is above 100 deg/s for too long MAX_STEER_RATE = 100 # deg/s MAX_STEER_RATE_FRAMES = 18 # tx control frames needed before torque can be cut -TOYOTA_HIGHLANDER_TSS2_MAX_STEER_RATE_FRAMES = 8 # EPS allows user torque above threshold for 50 frames before permanently faulting MAX_USER_TORQUE = 500 @@ -73,11 +72,6 @@ def should_bypass_toyota_long_pid(CP, starpilot_toggles=None) -> bool: ) or highlander_sdsu) -def get_steer_rate_limit_frames(car_fingerprint) -> int: - return (TOYOTA_HIGHLANDER_TSS2_MAX_STEER_RATE_FRAMES - if car_fingerprint == CAR.TOYOTA_HIGHLANDER_TSS2 else MAX_STEER_RATE_FRAMES) - - def get_long_tune(CP, params): kiBP = [2., 5.] kiV = [0.5, 0.25] @@ -229,7 +223,6 @@ class CarController(CarControllerBase): self.standstill_req = False self.permit_braking = True self.steer_rate_counter = 0 - self.steer_rate_limit_frames = get_steer_rate_limit_frames(self.CP.carFingerprint) self.distance_button = 0 # *** start long control state *** @@ -354,7 +347,7 @@ class CarController(CarControllerBase): # >100 degree/sec steering fault prevention self.steer_rate_counter, apply_steer_req = common_fault_avoidance( abs(CS.out.steeringRateDeg) >= MAX_STEER_RATE, lat_active, - self.steer_rate_counter, self.steer_rate_limit_frames, + self.steer_rate_counter, MAX_STEER_RATE_FRAMES, ) if not lat_active: diff --git a/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py b/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py index d11fe5cee..b16bef762 100644 --- a/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py +++ b/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py @@ -10,7 +10,6 @@ from opendbc.car.fw_versions import build_fw_dict, match_fw_to_car from opendbc.car.toyota import toyotacan from opendbc.car.toyota.carcontroller import CarController, get_camry_hybrid_feedforward, get_long_tune, get_prius_feedforward, \ get_prius_positive_feedforward_scale, \ - get_steer_rate_limit_frames, \ limit_interceptor_pcm_accel, \ limit_interceptor_stopping_accel, limit_no_lead_cruise_sign_flip, \ limit_prius_stopping_accel, should_bypass_toyota_long_pid, update_permit_braking @@ -707,10 +706,6 @@ class TestToyotaFingerprint: class TestToyotaCarController: - def test_highlander_tss2_uses_early_steer_rate_fault_guard(self): - assert get_steer_rate_limit_frames(CAR.TOYOTA_HIGHLANDER_TSS2) == 8 - assert get_steer_rate_limit_frames(CAR.TOYOTA_RAV4_TSS2) == 18 - @staticmethod def _make_controller(*, standstill_req=False, last_standstill=False): controller = CarController.__new__(CarController)