From bc57172b36ecc4922dba699e48bf0d57a7f3d539 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 2 Dec 2022 23:46:26 -0800 Subject: [PATCH] Hyundai: setup alt steering limits (#26685) * Hyundai: setup alt steering limits * value * bump panda old-commit-hash: 122c3143589418b74dd6b658607ac5c8d43fb4af --- panda | 2 +- selfdrive/car/hyundai/carcontroller.py | 3 --- selfdrive/car/hyundai/interface.py | 4 ++++ selfdrive/car/hyundai/values.py | 8 ++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/panda b/panda index 616450c52..4edd1a602 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 616450c525a7c1ef508f70f30e29547a606139aa +Subproject commit 4edd1a602131ec2f09a604a4bd28e7d00e334458 diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index e5fdbfd57..3f128b159 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -60,9 +60,6 @@ class CarController: # steering torque steer = actuators.steer - if self.CP.carFingerprint in (CAR.KONA, CAR.KONA_EV, CAR.KONA_HEV, CAR.KONA_EV_2022): - # these cars have significantly more torque than most HKG; limit to 70% of max - steer = clip(steer, -0.7, 0.7) new_steer = int(round(steer * self.params.STEER_MAX)) apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, self.params) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index cb4d9a968..7b157d048 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -267,6 +267,10 @@ class CarInterface(CarInterfaceBase): elif candidate in EV_CAR: ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_EV_GAS + if candidate in (CAR.KONA, CAR.KONA_EV, CAR.KONA_HEV, CAR.KONA_EV_2022): + ret.flags |= HyundaiFlags.ALT_LIMITS.value + ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_ALT_LIMITS + ret.centerToFront = ret.wheelbase * 0.4 # TODO: start from empirically derived lateral slip stiffness for the civic and scale by diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 7ecb07e7d..e5f180a51 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -39,6 +39,12 @@ class CarControllerParams: CAR.KIA_OPTIMA_H, CAR.KIA_SORENTO): self.STEER_MAX = 255 + # these cars have significantly more torque than most HKG; limit to 70% of max + elif CP.flags & HyundaiFlags.ALT_LIMITS: + self.STEER_MAX = 270 + self.STEER_DELTA_UP = 2 + self.STEER_DELTA_DOWN = 3 + # Default for most HKG else: self.STEER_MAX = 384 @@ -50,6 +56,8 @@ class HyundaiFlags(IntFlag): CANFD_ALT_GEARS = 4 CANFD_CAMERA_SCC = 8 + ALT_LIMITS = 16 + class CAR: # Hyundai