[torqued] Extend to all Toyota and Hyundai cars (#26238)
* extend to toyota and hyundai * remove all pid control in hyundai * remove indi tunes * remove toyota lat tunes * release notes * rm tunes.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: f6bab0cd678e3020c7b0e2257309df69f83de0f0
This commit is contained in:
@@ -6,6 +6,7 @@ Version 0.8.17 (2022-XX-XX)
|
||||
* New end-to-end distracted trigger
|
||||
* Self-tuning torque lateral controller parameters
|
||||
* Parameters learned live for each car
|
||||
* Torque controller used on all Toyota, Lexus, Hyundai, Kia, and Genesis models
|
||||
* UI updates
|
||||
* Multi-language in navigation
|
||||
* Matched speeds shown on car's dash
|
||||
|
||||
@@ -45,141 +45,92 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerActuatorDelay = 0.1 # Default delay
|
||||
ret.steerLimitTimer = 0.4
|
||||
tire_stiffness_factor = 1.
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
|
||||
if candidate in (CAR.SANTA_FE, CAR.SANTA_FE_2022, CAR.SANTA_FE_HEV_2022, CAR.SANTA_FE_PHEV_2022):
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
ret.wheelbase = 2.766
|
||||
# Values from optimizer
|
||||
ret.steerRatio = 16.55 # 13.8 is spec end-to-end
|
||||
tire_stiffness_factor = 0.82
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[9., 22.], [9., 22.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.35], [0.05, 0.09]]
|
||||
elif candidate in (CAR.SONATA, CAR.SONATA_HYBRID):
|
||||
ret.mass = 1513. + STD_CARGO_KG
|
||||
ret.wheelbase = 2.84
|
||||
ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable
|
||||
tire_stiffness_factor = 0.65
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate == CAR.SONATA_LF:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 4497. * CV.LB_TO_KG
|
||||
ret.wheelbase = 2.804
|
||||
ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate == CAR.PALISADE:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 1999. + STD_CARGO_KG
|
||||
ret.wheelbase = 2.90
|
||||
ret.steerRatio = 15.6 * 1.15
|
||||
tire_stiffness_factor = 0.63
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate == CAR.ELANTRA:
|
||||
ret.lateralTuning.pid.kf = 0.00006
|
||||
ret.mass = 1275. + STD_CARGO_KG
|
||||
ret.wheelbase = 2.7
|
||||
ret.steerRatio = 15.4 # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535
|
||||
tire_stiffness_factor = 0.385 # stiffnessFactor settled on 1.0081302973865127
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
ret.minSteerSpeed = 32 * CV.MPH_TO_MS
|
||||
elif candidate == CAR.ELANTRA_2021:
|
||||
ret.mass = (2800. * CV.LB_TO_KG) + STD_CARGO_KG
|
||||
ret.wheelbase = 2.72
|
||||
ret.steerRatio = 12.9
|
||||
tire_stiffness_factor = 0.65
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate == CAR.ELANTRA_HEV_2021:
|
||||
ret.mass = (3017. * CV.LB_TO_KG) + STD_CARGO_KG
|
||||
ret.wheelbase = 2.72
|
||||
ret.steerRatio = 12.9
|
||||
tire_stiffness_factor = 0.65
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate == CAR.HYUNDAI_GENESIS:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 2060. + STD_CARGO_KG
|
||||
ret.wheelbase = 3.01
|
||||
ret.steerRatio = 16.5
|
||||
ret.lateralTuning.init('indi')
|
||||
ret.lateralTuning.indi.innerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.innerLoopGainV = [3.5]
|
||||
ret.lateralTuning.indi.outerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.outerLoopGainV = [2.0]
|
||||
ret.lateralTuning.indi.timeConstantBP = [0.]
|
||||
ret.lateralTuning.indi.timeConstantV = [1.4]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessBP = [0.]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessV = [2.3]
|
||||
ret.minSteerSpeed = 60 * CV.KPH_TO_MS
|
||||
elif candidate in (CAR.KONA, CAR.KONA_EV, CAR.KONA_HEV, CAR.KONA_EV_2022):
|
||||
ret.mass = {CAR.KONA_EV: 1685., CAR.KONA_HEV: 1425., CAR.KONA_EV_2022: 1743.}.get(candidate, 1275.) + STD_CARGO_KG
|
||||
ret.wheelbase = 2.6
|
||||
ret.steerRatio = 13.42 # Spec
|
||||
tire_stiffness_factor = 0.385
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate in (CAR.IONIQ, CAR.IONIQ_EV_LTD, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.IONIQ_HEV_2022):
|
||||
ret.lateralTuning.pid.kf = 0.00006
|
||||
ret.mass = 1490. + STD_CARGO_KG # weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx
|
||||
ret.wheelbase = 2.7
|
||||
ret.steerRatio = 13.73 # Spec
|
||||
tire_stiffness_factor = 0.385
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
if candidate not in (CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.IONIQ_HEV_2022):
|
||||
ret.minSteerSpeed = 32 * CV.MPH_TO_MS
|
||||
elif candidate == CAR.IONIQ_PHEV_2019:
|
||||
ret.mass = 1550. + STD_CARGO_KG # weight per hyundai site https://www.hyundaiusa.com/us/en/vehicles/2019-ioniq-plug-in-hybrid/compare-specs
|
||||
ret.wheelbase = 2.7
|
||||
ret.steerRatio = 13.73
|
||||
ret.lateralTuning.init('indi')
|
||||
ret.lateralTuning.indi.innerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.innerLoopGainV = [2.5]
|
||||
ret.lateralTuning.indi.outerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.outerLoopGainV = [3.5]
|
||||
ret.lateralTuning.indi.timeConstantBP = [0.]
|
||||
ret.lateralTuning.indi.timeConstantV = [1.4]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessBP = [0.]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessV = [1.8]
|
||||
ret.minSteerSpeed = 32 * CV.MPH_TO_MS
|
||||
elif candidate == CAR.VELOSTER:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 3558. * CV.LB_TO_KG
|
||||
ret.wheelbase = 2.80
|
||||
ret.steerRatio = 13.75 * 1.15
|
||||
tire_stiffness_factor = 0.5
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate == CAR.TUCSON:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 3520. * CV.LB_TO_KG
|
||||
ret.wheelbase = 2.67
|
||||
ret.steerRatio = 14.00 * 1.15
|
||||
tire_stiffness_factor = 0.385
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate == CAR.TUCSON_HYBRID_4TH_GEN:
|
||||
ret.mass = 1680. + STD_CARGO_KG # average of all 3 trims
|
||||
ret.wheelbase = 2.756
|
||||
ret.steerRatio = 16.
|
||||
tire_stiffness_factor = 0.385
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
|
||||
# Kia
|
||||
elif candidate == CAR.KIA_SORENTO:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 1985. + STD_CARGO_KG
|
||||
ret.wheelbase = 2.78
|
||||
ret.steerRatio = 14.4 * 1.1 # 10% higher at the center seems reasonable
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate in (CAR.KIA_NIRO_EV, CAR.KIA_NIRO_PHEV, CAR.KIA_NIRO_HEV_2021):
|
||||
ret.lateralTuning.pid.kf = 0.00006
|
||||
ret.mass = 1737. + STD_CARGO_KG
|
||||
ret.wheelbase = 2.7
|
||||
ret.steerRatio = 13.9 if CAR.KIA_NIRO_HEV_2021 else 13.73 # Spec
|
||||
tire_stiffness_factor = 0.385
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
if candidate == CAR.KIA_NIRO_PHEV:
|
||||
ret.minSteerSpeed = 32 * CV.MPH_TO_MS
|
||||
elif candidate == CAR.KIA_SELTOS:
|
||||
@@ -187,15 +138,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.wheelbase = 2.63
|
||||
ret.steerRatio = 14.56
|
||||
tire_stiffness_factor = 1
|
||||
ret.lateralTuning.init('indi')
|
||||
ret.lateralTuning.indi.innerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.innerLoopGainV = [4.]
|
||||
ret.lateralTuning.indi.outerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.outerLoopGainV = [3.]
|
||||
ret.lateralTuning.indi.timeConstantBP = [0.]
|
||||
ret.lateralTuning.indi.timeConstantV = [1.4]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessBP = [0.]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessV = [1.8]
|
||||
elif candidate in (CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.KIA_OPTIMA_H):
|
||||
ret.mass = 3558. * CV.LB_TO_KG
|
||||
ret.wheelbase = 2.80
|
||||
@@ -203,92 +145,58 @@ class CarInterface(CarInterfaceBase):
|
||||
tire_stiffness_factor = 0.5
|
||||
if candidate == CAR.KIA_OPTIMA_G4:
|
||||
ret.minSteerSpeed = 32 * CV.MPH_TO_MS
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate == CAR.KIA_STINGER:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 1825. + STD_CARGO_KG
|
||||
ret.wheelbase = 2.78
|
||||
ret.steerRatio = 14.4 * 1.15 # 15% higher at the center seems reasonable
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate == CAR.KIA_FORTE:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 3558. * CV.LB_TO_KG
|
||||
ret.wheelbase = 2.80
|
||||
ret.steerRatio = 13.75
|
||||
tire_stiffness_factor = 0.5
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate == CAR.KIA_CEED:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 1450. + STD_CARGO_KG
|
||||
ret.wheelbase = 2.65
|
||||
ret.steerRatio = 13.75
|
||||
tire_stiffness_factor = 0.5
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate == CAR.KIA_K5_2021:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 3228. * CV.LB_TO_KG
|
||||
ret.wheelbase = 2.85
|
||||
ret.steerRatio = 13.27 # 2021 Kia K5 Steering Ratio (all trims)
|
||||
tire_stiffness_factor = 0.5
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||
elif candidate == CAR.KIA_EV6:
|
||||
ret.mass = 2055 + STD_CARGO_KG
|
||||
ret.wheelbase = 2.9
|
||||
ret.steerRatio = 16.
|
||||
tire_stiffness_factor = 0.65
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate == CAR.IONIQ_5:
|
||||
ret.mass = 2012 + STD_CARGO_KG
|
||||
ret.wheelbase = 3.0
|
||||
ret.steerRatio = 16.
|
||||
tire_stiffness_factor = 0.65
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
elif candidate == CAR.KIA_SPORTAGE_HYBRID_5TH_GEN:
|
||||
ret.mass = 1767. + STD_CARGO_KG # SX Prestige trim support only
|
||||
ret.wheelbase = 2.756
|
||||
ret.steerRatio = 13.6
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
|
||||
# Genesis
|
||||
elif candidate == CAR.GENESIS_G70:
|
||||
ret.lateralTuning.init('indi')
|
||||
ret.lateralTuning.indi.innerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.innerLoopGainV = [2.5]
|
||||
ret.lateralTuning.indi.outerLoopGainBP = [0.]
|
||||
ret.lateralTuning.indi.outerLoopGainV = [3.5]
|
||||
ret.lateralTuning.indi.timeConstantBP = [0.]
|
||||
ret.lateralTuning.indi.timeConstantV = [1.4]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessBP = [0.]
|
||||
ret.lateralTuning.indi.actuatorEffectivenessV = [1.8]
|
||||
ret.steerActuatorDelay = 0.1
|
||||
ret.mass = 1640.0 + STD_CARGO_KG
|
||||
ret.wheelbase = 2.84
|
||||
ret.steerRatio = 13.56
|
||||
elif candidate == CAR.GENESIS_G70_2020:
|
||||
ret.lateralTuning.pid.kf = 0.
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.112], [0.004]]
|
||||
ret.mass = 3673.0 * CV.LB_TO_KG + STD_CARGO_KG
|
||||
ret.wheelbase = 2.83
|
||||
ret.steerRatio = 12.9
|
||||
elif candidate == CAR.GENESIS_G80:
|
||||
ret.lateralTuning.pid.kf = 0.00005
|
||||
ret.mass = 2060. + STD_CARGO_KG
|
||||
ret.wheelbase = 3.01
|
||||
ret.steerRatio = 16.5
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]]
|
||||
elif candidate == CAR.GENESIS_G90:
|
||||
ret.mass = 2200
|
||||
ret.wheelbase = 3.15
|
||||
ret.steerRatio = 12.069
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]]
|
||||
|
||||
# *** longitudinal control ***
|
||||
if candidate in CANFD_CAR:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
from cereal import car
|
||||
from common.conversions import Conversions as CV
|
||||
from panda import Panda
|
||||
from selfdrive.car.toyota.tunes import LatTunes, LongTunes, set_long_tune, set_lat_tune
|
||||
from selfdrive.car.toyota.values import Ecu, CAR, ToyotaFlags, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, MIN_ACC_SPEED, EPS_SCALE, EV_HYBRID_CAR, CarControllerParams
|
||||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
|
||||
from selfdrive.car.interfaces import CarInterfaceBase
|
||||
@@ -74,7 +73,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.wheelSpeedFactor = 1.035
|
||||
tire_stiffness_factor = 0.5533
|
||||
ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_C)
|
||||
|
||||
elif candidate in (CAR.CHR, CAR.CHRH):
|
||||
stop_and_go = True
|
||||
@@ -82,7 +80,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 13.6
|
||||
tire_stiffness_factor = 0.7933
|
||||
ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_F)
|
||||
|
||||
elif candidate in (CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2):
|
||||
stop_and_go = True
|
||||
@@ -90,8 +87,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 13.7
|
||||
tire_stiffness_factor = 0.7933
|
||||
ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
|
||||
if candidate not in (CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2):
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_C)
|
||||
|
||||
elif candidate in (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2):
|
||||
stop_and_go = True
|
||||
@@ -99,7 +94,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 16.0
|
||||
tire_stiffness_factor = 0.8
|
||||
ret.mass = 4516. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_G)
|
||||
|
||||
elif candidate in (CAR.AVALON, CAR.AVALON_2019, CAR.AVALONH_2019, CAR.AVALON_TSS2, CAR.AVALONH_TSS2):
|
||||
# starting from 2019, all Avalon variants have stop and go
|
||||
@@ -109,7 +103,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 14.8 # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download
|
||||
tire_stiffness_factor = 0.7983
|
||||
ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_H)
|
||||
|
||||
elif candidate in (CAR.RAV4_TSS2, CAR.RAV4_TSS2_2022, CAR.RAV4H_TSS2, CAR.RAV4H_TSS2_2022):
|
||||
stop_and_go = True
|
||||
@@ -117,14 +110,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 14.3
|
||||
tire_stiffness_factor = 0.7933
|
||||
ret.mass = 3585. * CV.LB_TO_KG + STD_CARGO_KG # Average between ICE and Hybrid
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_D)
|
||||
|
||||
# 2019+ RAV4 TSS2 uses two different steering racks and specific tuning seems to be necessary.
|
||||
# See https://github.com/commaai/openpilot/pull/21429#issuecomment-873652891
|
||||
for fw in car_fw:
|
||||
if fw.ecu == "eps" and (fw.fwVersion.startswith(b'\x02') or fw.fwVersion in [b'8965B42181\x00\x00\x00\x00\x00\x00']):
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_I)
|
||||
break
|
||||
|
||||
elif candidate in (CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2):
|
||||
stop_and_go = True
|
||||
@@ -139,7 +124,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 16.0 # not optimized
|
||||
tire_stiffness_factor = 0.444 # not optimized yet
|
||||
ret.mass = 3677. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_D)
|
||||
|
||||
elif candidate == CAR.SIENNA:
|
||||
stop_and_go = True
|
||||
@@ -147,14 +131,12 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 15.5
|
||||
tire_stiffness_factor = 0.444
|
||||
ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_J)
|
||||
|
||||
elif candidate in (CAR.LEXUS_IS, CAR.LEXUS_RC):
|
||||
ret.wheelbase = 2.79908
|
||||
ret.steerRatio = 13.3
|
||||
tire_stiffness_factor = 0.444
|
||||
ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_L)
|
||||
|
||||
elif candidate == CAR.LEXUS_CTH:
|
||||
stop_and_go = True
|
||||
@@ -162,7 +144,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 18.6
|
||||
tire_stiffness_factor = 0.517
|
||||
ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_M)
|
||||
|
||||
elif candidate in (CAR.LEXUS_NX, CAR.LEXUS_NXH, CAR.LEXUS_NX_TSS2, CAR.LEXUS_NXH_TSS2):
|
||||
stop_and_go = True
|
||||
@@ -170,7 +151,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 14.7
|
||||
tire_stiffness_factor = 0.444 # not optimized yet
|
||||
ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_C)
|
||||
|
||||
elif candidate == CAR.PRIUS_TSS2:
|
||||
stop_and_go = True
|
||||
@@ -178,7 +158,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 13.4 # True steerRatio from older prius
|
||||
tire_stiffness_factor = 0.6371 # hand-tune
|
||||
ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_N)
|
||||
|
||||
elif candidate == CAR.MIRAI:
|
||||
stop_and_go = True
|
||||
@@ -186,7 +165,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 14.8
|
||||
tire_stiffness_factor = 0.8
|
||||
ret.mass = 4300. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_C)
|
||||
|
||||
elif candidate in (CAR.ALPHARD_TSS2, CAR.ALPHARDH_TSS2):
|
||||
stop_and_go = True
|
||||
@@ -194,7 +172,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.steerRatio = 14.2
|
||||
tire_stiffness_factor = 0.444
|
||||
ret.mass = 4305. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_J)
|
||||
|
||||
ret.centerToFront = ret.wheelbase * 0.44
|
||||
|
||||
@@ -230,12 +207,23 @@ class CarInterface(CarInterfaceBase):
|
||||
# to a negative value, so it won't matter.
|
||||
ret.minEnableSpeed = -1. if (stop_and_go or ret.enableGasInterceptor) else MIN_ACC_SPEED
|
||||
|
||||
tune = ret.longitudinalTuning
|
||||
if candidate in TSS2_CAR or ret.enableGasInterceptor:
|
||||
set_long_tune(ret.longitudinalTuning, LongTunes.TSS2)
|
||||
tune.deadzoneBP = [0., 8.05]
|
||||
tune.deadzoneV = [.0, .14]
|
||||
tune.kpBP = [0., 5., 20.]
|
||||
tune.kpV = [1.3, 1.0, 0.7]
|
||||
tune.kiBP = [0., 5., 12., 20., 27.]
|
||||
tune.kiV = [.35, .23, .20, .17, .1]
|
||||
if candidate in TSS2_CAR:
|
||||
ret.stoppingDecelRate = 0.3 # reach stopping target smoothly
|
||||
else:
|
||||
set_long_tune(ret.longitudinalTuning, LongTunes.TSS)
|
||||
tune.deadzoneBP = [0., 9.]
|
||||
tune.deadzoneV = [.0, .15]
|
||||
tune.kpBP = [0., 5., 35.]
|
||||
tune.kiBP = [0., 35.]
|
||||
tune.kpV = [3.6, 2.4, 1.5]
|
||||
tune.kiV = [0.54, 0.36]
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
from enum import Enum
|
||||
|
||||
class LongTunes(Enum):
|
||||
TSS2 = 0
|
||||
TSS = 1
|
||||
|
||||
class LatTunes(Enum):
|
||||
INDI_PRIUS = 0
|
||||
LQR_RAV4 = 1
|
||||
PID_A = 2
|
||||
PID_B = 3
|
||||
PID_C = 4
|
||||
PID_D = 5
|
||||
PID_E = 6
|
||||
PID_F = 7
|
||||
PID_G = 8
|
||||
PID_I = 9
|
||||
PID_H = 10
|
||||
PID_J = 11
|
||||
PID_K = 12
|
||||
PID_L = 13
|
||||
PID_M = 14
|
||||
PID_N = 15
|
||||
|
||||
|
||||
###### LONG ######
|
||||
def set_long_tune(tune, name):
|
||||
# Improved longitudinal tune
|
||||
if name == LongTunes.TSS2:
|
||||
tune.deadzoneBP = [0., 8.05]
|
||||
tune.deadzoneV = [.0, .14]
|
||||
tune.kpBP = [0., 5., 20.]
|
||||
tune.kpV = [1.3, 1.0, 0.7]
|
||||
tune.kiBP = [0., 5., 12., 20., 27.]
|
||||
tune.kiV = [.35, .23, .20, .17, .1]
|
||||
# Default longitudinal tune
|
||||
elif name == LongTunes.TSS:
|
||||
tune.deadzoneBP = [0., 9.]
|
||||
tune.deadzoneV = [.0, .15]
|
||||
tune.kpBP = [0., 5., 35.]
|
||||
tune.kiBP = [0., 35.]
|
||||
tune.kpV = [3.6, 2.4, 1.5]
|
||||
tune.kiV = [0.54, 0.36]
|
||||
else:
|
||||
raise NotImplementedError('This longitudinal tune does not exist')
|
||||
|
||||
|
||||
###### LAT ######
|
||||
def set_lat_tune(tune, name, MAX_LAT_ACCEL=2.5, FRICTION=0.01, steering_angle_deadzone_deg=0.0, use_steering_angle=True):
|
||||
if 'PID' in str(name):
|
||||
tune.init('pid')
|
||||
tune.pid.kiBP = [0.0]
|
||||
tune.pid.kpBP = [0.0]
|
||||
if name == LatTunes.PID_A:
|
||||
tune.pid.kpV = [0.2]
|
||||
tune.pid.kiV = [0.05]
|
||||
tune.pid.kf = 0.00003
|
||||
elif name == LatTunes.PID_C:
|
||||
tune.pid.kpV = [0.6]
|
||||
tune.pid.kiV = [0.1]
|
||||
tune.pid.kf = 0.00006
|
||||
elif name == LatTunes.PID_D:
|
||||
tune.pid.kpV = [0.6]
|
||||
tune.pid.kiV = [0.1]
|
||||
tune.pid.kf = 0.00007818594
|
||||
elif name == LatTunes.PID_F:
|
||||
tune.pid.kpV = [0.723]
|
||||
tune.pid.kiV = [0.0428]
|
||||
tune.pid.kf = 0.00006
|
||||
elif name == LatTunes.PID_G:
|
||||
tune.pid.kpV = [0.18]
|
||||
tune.pid.kiV = [0.015]
|
||||
tune.pid.kf = 0.00012
|
||||
elif name == LatTunes.PID_H:
|
||||
tune.pid.kpV = [0.17]
|
||||
tune.pid.kiV = [0.03]
|
||||
tune.pid.kf = 0.00006
|
||||
elif name == LatTunes.PID_I:
|
||||
tune.pid.kpV = [0.15]
|
||||
tune.pid.kiV = [0.05]
|
||||
tune.pid.kf = 0.00004
|
||||
elif name == LatTunes.PID_J:
|
||||
tune.pid.kpV = [0.19]
|
||||
tune.pid.kiV = [0.02]
|
||||
tune.pid.kf = 0.00007818594
|
||||
elif name == LatTunes.PID_L:
|
||||
tune.pid.kpV = [0.3]
|
||||
tune.pid.kiV = [0.05]
|
||||
tune.pid.kf = 0.00006
|
||||
elif name == LatTunes.PID_M:
|
||||
tune.pid.kpV = [0.3]
|
||||
tune.pid.kiV = [0.05]
|
||||
tune.pid.kf = 0.00007
|
||||
elif name == LatTunes.PID_N:
|
||||
tune.pid.kpV = [0.35]
|
||||
tune.pid.kiV = [0.15]
|
||||
tune.pid.kf = 0.00007818594
|
||||
else:
|
||||
raise NotImplementedError('This PID tune does not exist')
|
||||
else:
|
||||
raise NotImplementedError('This lateral tune does not exist')
|
||||
Reference in New Issue
Block a user