mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-29 10:32:10 +08:00
VW MQB: Fix bug with HCA state handling (#21104)
* Improved HCA state and fault handling * Apparently opendbc does an upper() on everything * Update EPS HCA init state * Make initial state "ready" old-commit-hash: 3a2893f11a7f40277ab21d7e70145d4900c0b532
This commit is contained in:
@@ -43,7 +43,7 @@ class CarController():
|
||||
|
||||
# FAULT AVOIDANCE: HCA must not be enabled at standstill. Also stop
|
||||
# commanding HCA if there's a fault, so the steering rack recovers.
|
||||
if enabled and not (CS.out.standstill or CS.steeringFault):
|
||||
if enabled and not (CS.out.standstill or CS.out.steerError or CS.out.steerWarning):
|
||||
|
||||
# FAULT AVOIDANCE: Requested HCA torque must not exceed 3.0 Nm. This
|
||||
# is inherently handled by scaling to STEER_MAX. The rack doesn't seem
|
||||
|
||||
@@ -14,6 +14,7 @@ class CarState(CarStateBase):
|
||||
self.shifter_values = can_define.dv["Getriebe_11"]["GE_Fahrstufe"]
|
||||
elif CP.transmissionType == TransmissionType.direct:
|
||||
self.shifter_values = can_define.dv["EV_Gearshift"]["GearPosition"]
|
||||
self.hca_status_values = can_define.dv["LH_EPS_03"]["EPS_HCA_Status"]
|
||||
self.buttonStates = BUTTON_STATES.copy()
|
||||
|
||||
def update(self, pt_cp, cam_cp, trans_type):
|
||||
@@ -37,6 +38,11 @@ class CarState(CarStateBase):
|
||||
ret.steeringPressed = abs(ret.steeringTorque) > CarControllerParams.STEER_DRIVER_ALLOWANCE
|
||||
ret.yawRate = pt_cp.vl["ESP_02"]["ESP_Gierrate"] * (1, -1)[int(pt_cp.vl["ESP_02"]["ESP_VZ_Gierrate"])] * CV.DEG_TO_RAD
|
||||
|
||||
# Verify EPS readiness to accept steering commands
|
||||
hca_status = self.hca_status_values.get(pt_cp.vl["LH_EPS_03"]["EPS_HCA_Status"])
|
||||
ret.steerError = hca_status in ["DISABLED", "FAULT"]
|
||||
ret.steerWarning = hca_status in ["INITIALIZING", "REJECTED"]
|
||||
|
||||
# Update gas, brakes, and gearshift.
|
||||
ret.gas = pt_cp.vl["Motor_20"]["MO_Fahrpedalrohwert_01"] / 100.0
|
||||
ret.gasPressed = ret.gas > 0
|
||||
@@ -141,10 +147,6 @@ class CarState(CarStateBase):
|
||||
# later cruise-control button spamming.
|
||||
self.graMsgBusCounter = pt_cp.vl["GRA_ACC_01"]["COUNTER"]
|
||||
|
||||
# Check to make sure the electric power steering rack is configured to
|
||||
# accept and respond to HCA_01 messages and has not encountered a fault.
|
||||
self.steeringFault = not pt_cp.vl["LH_EPS_03"]["EPS_HCA_Status"]
|
||||
|
||||
# Additional safety checks performed in CarInterface.
|
||||
self.parkingBrakeSet = bool(pt_cp.vl["Kombi_01"]["KBI_Handbremse"]) # FIXME: need to include an EPB check as well
|
||||
ret.espDisabled = pt_cp.vl["ESP_21"]["ESP_Tastung_passiv"] != 0
|
||||
@@ -181,7 +183,7 @@ class CarState(CarStateBase):
|
||||
("MO_Kuppl_schalter", "Motor_14", 0), # Clutch switch
|
||||
("EPS_Lenkmoment", "LH_EPS_03", 0), # Absolute driver torque input
|
||||
("EPS_VZ_Lenkmoment", "LH_EPS_03", 0), # Driver torque input sign
|
||||
("EPS_HCA_Status", "LH_EPS_03", 0), # Steering rack HCA support configured
|
||||
("EPS_HCA_Status", "LH_EPS_03", 3), # EPS HCA control status
|
||||
("ESP_Tastung_passiv", "ESP_21", 0), # Stability control disabled
|
||||
("KBI_MFA_v_Einheit_02", "Einheiten_01", 0), # MPH vs KMH speed display
|
||||
("KBI_Handbremse", "Kombi_01", 0), # Manual handbrake applied
|
||||
|
||||
@@ -167,8 +167,6 @@ class CarInterface(CarInterfaceBase):
|
||||
# Vehicle health and operation safety checks
|
||||
if self.CS.parkingBrakeSet:
|
||||
events.add(EventName.parkBrake)
|
||||
if self.CS.steeringFault:
|
||||
events.add(EventName.steerTempUnavailable)
|
||||
|
||||
ret.events = events.to_msg()
|
||||
ret.buttonEvents = buttonEvents
|
||||
|
||||
Reference in New Issue
Block a user