VW MQB: Support for other transmission types (#20253)
* Support pieces for e-Golf and manual trans * Support pieces for e-Golf and manual trans * Support pieces for e-Golf and manual trans * Support pieces for e-Golf and manual trans * Support pieces for e-Golf and manual trans * Support pieces for e-Golf and manual trans * Support pieces for e-Golf and manual trans * Fix comment typo * TRANS->TransmissionType, GEAR->GearShifter * TRANS->TransmissionType, GEAR->GearShifteralbatross
parent
958e7b0071
commit
bee0cc6dac
|
@ -4,16 +4,19 @@ from selfdrive.config import Conversions as CV
|
|||
from selfdrive.car.interfaces import CarStateBase
|
||||
from opendbc.can.parser import CANParser
|
||||
from opendbc.can.can_define import CANDefine
|
||||
from selfdrive.car.volkswagen.values import DBC, CANBUS, BUTTON_STATES, CarControllerParams
|
||||
from selfdrive.car.volkswagen.values import DBC, CANBUS, TransmissionType, GearShifter, BUTTON_STATES, CarControllerParams
|
||||
|
||||
class CarState(CarStateBase):
|
||||
def __init__(self, CP):
|
||||
super().__init__(CP)
|
||||
can_define = CANDefine(DBC[CP.carFingerprint]['pt'])
|
||||
self.shifter_values = can_define.dv["Getriebe_11"]['GE_Fahrstufe']
|
||||
if CP.transmissionType == TransmissionType.automatic:
|
||||
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.buttonStates = BUTTON_STATES.copy()
|
||||
|
||||
def update(self, pt_cp):
|
||||
def update(self, pt_cp, trans_type):
|
||||
ret = car.CarState.new_message()
|
||||
# Update vehicle speed and acceleration from ABS wheel speeds.
|
||||
ret.wheelSpeeds.fl = pt_cp.vl["ESP_19"]['ESP_VL_Radgeschw_02'] * CV.KPH_TO_MS
|
||||
|
@ -42,8 +45,16 @@ class CarState(CarStateBase):
|
|||
ret.brakeLights = bool(pt_cp.vl["ESP_05"]['ESP_Status_Bremsdruck'])
|
||||
|
||||
# Update gear and/or clutch position data.
|
||||
can_gear_shifter = int(pt_cp.vl["Getriebe_11"]['GE_Fahrstufe'])
|
||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear_shifter, None))
|
||||
if trans_type == TransmissionType.automatic:
|
||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["Getriebe_11"]['GE_Fahrstufe'], None))
|
||||
elif trans_type == TransmissionType.direct:
|
||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["EV_Gearshift"]['GearPosition'], None))
|
||||
elif trans_type == TransmissionType.manual:
|
||||
ret.clutchPressed = not pt_cp.vl["Motor_14"]['MO_Kuppl_schalter']
|
||||
if bool(pt_cp.vl["Gateway_72"]['BCM1_Rueckfahrlicht_Schalter']):
|
||||
ret.gearShifter = GearShifter.reverse
|
||||
else:
|
||||
ret.gearShifter = GearShifter.drive
|
||||
|
||||
# Update door and trunk/hatch lid open status.
|
||||
ret.doorOpen = any([pt_cp.vl["Gateway_72"]['ZV_FT_offen'],
|
||||
|
@ -154,7 +165,6 @@ class CarState(CarStateBase):
|
|||
("ZV_HD_offen", "Gateway_72", 0), # Trunk or hatch open
|
||||
("BH_Blinker_li", "Gateway_72", 0), # Left turn signal on
|
||||
("BH_Blinker_re", "Gateway_72", 0), # Right turn signal on
|
||||
("GE_Fahrstufe", "Getriebe_11", 0), # Auto trans gear selector position
|
||||
("AB_Gurtschloss_FA", "Airbag_02", 0), # Seatbelt status, driver
|
||||
("AB_Gurtschloss_BF", "Airbag_02", 0), # Seatbelt status, passenger
|
||||
("ESP_Fahrer_bremst", "ESP_05", 0), # Brake pedal pressed
|
||||
|
@ -206,7 +216,6 @@ class CarState(CarStateBase):
|
|||
("TSK_06", 50), # From J623 Engine control module
|
||||
("GRA_ACC_01", 33), # From J??? steering wheel control buttons
|
||||
("ACC_02", 17), # From J428 ACC radar control module
|
||||
("Getriebe_11", 20), # From J743 Auto transmission control module
|
||||
("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
|
||||
|
@ -215,6 +224,17 @@ class CarState(CarStateBase):
|
|||
("Einheiten_01", 1), # From J??? not known if gateway, cluster, or BCM
|
||||
]
|
||||
|
||||
if CP.transmissionType == TransmissionType.automatic:
|
||||
signals += [("GE_Fahrstufe", "Getriebe_11", 0)] # Auto trans gear selector position
|
||||
checks += [("Getriebe_11", 20)] # From J743 Auto transmission control module
|
||||
elif CP.transmissionType == TransmissionType.direct:
|
||||
signals += [("GearPosition", "EV_Gearshift", 0)] # EV gear selector position
|
||||
checks += [("EV_Gearshift", 10)] # From J??? unknown EV control module
|
||||
elif CP.transmissionType == TransmissionType.manual:
|
||||
signals += [("MO_Kuppl_schalter", "Motor_14", 0), # Clutch switch
|
||||
("BCM1_Rueckfahrlicht_Schalter", "Gateway_72", 0)] # Reverse light from BCM
|
||||
checks += [("Motor_14", 10)] # From J623 Engine control module
|
||||
|
||||
return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, CANBUS.pt)
|
||||
|
||||
# A single signal is monitored from the camera CAN bus, and then ignored,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from cereal import car
|
||||
from selfdrive.car.volkswagen.values import CAR, BUTTON_STATES
|
||||
from selfdrive.swaglog import cloudlog
|
||||
from selfdrive.car.volkswagen.values import CAR, BUTTON_STATES, TransmissionType, GearShifter
|
||||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint
|
||||
from selfdrive.car.interfaces import CarInterfaceBase
|
||||
|
||||
GEAR = car.CarState.GearShifter
|
||||
EventName = car.CarEvent.EventName
|
||||
|
||||
|
||||
|
@ -49,7 +49,17 @@ class CarInterface(CarInterfaceBase):
|
|||
tire_stiffness_factor = 1.0
|
||||
|
||||
ret.enableCamera = True # Stock camera detection doesn't apply to VW
|
||||
ret.transmissionType = car.CarParams.TransmissionType.automatic
|
||||
|
||||
if 0xAD in fingerprint[0]:
|
||||
# Getriebe_11 detected: traditional automatic or DSG gearbox
|
||||
ret.transmissionType = TransmissionType.automatic
|
||||
elif 0x187 in fingerprint[0]:
|
||||
# EV_Gearshift detected: e-Golf or similar direct-drive electric
|
||||
ret.transmissionType = TransmissionType.direct
|
||||
else:
|
||||
# No trans message at all, must be a true stick-shift manual
|
||||
ret.transmissionType = TransmissionType.manual
|
||||
cloudlog.info("Detected transmission type: %s", ret.transmissionType)
|
||||
|
||||
# TODO: get actual value, for now starting with reasonable value for
|
||||
# civic and scaling by mass and wheelbase
|
||||
|
@ -72,7 +82,7 @@ class CarInterface(CarInterfaceBase):
|
|||
self.cp.update_strings(can_strings)
|
||||
self.cp_cam.update_strings(can_strings)
|
||||
|
||||
ret = self.CS.update(self.cp)
|
||||
ret = self.CS.update(self.cp, self.CP.transmissionType)
|
||||
ret.canValid = self.cp.can_valid and self.cp_cam.can_valid
|
||||
ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False
|
||||
|
||||
|
@ -91,7 +101,7 @@ class CarInterface(CarInterfaceBase):
|
|||
be.pressed = self.CS.buttonStates[button]
|
||||
buttonEvents.append(be)
|
||||
|
||||
events = self.create_common_events(ret, extra_gears=[GEAR.eco, GEAR.sport])
|
||||
events = self.create_common_events(ret, extra_gears=[GearShifter.eco, GearShifter.sport])
|
||||
|
||||
# Vehicle health and operation safety checks
|
||||
if self.CS.parkingBrakeSet:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# flake8: noqa
|
||||
|
||||
from cereal import car
|
||||
from selfdrive.car import dbc_dict
|
||||
|
||||
class CarControllerParams:
|
||||
|
@ -24,6 +25,9 @@ class CANBUS:
|
|||
pt = 0
|
||||
cam = 2
|
||||
|
||||
TransmissionType = car.CarParams.TransmissionType
|
||||
GearShifter = car.CarState.GearShifter
|
||||
|
||||
BUTTON_STATES = {
|
||||
"accelCruise": False,
|
||||
"decelCruise": False,
|
||||
|
|
Loading…
Reference in New Issue