From 1f9ea6628aebcde883df1e7ee173b60a2fc5113d Mon Sep 17 00:00:00 2001 From: rav4kumar Date: Tue, 24 Sep 2024 19:35:30 -0700 Subject: [PATCH] Toyota: prevent lagged gas after heavy braking (#1279) --- selfdrive/car/toyota/carcontroller.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index 0cde68bc8a..a22b013ef5 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -18,7 +18,9 @@ SteerControlType = car.CarParams.SteerControlType VisualAlert = car.CarControl.HUDControl.VisualAlert LongCtrlState = car.CarControl.Actuators.LongControlState -ACCELERATION_DUE_TO_GRAVITY = 9.81 +ACCELERATION_DUE_TO_GRAVITY = 9.81 # m/s^2 + +ACCEL_WINDUP_LIMIT = 0.5 # m/s^2 / frame # LKA limits # EPS faults if you apply torque while the steering rate is above 100 deg/s for too long @@ -231,9 +233,8 @@ class CarController(CarControllerBase): if pcm_cancel_cmd and self.CP.carFingerprint in UNSUPPORTED_DSU_CAR: can_sends.append(toyotacan.create_acc_cancel_command(self.packer)) elif self.CP.openpilotLongitudinalControl: - # internal PCM gas command can get stuck unwinding from negative accel. send one frame of zero when transitioning from braking to gas - #if pcm_accel_cmd > 0 > self.accel and abs(pcm_accel_cmd - self.accel) > 0.5: - # pcm_accel_cmd = 0 + # internal PCM gas command can get stuck unwinding from negative accel so we apply a generous rate limit + pcm_accel_cmd = min(pcm_accel_cmd, self.accel + ACCEL_WINDUP_LIMIT) if CC.longActive else 0.0 can_sends.append(toyotacan.create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type, fcw_alert, self.distance_button, reverse_acc))