Skip to content

Commit

Permalink
VW updates
Browse files Browse the repository at this point in the history
* bump long kf
* add BR8_Laengsbeschl to EPB brake init calculation
* refactor RegelAbw control, link to speed with roll off for high accel demand, and clip range
  • Loading branch information
dkiiv committed Nov 16, 2024
1 parent 2022508 commit ddc2faf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions selfdrive/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ def update(self, CC, CS, now_nanos):
accel = clip(actuators.accel, self.CCP.ACCEL_MIN, self.CCP.ACCEL_MAX) if CC.longActive else 0
# SMA to EMA conversion: alpha = 2 / (n + 1) n = SMA-sample
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, .3, 1.], [.25, .25, 0]) # floating comfort band calculation
self.long_jerklimit = (0.01 * (clip(abs(accel), 0.7, 2))) + (1 - 0.01) * self.long_jerklimit # set jerk limit based on accel
self.long_deviation = clip(CS.out.vEgo/40, 0, 0.25) * interp(abs(accel - self.accel_diff), [0, .3, 1.], [1.0, 1.0, 0.0])

if self.CCS == pqcan and CC.longActive and actuators.accel <= 0 and CS.out.vEgoRaw <= 5:
if not self.EPB_enable: # first frame of EPB entry
self.EPB_counter = 0
self.EPB_brake = 0
self.EPB_brake_last = accel
self.EPB_brake_last = accel - (CS.aEgoBremse / 2)
self.EPB_enable = 1
else:
self.EPB_brake = limit_jerk(accel, self.EPB_brake_last, 0.7, 0.02)
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/car/volkswagen/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, CP):
self.esp_hold_confirmation = False
self.upscale_lead_car_signal = False
self.eps_stock_values = False
self.aEgoBremse = 0

def create_button_events(self, pt_cp, buttons):
button_events = []
Expand Down Expand Up @@ -180,6 +181,8 @@ def update_pq(self, pt_cp, cam_cp, ext_cp, trans_type):
ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw)
ret.standstill = ret.vEgoRaw == 0

self.aEgoBremse = pt_cp.vl["Bremse_8"]["BR8_Laengsbeschl"]

# Update EPS position and state info. For signed values, VW sends the sign in a separate signal.
ret.steeringAngleDeg = pt_cp.vl["Lenkhilfe_3"]["LH3_BLW"] * (1, -1)[int(pt_cp.vl["Lenkhilfe_3"]["LH3_BLWSign"])]
ret.steeringRateDeg = pt_cp.vl["Lenkwinkel_1"]["Lenkradwinkel_Geschwindigkeit"] * (1, -1)[int(pt_cp.vl["Lenkwinkel_1"]["Lenkradwinkel_Geschwindigkeit_S"])]
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/volkswagen/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _get_params(ret, candidate: CAR, fingerprint, car_fw, experimental_long, doc
ret.steerLimitTimer = 0.4
if ret.flags & VolkswagenFlags.PQ:
ret.steerActuatorDelay = 0.11
ret.longitudinalTuning.kf = 1.1
ret.longitudinalTuning.kf = 1.2
ret.longitudinalTuning.kpBP = [0.]
ret.longitudinalTuning.kpV = [0.]
ret.longitudinalTuning.kiBP = [0., 11, 22, 35]
Expand Down

0 comments on commit ddc2faf

Please sign in to comment.