From b18c9ec1ae405300a17376551ae00b10aa46412e Mon Sep 17 00:00:00 2001 From: actuallylemoncurd Date: Thu, 7 Nov 2024 20:40:40 -0500 Subject: [PATCH] VW PQ: relax the decel training wheels * refactor EPB layout, add rate limit to EPB signal --- selfdrive/car/volkswagen/carcontroller.py | 8 +++++--- selfdrive/car/volkswagen/values.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/volkswagen/carcontroller.py b/selfdrive/car/volkswagen/carcontroller.py index d832cf23872a64..89aacc1151f442 100644 --- a/selfdrive/car/volkswagen/carcontroller.py +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -155,13 +155,14 @@ def update(self, CC, CS, now_nanos): self.accel_diff = (0.0019 * (accel - self.accel_last)) + (1 - 0.0019) * self.accel_diff # 1000 SMA equivalence self.long_deviation = interp(abs(accel - self.accel_diff), [0, .2, .3], [.13, .1, 0]) # floating comfort band calculation self.long_ratelimit = (0.019 * (clip(abs(accel), 0.7, 3))) + (1 - 0.019) * self.long_ratelimit # set jerk/rate limit based on accel - self.accel_last = accel if self.CCS == pqcan and CC.longActive and actuators.accel <= 0 and CS.out.vEgoRaw <= 5: - self.EPB_brake = clip(actuators.accel, self.CCP.ACCEL_MIN, 0) if self.EPB_enable else 0 if not self.EPB_enable: self.EPB_counter = 0 # Reset frame counter when EPB_enable is first activated - self.EPB_enable = 1 + self.EPB_brake = 0 + else: + self.EPB_brake = clip(accel, self.accel_last - self.long_ratelimit, self.accel_last + self.long_ratelimit) + self.EPB_enable = 1 else: acc_control = 0 if acc_control != 6 and self.EPB_enable else acc_control # Pulse ACC status to 0 for one frame self.EPB_enable = 0 @@ -176,6 +177,7 @@ def update(self, CC, CS, now_nanos): else: self.EPB_counter = 0 + self.accel_last = accel if self.CCS == pqcan: can_sends.append(self.CCS.create_epb_control(self.packer_pt, CANBUS.br, self.EPB_brake, self.EPB_enable)) can_sends.extend(self.CCS.create_acc_accel_control(self.packer_pt, CANBUS.pt, CS.acc_type, accel, diff --git a/selfdrive/car/volkswagen/values.py b/selfdrive/car/volkswagen/values.py index 8efc914cf951bf..a4c13a82111ac4 100644 --- a/selfdrive/car/volkswagen/values.py +++ b/selfdrive/car/volkswagen/values.py @@ -37,7 +37,7 @@ class CarControllerParams: DEFAULT_MIN_STEER_SPEED = 0.4 # m/s, newer EPS racks fault below this speed, don't show a low speed alert ACCEL_MAX = 2.0 # 2.0 m/s max acceleration - ACCEL_MIN = -3.5 # 3.5 m/s max deceleration + ACCEL_MIN = -5.0 # 3.5 m/s max deceleration def __init__(self, CP): can_define = CANDefine(DBC[CP.carFingerprint]["pt"])