@ -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 :