Skip to content

Commit

Permalink
VW PQ: update carAPI long values, make the behavior not linear
Browse files Browse the repository at this point in the history
  • Loading branch information
dkiiv committed Oct 1, 2024
1 parent 6df0333 commit 53e3f52
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions selfdrive/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def __init__(self, dbc_name, CP, VM):
self.last_button_frame = 0
self.accel_last = 0

self.deviationBP = [-0.08, 0.] # accel (m/s squared)
self.deviationV = [0., 0.15] # comfort-band (m/s squared)
self.rateLimitBP = [-0.3, 0.] # accel (m/s squared)
self.ratelimitV = [4., 0.50] # jerk-limits (m/s squared)
self.deviationBP = [-0.05, -0.03, -0.02, 0.] # accel (m/s squared)
self.deviationV = [0., 0.1, 0.13, 0.15] # comfort-band (m/s squared)
self.rateLimitBP = [-0.2, -0.13, -0.05, 0.] # accel (m/s squared)
self.ratelimitV = [4., 2., 0.75, 0.50] # jerk-limits (m/s squared)
# SMA to EMA conversion: alpha = 2 / (n + 1) n = SMA-sample
self.longSignalSmooth = 0.00664 # closer to 0 = more smoothing, 1 = no smoothing (eq = 300 SMA-sample)
self.accel_diff_smoothed = 0
Expand Down Expand Up @@ -156,8 +156,8 @@ def update(self, CC, CS, now_nanos):
self.accel_diff_smoothed = (self.longSignalSmooth * accel_diff) + (1 - self.longSignalSmooth) * getattr(self, 'accel_diff_smoothed', 0)
deviation_lookup = interp(self.accel_diff_smoothed, self.deviationBP, self.deviationV)
ratelimit_lookup = interp(self.accel_diff_smoothed, self.rateLimitBP, self.ratelimitV)
clip(deviation_lookup, self.deviationV[0], self.deviationV[1])
clip(ratelimit_lookup, self.ratelimitV[1], self.ratelimitV[0])
clip(deviation_lookup, self.deviationV[0], self.deviationV[3])
clip(ratelimit_lookup, self.ratelimitV[3], self.ratelimitV[0])
self.long_deviation = (0.019 * deviation_lookup) + (1 - 0.019) * getattr(self, 'long_deviation', 0)
self.long_ratelimit = (0.009 * ratelimit_lookup) + (1 - 0.009) * getattr(self, 'long_ratelimit', 0)
self.accel_last = self.accel_last if accel == -3.5 else accel
Expand Down

0 comments on commit 53e3f52

Please sign in to comment.