auto detect gearbox message

auto detect gearbox message

remove todos

remove todos
pull/21410/head
ShaneSmiskol 4 years ago
parent 8418dc42aa
commit bcdf7c452d
  1. 2
      cereal
  2. 57
      selfdrive/car/hyundai/carstate.py
  3. 9
      selfdrive/car/hyundai/interface.py
  4. 11
      selfdrive/car/hyundai/values.py

@ -1 +1 @@
Subproject commit 232e28c2bb049fa8b7c2da0a2add27645b5a6bc2
Subproject commit 683f5bfb0d2880e55356f825774305632a033ecc

@ -1,6 +1,6 @@
import copy
from cereal import car
from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD, FEATURES, EV_CAR, HYBRID_CAR
from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD, USE_FCA, EV_CAR, HYBRID_CAR
from selfdrive.car.interfaces import CarStateBase
from opendbc.can.parser import CANParser
from opendbc.can.can_define import CANDefine
@ -12,15 +12,15 @@ GearShifter = car.CarState.GearShifter
class CarState(CarStateBase):
def __init__(self, CP):
super().__init__(CP)
can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
if self.CP.carFingerprint in FEATURES["use_cluster_gears"]:
self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"]
elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]:
self.shifter_values = can_define.dv["TCU12"]["CUR_GR"]
else: # preferred and elect gear methods use same definition
can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
if self.CP.gearboxType in [1, 2]:
# preferred and elect gear methods use same definition
self.shifter_values = can_define.dv["LVR12"]["CF_Lvr_Gear"]
elif self.CP.gearboxType == 3:
self.shifter_values = can_define.dv["TCU12"]["CUR_GR"]
else:
self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"]
def update(self, cp, cp_cam):
ret = car.CarState.new_message()
@ -79,20 +79,19 @@ class CarState(CarStateBase):
ret.gas = cp.vl["EMS12"]["PV_AV_CAN"] / 100.
ret.gasPressed = bool(cp.vl["EMS16"]["CF_Ems_AclAct"])
# Gear Selection via Cluster - For those Kia/Hyundai which are not fully discovered, we can use the Cluster Indicator for Gear Selection,
# as this seems to be standard over all cars, but is not the preferred method.
if self.CP.carFingerprint in FEATURES["use_cluster_gears"]:
gear = cp.vl["CLU15"]["CF_Clu_Gear"]
elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]:
gear = cp.vl["TCU12"]["CUR_GR"]
elif self.CP.carFingerprint in FEATURES["use_elect_gears"]:
if self.CP.gearboxType == 1:
gear = cp.vl["LVR12"]["CF_Lvr_Gear"]
elif self.CP.gearboxType == 2:
gear = cp.vl["ELECT_GEAR"]["Elect_Gear_Shifter"]
elif self.CP.gearboxType == 3:
gear = cp.vl["TCU12"]["CUR_GR"]
else:
gear = cp.vl["LVR12"]["CF_Lvr_Gear"]
# Last in priority, some cars have this message but CF_Clu_Gear is empty
gear = cp.vl["CLU15"]["CF_Clu_Gear"]
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear))
if self.CP.carFingerprint in FEATURES["use_fca"]:
if self.CP.carFingerprint in USE_FCA:
ret.stockAeb = cp.vl["FCA11"]["FCA_CmdAct"] != 0
ret.stockFcw = cp.vl["FCA11"]["CF_VSM_Warn"] == 2
else:
@ -227,32 +226,36 @@ class CarState(CarStateBase):
("EMS16", 100),
]
if CP.carFingerprint in FEATURES["use_cluster_gears"]:
if CP.gearboxType == 1:
signals += [
("CF_Clu_Gear", "CLU15", 0),
("CF_Lvr_Gear", "LVR12", 0)
]
checks += [
("CLU15", 5)
("LVR12", 100)
]
elif CP.carFingerprint in FEATURES["use_tcu_gears"]:
elif CP.gearboxType == 2:
signals += [
("Elect_Gear_Shifter", "ELECT_GEAR", 0)
]
checks += [
("ELECT_GEAR", 20)
]
elif CP.gearboxType == 3:
signals += [
("CUR_GR", "TCU12", 0)
]
checks += [
("TCU12", 100)
]
elif CP.carFingerprint in FEATURES["use_elect_gears"]:
signals += [("Elect_Gear_Shifter", "ELECT_GEAR", 0)]
checks += [("ELECT_GEAR", 20)]
else:
signals += [
("CF_Lvr_Gear", "LVR12", 0)
("CF_Clu_Gear", "CLU15", 0),
]
checks += [
("LVR12", 100)
("CLU15", 5)
]
if CP.carFingerprint in FEATURES["use_fca"]:
if CP.carFingerprint in USE_FCA:
signals += [
("FCA_CmdAct", "FCA11", 0),
("CF_VSM_Warn", "FCA11", 0),

@ -253,6 +253,15 @@ class CarInterface(CarInterfaceBase):
ret.enableCamera = True
ret.enableBsm = 0x58b in fingerprint[0]
if 0x367 in fingerprint[0]:
ret.gearboxType = 1
elif 0x372 in fingerprint[0]:
ret.gearboxType = 2
elif 0x112 in fingerprint[0]:
ret.gearboxType = 3
else: #
ret.gearboxType = 4
return ret
def update(self, c, can_strings):

@ -648,15 +648,10 @@ CHECKSUM = {
"6B": [CAR.KIA_SORENTO, CAR.HYUNDAI_GENESIS],
}
FEATURES = {
# which message has the gear
"use_cluster_gears": set([CAR.ELANTRA, CAR.ELANTRA_GT_I30, CAR.KONA]),
"use_tcu_gears": set([CAR.KIA_OPTIMA, CAR.SONATA_LF, CAR.VELOSTER]),
"use_elect_gears": set([CAR.KIA_NIRO_EV, CAR.KIA_OPTIMA_H, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.IONIQ, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021]),
# these cars use the FCA11 message for the AEB and FCW signals, all others use SCC12
"use_fca": set([CAR.SONATA, CAR.ELANTRA, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.ELANTRA_GT_I30, CAR.KIA_STINGER, CAR.IONIQ, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KONA_EV, CAR.KIA_FORTE, CAR.KIA_NIRO_EV, CAR.PALISADE, CAR.GENESIS_G70, CAR.KONA, CAR.SANTA_FE, CAR.KIA_SELTOS]),
}
# these cars use the FCA11 message for the AEB and FCW signals, all others use SCC12
USE_FCA = set([CAR.SONATA, CAR.ELANTRA, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.ELANTRA_GT_I30, CAR.KIA_STINGER, CAR.IONIQ, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KONA_EV, CAR.KIA_FORTE, CAR.KIA_NIRO_EV, CAR.PALISADE, CAR.GENESIS_G70, CAR.KONA, CAR.SANTA_FE, CAR.KIA_SELTOS]),
HYBRID_CAR = set([CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021]) # these cars use a different gas signal
EV_CAR = set([CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_NIRO_EV])

Loading…
Cancel
Save