Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VW MQB: AEB actuation setup #1229

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions opendbc/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, dbc_name, CP):
self.CCS = pqcan if CP.flags & VolkswagenFlags.PQ else mqbcan
self.packer_pt = CANPacker(dbc_name)
self.ext_bus = CANBUS.pt if CP.networkLocation == structs.CarParams.NetworkLocation.fwdCamera else CANBUS.cam
self.aeb_available = not CP.flags & VolkswagenFlags.PQ

self.apply_steer_last = 0
self.gra_acc_counter_last = None
Expand Down Expand Up @@ -76,13 +77,20 @@ def update(self, CC, CS, now_nanos):

# **** Acceleration Controls ******************************************** #

if self.frame % self.CCP.ACC_CONTROL_STEP == 0 and self.CP.openpilotLongitudinalControl:
acc_control = self.CCS.acc_control_value(CS.out.cruiseState.available, CS.out.accFaulted, CC.longActive)
accel = clip(actuators.accel, self.CCP.ACCEL_MIN, self.CCP.ACCEL_MAX) if CC.longActive else 0
stopping = actuators.longControlState == LongCtrlState.stopping
starting = actuators.longControlState == LongCtrlState.pid and (CS.esp_hold_confirmation or CS.out.vEgo < self.CP.vEgoStopping)
can_sends.extend(self.CCS.create_acc_accel_control(self.packer_pt, CANBUS.pt, CS.acc_type, CC.longActive, accel,
acc_control, stopping, starting, CS.esp_hold_confirmation))
if self.CP.openpilotLongitudinalControl:
if self.frame % self.CCP.ACC_CONTROL_STEP == 0:
acc_control = self.CCS.acc_control_value(CS.out.cruiseState.available, CS.out.accFaulted, CC.longActive)
accel = clip(actuators.accel, self.CCP.ACCEL_MIN, self.CCP.ACCEL_MAX) if CC.longActive else 0
stopping = actuators.longControlState == LongCtrlState.stopping
starting = actuators.longControlState == LongCtrlState.pid and (CS.esp_hold_confirmation or CS.out.vEgo < self.CP.vEgoStopping)
can_sends.extend(self.CCS.create_acc_accel_control(self.packer_pt, CANBUS.pt, CS.acc_type, CC.longActive, accel,
acc_control, stopping, starting, CS.esp_hold_confirmation))

if self.aeb_available:
if self.frame % self.CCP.AEB_CONTROL_STEP == 0:
can_sends.append(self.CCS.create_aeb_control(self.packer_pt, False, False, 0.0))
if self.frame % self.CCP.AEB_HUD_STEP == 0:
can_sends.append(self.CCS.create_aeb_hud(self.packer_pt, False, False))

# **** HUD Controls ***************************************************** #

Expand Down
32 changes: 32 additions & 0 deletions opendbc/car/volkswagen/mqbcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,35 @@ def create_acc_hud_control(packer, bus, acc_hud_status, set_speed, lead_distance
}

return packer.make_can_msg("ACC_02", bus, values)


# AWV = Stopping Distance Reduction
# Refer to Self Study Program 890253: Volkswagen Driver Assistance Systems, Design and Function


def create_aeb_control(packer, fcw_active, aeb_active, accel):
values = {
"AWV_Vorstufe": 0, # Preliminary stage
"AWV1_Anf_Prefill": 0, # Brake pre-fill request
"AWV1_HBA_Param": 0, # Brake pre-fill level
"AWV2_Freigabe": 0, # Stage 2 braking release
"AWV2_Ruckprofil": 0, # Brake jerk level
"AWV2_Priowarnung": 0, # Suppress lane departure warning in favor of FCW
"ANB_Notfallblinken": 0, # Hazard flashers request
"ANB_Teilbremsung_Freigabe": 0, # Target braking release
"ANB_Zielbremsung_Freigabe": 0, # Partial braking release
"ANB_Zielbrems_Teilbrems_Verz_Anf": 0.0, # Acceleration requirement for target/partial braking, m/s/s
"AWV_Halten": 0, # Vehicle standstill request
"PCF_Time_to_collision": 0xFF, # Pre Crash Front, populated only with a target, might be used on Audi only
}

return packer.make_can_msg("ACC_10", 0, values)


def create_aeb_hud(packer, aeb_supported, fcw_active):
values = {
"AWV_Texte": 5 if aeb_supported else 7, # FCW/AEB system status, display text (from menu in VAL)
"AWV_Status_Anzeige": 1 if aeb_supported else 2, # FCW/AEB system status, available or disabled
}

return packer.make_can_msg("ACC_15", 0, values)
2 changes: 2 additions & 0 deletions opendbc/car/volkswagen/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
class CarControllerParams:
STEER_STEP = 2 # HCA_01/HCA_1 message frequency 50Hz
ACC_CONTROL_STEP = 2 # ACC_06/ACC_07/ACC_System frequency 50Hz
AEB_CONTROL_STEP = 2 # ACC_10 frequency 50Hz
AEB_HUD_STEP = 20 # ACC_15 frequency 5Hz

# Documented lateral limits: 3.00 Nm max, rate of change 5.00 Nm/sec.
# MQB vs PQ maximums are shared, but rate-of-change limited differently
Expand Down
Loading