From e91143a5904fdfc2948abf6c2189021aebc65a74 Mon Sep 17 00:00:00 2001 From: Jason Young Date: Tue, 13 Sep 2022 22:20:35 -0400 Subject: [PATCH] more cleanup --- selfdrive/car/volkswagen/carcontroller.py | 4 ++-- selfdrive/car/volkswagen/mqbcan.py | 28 ++++++++--------------- selfdrive/car/volkswagen/pqcan.py | 22 +++++++++--------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/selfdrive/car/volkswagen/carcontroller.py b/selfdrive/car/volkswagen/carcontroller.py index b6734c9a3..bf6256759 100644 --- a/selfdrive/car/volkswagen/carcontroller.py +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -70,12 +70,12 @@ class CarController: # **** Acceleration Controls ******************************************** # if self.frame % self.CCP.ACC_CONTROL_STEP == 0 and self.CP.openpilotLongitudinalControl: - acc_status = self.CCS.acc_control_status_value(CS.out.cruiseState.available, CS.out.accFaulted, CC.longActive) + 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.starting can_sends.extend(self.CCS.create_acc_accel_control(self.packer_pt, CANBUS.pt, CS.acc_type, CC.longActive, accel, - acc_status, stopping, starting, CS.out.cruiseState.standstill)) + acc_control, stopping, starting, CS.out.cruiseState.standstill)) # **** HUD Controls ***************************************************** # diff --git a/selfdrive/car/volkswagen/mqbcan.py b/selfdrive/car/volkswagen/mqbcan.py index f1dae7e59..9d216b533 100644 --- a/selfdrive/car/volkswagen/mqbcan.py +++ b/selfdrive/car/volkswagen/mqbcan.py @@ -38,38 +38,30 @@ def create_acc_buttons_control(packer, bus, gra_stock_values, idx, cancel=False, return packer.make_can_msg("GRA_ACC_01", bus, values) -def acc_control_status_value(main_switch_on, acc_faulted, long_active): +def acc_control_value(main_switch_on, acc_faulted, long_active): if acc_faulted: - tsk_status = 6 + acc_control = 6 elif long_active: - tsk_status = 3 + acc_control = 3 elif main_switch_on: - tsk_status = 2 + acc_control = 2 else: - tsk_status = 0 + acc_control = 0 - return tsk_status + return acc_control def acc_hud_status_value(main_switch_on, acc_faulted, long_active): - if acc_faulted: - hud_status = 6 - elif long_active: - hud_status = 3 - elif main_switch_on: - hud_status = 2 - else: - hud_status = 0 - - return hud_status + # TODO: happens to resemble the ACC control value for now, but extend this for init/gas override later + return acc_control_value(main_switch_on, acc_faulted, long_active) -def create_acc_accel_control(packer, bus, acc_type, enabled, accel, acc_status, stopping, starting, standstill): +def create_acc_accel_control(packer, bus, acc_type, enabled, accel, acc_control, stopping, starting, standstill): commands = [] acc_06_values = { "ACC_Typ": acc_type, - "ACC_Status_ACC": acc_status, + "ACC_Status_ACC": acc_control, "ACC_StartStopp_Info": enabled, "ACC_Sollbeschleunigung_02": accel if enabled else 3.01, "ACC_zul_Regelabw_unten": 0.2, # TODO: dynamic adjustment of comfort-band diff --git a/selfdrive/car/volkswagen/pqcan.py b/selfdrive/car/volkswagen/pqcan.py index c7e9233a5..cde6410e1 100644 --- a/selfdrive/car/volkswagen/pqcan.py +++ b/selfdrive/car/volkswagen/pqcan.py @@ -35,15 +35,15 @@ def create_acc_buttons_control(packer, bus, gra_stock_values, idx, cancel=False, return packer.make_can_msg("GRA_Neu", bus, values) -def acc_control_status_value(main_switch_on, acc_faulted, long_active): +def acc_control_value(main_switch_on, acc_faulted, long_active): if long_active: - tsk_status = 1 + acc_control = 1 elif main_switch_on: - tsk_status = 2 + acc_control = 2 else: - tsk_status = 0 + acc_control = 0 - return tsk_status + return acc_control def acc_hud_status_value(main_switch_on, acc_faulted, long_active): @@ -59,16 +59,16 @@ def acc_hud_status_value(main_switch_on, acc_faulted, long_active): return hud_status -def create_acc_accel_control(packer, bus, acc_type, enabled, accel, acc_status, stopping, starting, standstill): +def create_acc_accel_control(packer, bus, acc_type, enabled, accel, acc_control, stopping, starting, standstill): commands = [] values = { - "ACS_Sta_ADR": acc_status, - "ACS_StSt_Info": acc_status != 1, + "ACS_Sta_ADR": acc_control, + "ACS_StSt_Info": acc_control != 1, "ACS_Typ_ACC": acc_type, - "ACS_Sollbeschl": accel if acc_status == 1 else 3.01, - "ACS_zul_Regelabw": 0.2 if acc_status == 1 else 1.27, - "ACS_max_AendGrad": 3.0 if acc_status == 1 else 5.08, + "ACS_Sollbeschl": accel if acc_control == 1 else 3.01, + "ACS_zul_Regelabw": 0.2 if acc_control == 1 else 1.27, + "ACS_max_AendGrad": 3.0 if acc_control == 1 else 5.08, } commands.append(packer.make_can_msg("ACC_System", bus, values))