Skip to content

Commit

Permalink
VW PQ: update AWV signal controls
Browse files Browse the repository at this point in the history
* add AWV_Halten control
* remove counter. may add back?
* set parameter to 2, OEM parody
  • Loading branch information
dkiiv committed Nov 1, 2024
1 parent f5b9f70 commit 860e377
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions selfdrive/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, dbc_name, CP, VM):
self.motor2_frame = 0
self.AWV_brake = 0
self.AWV_enable = 0
self.AWV_counter = 0
self.AWV_halten = 0

self.deviationBP = [-0.13, -0.1, -0.05, 0.] # accel (m/s squared)
self.deviationV = [0., 0.08, 0.14, 0.15] # comfort-band (m/s squared)
Expand Down Expand Up @@ -155,22 +155,20 @@ def update(self, CC, CS, now_nanos):
acc_control = self.CCS.acc_control_value(CS.out.cruiseState.available, CS.out.accFaulted, CC.longActive, CC.cruiseControl.override)
stopping = actuators.longControlState == LongCtrlState.stopping
starting = actuators.longControlState == LongCtrlState.pid and (CS.esp_hold_confirmation or CS.out.vEgo < self.CP.vEgoStopping)
if self.CCS == pqcan and CC.longActive and (clip(actuators.accel, self.CCP.ACCEL_MIN, self.CCP.ACCEL_MAX) <= 0) and CS.out.vEgoRaw <= 6:
accel = clip(actuators.accel, self.CCP.ACCEL_MIN, 0) if self.AWV_counter <= 10 else 0
if self.CCS == pqcan and CC.longActive and actuators.accel <= 0 and CS.out.vEgoRaw <= 6:
accel = clip(actuators.accel, self.CCP.ACCEL_MIN, 0)
self.AWV_enable = 1
self.AWV_brake = clip(actuators.accel, self.CCP.ACCEL_MIN, 0) if self.AWV_counter >= 11 else 0
self.AWV_counter += 1
self.AWV_brake = clip(actuators.accel, self.CCP.ACCEL_MIN, 0)
else:
accel = clip(actuators.accel, self.CCP.ACCEL_MIN, self.CCP.ACCEL_MAX) if CC.longActive else 0
self.AWV_enable = 0
self.AWV_brake = 0
self.AWV_counter = 0
self.AWV_counter = 11 if self.AWV_counter >= 11 else self.AWV_counter
self.AWV_halten = 1 if CS.out.vEgoRaw <= 2 and self.AWV_enable else 0
self.long_deviation = 0 # TODO: make dynamic again
self.long_ratelimit = 4 # TODO: make dynamic again

if self.CCS == pqcan:
can_sends.append(self.CCS.create_awv_control(self.packer_pt, CANBUS.pt, self.AWV_brake, self.AWV_enable))
can_sends.append(self.CCS.create_awv_control(self.packer_pt, CANBUS.pt, self.AWV_brake, self.AWV_enable, self.AWV_halten))
can_sends.extend(self.CCS.create_acc_accel_control(self.packer_pt, CANBUS.pt, CS.acc_type, accel,
acc_control, stopping, starting, CS.esp_hold_confirmation,
self.long_deviation, self.long_ratelimit))
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/car/volkswagen/pqcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ def create_acc_accel_control(packer, bus, acc_type, accel, acc_control, stopping

return commands

def create_awv_control(packer, bus, apply_brake, enabled):
def create_awv_control(packer, bus, apply_brake, enabled, halten):

values = {
"AWV_1_Parameter": 1 if enabled else 0,
"AWV_1_Parameter": 2 if enabled else 0,
"AWV_1_Prefill": enabled,
"ANB_Teilbremsung_Freigabe": enabled,
"ANB_Ziel_Teilbrems_Verz_Anf": apply_brake if enabled else 0,
"AWV_Halten": 0, # Hold at stop, configure later? Not needed?
"AWV_Halten": halten, # Hold at stop, configure later? Not needed?
}

return packer.make_can_msg("AWV", bus, values)
Expand Down

0 comments on commit 860e377

Please sign in to comment.