VW MQB: Cleanup and prep for gateway integration (#21667)

* cleanup and scoping fixes

* static analysis feels sad without this

* remove extra read of clutch switch signal

* don't check Motor_14 unless it's needed

* collect short CP/CS aliases together
old-commit-hash: df0b92bbcd
commatwo_master
Jason Young 4 years ago committed by GitHub
parent d1c5e054d0
commit 8ce8eca19d
  1. 13
      selfdrive/car/volkswagen/carstate.py
  2. 39
      selfdrive/car/volkswagen/interface.py
  3. 6
      selfdrive/car/volkswagen/values.py

@ -76,15 +76,8 @@ class CarState(CarStateBase):
# We use the speed preference for OP. # We use the speed preference for OP.
self.displayMetricUnits = not pt_cp.vl["Einheiten_01"]["KBI_MFA_v_Einheit_02"] self.displayMetricUnits = not pt_cp.vl["Einheiten_01"]["KBI_MFA_v_Einheit_02"]
# Consume blind-spot monitoring info/warning LED states, if available. The # Consume blind-spot monitoring info/warning LED states, if available.
# info signal (LED on) is enabled whenever a vehicle is detected in the # Infostufe: BSM LED on, Warnung: BSM LED flashing
# driver's blind spot. The warning signal (LED flashing) is enabled if the
# driver shows possibly hazardous intent toward a BSM detected vehicle, by
# setting the turn signal in that direction, or (for cars with factory Lane
# Assist) approaches the lane boundary in that direction. Size of the BSM
# detection box is dynamic based on speed and road curvature.
# Refer to VW Self Study Program 890253: Volkswagen Driver Assist Systems,
# pages 32-35.
if self.CP.enableBsm: if self.CP.enableBsm:
ret.leftBlindspot = bool(pt_cp.vl["SWA_01"]["SWA_Infostufe_SWA_li"]) or bool(pt_cp.vl["SWA_01"]["SWA_Warnung_SWA_li"]) ret.leftBlindspot = bool(pt_cp.vl["SWA_01"]["SWA_Infostufe_SWA_li"]) or bool(pt_cp.vl["SWA_01"]["SWA_Warnung_SWA_li"])
ret.rightBlindspot = bool(pt_cp.vl["SWA_01"]["SWA_Infostufe_SWA_re"]) or bool(pt_cp.vl["SWA_01"]["SWA_Warnung_SWA_re"]) ret.rightBlindspot = bool(pt_cp.vl["SWA_01"]["SWA_Infostufe_SWA_re"]) or bool(pt_cp.vl["SWA_01"]["SWA_Warnung_SWA_re"])
@ -180,7 +173,6 @@ class CarState(CarStateBase):
("ESP_Fahrer_bremst", "ESP_05", 0), # Brake pedal pressed ("ESP_Fahrer_bremst", "ESP_05", 0), # Brake pedal pressed
("ESP_Bremsdruck", "ESP_05", 0), # Brake pressure applied ("ESP_Bremsdruck", "ESP_05", 0), # Brake pressure applied
("MO_Fahrpedalrohwert_01", "Motor_20", 0), # Accelerator pedal value ("MO_Fahrpedalrohwert_01", "Motor_20", 0), # Accelerator pedal value
("MO_Kuppl_schalter", "Motor_14", 0), # Clutch switch
("EPS_Lenkmoment", "LH_EPS_03", 0), # Absolute driver torque input ("EPS_Lenkmoment", "LH_EPS_03", 0), # Absolute driver torque input
("EPS_VZ_Lenkmoment", "LH_EPS_03", 0), # Driver torque input sign ("EPS_VZ_Lenkmoment", "LH_EPS_03", 0), # Driver torque input sign
("EPS_HCA_Status", "LH_EPS_03", 3), # EPS HCA control status ("EPS_HCA_Status", "LH_EPS_03", 3), # EPS HCA control status
@ -213,7 +205,6 @@ class CarState(CarStateBase):
("ESP_02", 50), # From J104 ABS/ESP controller ("ESP_02", 50), # From J104 ABS/ESP controller
("GRA_ACC_01", 33), # From J533 CAN gateway (via LIN from steering wheel controls) ("GRA_ACC_01", 33), # From J533 CAN gateway (via LIN from steering wheel controls)
("Gateway_72", 10), # From J533 CAN gateway (aggregated data) ("Gateway_72", 10), # From J533 CAN gateway (aggregated data)
("Motor_14", 10), # From J623 Engine control module
("Airbag_02", 5), # From J234 Airbag control module ("Airbag_02", 5), # From J234 Airbag control module
("Kombi_01", 2), # From J285 Instrument cluster ("Kombi_01", 2), # From J285 Instrument cluster
("Blinkmodi_02", 1), # From J519 BCM (sent at 1Hz when no lights active, 50Hz when active) ("Blinkmodi_02", 1), # From J519 BCM (sent at 1Hz when no lights active, 50Hz when active)

@ -20,29 +20,25 @@ class CarInterface(CarInterfaceBase):
@staticmethod @staticmethod
def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None):
ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
ret.carName = "volkswagen"
# VW port is a community feature, since we don't own one to test
ret.communityFeature = True ret.communityFeature = True
ret.radarOffCan = True
if True: # pylint: disable=using-constant-test if True: # pylint: disable=using-constant-test
# Set common MQB parameters that will apply globally # Set global MQB parameters
ret.carName = "volkswagen"
ret.radarOffCan = True
ret.safetyModel = car.CarParams.SafetyModel.volkswagen ret.safetyModel = car.CarParams.SafetyModel.volkswagen
ret.steerActuatorDelay = 0.05 ret.enableBsm = 0x30F in fingerprint[0]
if 0xAD in fingerprint[0]: if 0xAD in fingerprint[0]: # Getriebe_11
# Getriebe_11 detected: traditional automatic or DSG gearbox
ret.transmissionType = TransmissionType.automatic ret.transmissionType = TransmissionType.automatic
elif 0x187 in fingerprint[0]: elif 0x187 in fingerprint[0]: # EV_Gearshift
# EV_Gearshift detected: e-Golf or similar direct-drive electric
ret.transmissionType = TransmissionType.direct ret.transmissionType = TransmissionType.direct
else: else: # No trans message at all, must be a true stick-shift manual
# No trans message at all, must be a true stick-shift manual
ret.transmissionType = TransmissionType.manual ret.transmissionType = TransmissionType.manual
# Global tuning defaults, can be overridden per-vehicle # Global tuning defaults, can be overridden per-vehicle
ret.steerActuatorDelay = 0.05
ret.steerRateCost = 1.0 ret.steerRateCost = 1.0
ret.steerLimitTimer = 0.4 ret.steerLimitTimer = 0.4
ret.steerRatio = 15.6 # Let the params learner figure this out ret.steerRatio = 15.6 # Let the params learner figure this out
@ -56,85 +52,68 @@ class CarInterface(CarInterfaceBase):
# Per-chassis tuning values, override tuning defaults here if desired # Per-chassis tuning values, override tuning defaults here if desired
if candidate == CAR.ATLAS_MK1: if candidate == CAR.ATLAS_MK1:
# Averages of all CA Atlas variants
ret.mass = 2011 + STD_CARGO_KG ret.mass = 2011 + STD_CARGO_KG
ret.wheelbase = 2.98 ret.wheelbase = 2.98
elif candidate == CAR.GOLF_MK7: elif candidate == CAR.GOLF_MK7:
# Averages of all AU Golf variants
ret.mass = 1397 + STD_CARGO_KG ret.mass = 1397 + STD_CARGO_KG
ret.wheelbase = 2.62 ret.wheelbase = 2.62
elif candidate == CAR.JETTA_MK7: elif candidate == CAR.JETTA_MK7:
# Averages of all BU Jetta variants
ret.mass = 1328 + STD_CARGO_KG ret.mass = 1328 + STD_CARGO_KG
ret.wheelbase = 2.71 ret.wheelbase = 2.71
elif candidate == CAR.PASSAT_MK8: elif candidate == CAR.PASSAT_MK8:
# Averages of all 3C Passat variants
ret.mass = 1551 + STD_CARGO_KG ret.mass = 1551 + STD_CARGO_KG
ret.wheelbase = 2.79 ret.wheelbase = 2.79
elif candidate == CAR.TIGUAN_MK2: elif candidate == CAR.TIGUAN_MK2:
# Average of SWB and LWB variants
ret.mass = 1715 + STD_CARGO_KG ret.mass = 1715 + STD_CARGO_KG
ret.wheelbase = 2.74 ret.wheelbase = 2.74
elif candidate == CAR.TOURAN_MK2: elif candidate == CAR.TOURAN_MK2:
# Average of SWB and LWB variants
ret.mass = 1516 + STD_CARGO_KG ret.mass = 1516 + STD_CARGO_KG
ret.wheelbase = 2.79 ret.wheelbase = 2.79
elif candidate == CAR.AUDI_A3_MK3: elif candidate == CAR.AUDI_A3_MK3:
# Averages of all 8V A3 variants
ret.mass = 1335 + STD_CARGO_KG ret.mass = 1335 + STD_CARGO_KG
ret.wheelbase = 2.61 ret.wheelbase = 2.61
elif candidate == CAR.AUDI_Q2_MK1: elif candidate == CAR.AUDI_Q2_MK1:
# Averages of all GA Q2 variants
ret.mass = 1205 + STD_CARGO_KG ret.mass = 1205 + STD_CARGO_KG
ret.wheelbase = 2.61 ret.wheelbase = 2.61
elif candidate == CAR.SEAT_ATECA_MK1: elif candidate == CAR.SEAT_ATECA_MK1:
# Averages of all 5F Ateca variants
ret.mass = 1900 + STD_CARGO_KG ret.mass = 1900 + STD_CARGO_KG
ret.wheelbase = 2.64 ret.wheelbase = 2.64
elif candidate == CAR.SEAT_LEON_MK3: elif candidate == CAR.SEAT_LEON_MK3:
# Averages of all 5F Leon variants
ret.mass = 1227 + STD_CARGO_KG ret.mass = 1227 + STD_CARGO_KG
ret.wheelbase = 2.64 ret.wheelbase = 2.64
elif candidate == CAR.SKODA_KODIAQ_MK1: elif candidate == CAR.SKODA_KODIAQ_MK1:
# Averages of all 5N Kodiaq variants
ret.mass = 1569 + STD_CARGO_KG ret.mass = 1569 + STD_CARGO_KG
ret.wheelbase = 2.79 ret.wheelbase = 2.79
elif candidate == CAR.SKODA_OCTAVIA_MK3: elif candidate == CAR.SKODA_OCTAVIA_MK3:
# Averages of all 5E/NE Octavia variants
ret.mass = 1388 + STD_CARGO_KG ret.mass = 1388 + STD_CARGO_KG
ret.wheelbase = 2.68 ret.wheelbase = 2.68
elif candidate == CAR.SKODA_SCALA_MK1: elif candidate == CAR.SKODA_SCALA_MK1:
# Averages of all NW Scala variants
ret.mass = 1192 + STD_CARGO_KG ret.mass = 1192 + STD_CARGO_KG
ret.wheelbase = 2.65 ret.wheelbase = 2.65
elif candidate == CAR.SKODA_SUPERB_MK3: elif candidate == CAR.SKODA_SUPERB_MK3:
# Averages of all 3V/NP Scala variants
ret.mass = 1505 + STD_CARGO_KG ret.mass = 1505 + STD_CARGO_KG
ret.wheelbase = 2.84 ret.wheelbase = 2.84
ret.centerToFront = ret.wheelbase * 0.45
ret.enableBsm = 0x30F in fingerprint[0]
# TODO: get actual value, for now starting with reasonable value for # TODO: get actual value, for now starting with reasonable value for
# civic and scaling by mass and wheelbase # civic and scaling by mass and wheelbase
ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase)
# TODO: start from empirically derived lateral slip stiffness for the civic and scale by # TODO: start from empirically derived lateral slip stiffness for the civic and scale by
# mass and CG position, so all cars will have approximately similar dyn behaviors # mass and CG position, so all cars will have approximately similar dyn behaviors
ret.centerToFront = ret.wheelbase * 0.45
ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront,
tire_stiffness_factor=tire_stiffness_factor) tire_stiffness_factor=tire_stiffness_factor)

@ -5,7 +5,10 @@ from typing import Dict
from cereal import car from cereal import car
from selfdrive.car import dbc_dict from selfdrive.car import dbc_dict
Ecu = car.CarParams.Ecu Ecu = car.CarParams.Ecu
TransmissionType = car.CarParams.TransmissionType
GearShifter = car.CarState.GearShifter
class CarControllerParams: class CarControllerParams:
HCA_STEP = 2 # HCA_01 message frequency 50Hz HCA_STEP = 2 # HCA_01 message frequency 50Hz
@ -34,9 +37,6 @@ class DBC_FILES:
DBC = defaultdict(lambda: dbc_dict(DBC_FILES.mqb, None)) # type: Dict[str, Dict[str, str]] DBC = defaultdict(lambda: dbc_dict(DBC_FILES.mqb, None)) # type: Dict[str, Dict[str, str]]
TransmissionType = car.CarParams.TransmissionType
GearShifter = car.CarState.GearShifter
BUTTON_STATES = { BUTTON_STATES = {
"accelCruise": False, "accelCruise": False,
"decelCruise": False, "decelCruise": False,

Loading…
Cancel
Save