|
|
@ -1,7 +1,8 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
#!/usr/bin/env python3 |
|
|
|
from cereal import car |
|
|
|
from cereal import car |
|
|
|
from selfdrive.config import Conversions as CV |
|
|
|
from selfdrive.config import Conversions as CV |
|
|
|
from selfdrive.car.toyota.values import Ecu, CAR, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, PEDAL_HYST_GAP, CarControllerParams |
|
|
|
from selfdrive.car.toyota.tunes import LatTunes, LongTunes, set_long_tune, set_lat_tune |
|
|
|
|
|
|
|
from selfdrive.car.toyota.values import Ecu, CAR, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, CarControllerParams |
|
|
|
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config |
|
|
|
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 |
|
|
|
from selfdrive.car.interfaces import CarInterfaceBase |
|
|
|
|
|
|
|
|
|
|
@ -23,267 +24,208 @@ class CarInterface(CarInterfaceBase): |
|
|
|
ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay |
|
|
|
ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay |
|
|
|
ret.steerLimitTimer = 0.4 |
|
|
|
ret.steerLimitTimer = 0.4 |
|
|
|
|
|
|
|
|
|
|
|
ret.stoppingControl = False # Toyota starts braking more when it thinks you want to stop |
|
|
|
ret.stoppingControl = False # Toyota starts braking more when it thinks you want to stop |
|
|
|
|
|
|
|
|
|
|
|
if candidate not in [CAR.PRIUS, CAR.RAV4, CAR.RAV4H]: # These cars use LQR/INDI |
|
|
|
# Most cars use this default safety param |
|
|
|
ret.lateralTuning.init('pid') |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if candidate == CAR.PRIUS: |
|
|
|
if candidate == CAR.PRIUS: |
|
|
|
stop_and_go = True |
|
|
|
|
|
|
|
ret.safetyConfigs[0].safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file |
|
|
|
ret.safetyConfigs[0].safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file |
|
|
|
|
|
|
|
stop_and_go = True |
|
|
|
ret.wheelbase = 2.70 |
|
|
|
ret.wheelbase = 2.70 |
|
|
|
ret.steerRatio = 15.74 # unknown end-to-end spec |
|
|
|
ret.steerRatio = 15.74 # unknown end-to-end spec |
|
|
|
tire_stiffness_factor = 0.6371 # hand-tune |
|
|
|
tire_stiffness_factor = 0.6371 # hand-tune |
|
|
|
ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
|
|
|
|
|
|
|
|
ret.lateralTuning.init('indi') |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.INDI_PRIUS) |
|
|
|
ret.lateralTuning.indi.innerLoopGainBP = [0.] |
|
|
|
|
|
|
|
ret.lateralTuning.indi.innerLoopGainV = [4.0] |
|
|
|
|
|
|
|
ret.lateralTuning.indi.outerLoopGainBP = [0.] |
|
|
|
|
|
|
|
ret.lateralTuning.indi.outerLoopGainV = [3.0] |
|
|
|
|
|
|
|
ret.lateralTuning.indi.timeConstantBP = [0.] |
|
|
|
|
|
|
|
ret.lateralTuning.indi.timeConstantV = [1.0] |
|
|
|
|
|
|
|
ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] |
|
|
|
|
|
|
|
ret.lateralTuning.indi.actuatorEffectivenessV = [1.0] |
|
|
|
|
|
|
|
ret.steerActuatorDelay = 0.3 |
|
|
|
ret.steerActuatorDelay = 0.3 |
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.RAV4, CAR.RAV4H]: |
|
|
|
elif candidate in [CAR.RAV4, CAR.RAV4H]: |
|
|
|
stop_and_go = True if (candidate in CAR.RAV4H) else False |
|
|
|
stop_and_go = True if (candidate in CAR.RAV4H) else False |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.65 |
|
|
|
ret.wheelbase = 2.65 |
|
|
|
ret.steerRatio = 16.88 # 14.5 is spec end-to-end |
|
|
|
ret.steerRatio = 16.88 # 14.5 is spec end-to-end |
|
|
|
tire_stiffness_factor = 0.5533 |
|
|
|
tire_stiffness_factor = 0.5533 |
|
|
|
ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.lateralTuning.init('lqr') |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.LQR_RAV4) |
|
|
|
|
|
|
|
|
|
|
|
ret.lateralTuning.lqr.scale = 1500.0 |
|
|
|
|
|
|
|
ret.lateralTuning.lqr.ki = 0.05 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268] |
|
|
|
|
|
|
|
ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05] |
|
|
|
|
|
|
|
ret.lateralTuning.lqr.c = [1., 0.] |
|
|
|
|
|
|
|
ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255] |
|
|
|
|
|
|
|
ret.lateralTuning.lqr.l = [0.3233671, 0.3185757] |
|
|
|
|
|
|
|
ret.lateralTuning.lqr.dcGain = 0.002237852961363602 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.COROLLA: |
|
|
|
elif candidate == CAR.COROLLA: |
|
|
|
stop_and_go = False |
|
|
|
|
|
|
|
ret.safetyConfigs[0].safetyParam = 88 |
|
|
|
ret.safetyConfigs[0].safetyParam = 88 |
|
|
|
|
|
|
|
stop_and_go = False |
|
|
|
ret.wheelbase = 2.70 |
|
|
|
ret.wheelbase = 2.70 |
|
|
|
ret.steerRatio = 18.27 |
|
|
|
ret.steerRatio = 18.27 |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_A) |
|
|
|
ret.lateralTuning.pid.kf = 0.00003 # full torque for 20 deg at 80mph means 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.LEXUS_RX: |
|
|
|
elif candidate == CAR.LEXUS_RX: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.steerRatio = 14.8 |
|
|
|
ret.steerRatio = 14.8 |
|
|
|
tire_stiffness_factor = 0.5533 |
|
|
|
tire_stiffness_factor = 0.5533 |
|
|
|
ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.05]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_B) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.LEXUS_RXH: |
|
|
|
elif candidate == CAR.LEXUS_RXH: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.steerRatio = 16. # 14.8 is spec end-to-end |
|
|
|
ret.steerRatio = 16. # 14.8 is spec end-to-end |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max |
|
|
|
ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_C) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.LEXUS_RX_TSS2: |
|
|
|
elif candidate == CAR.LEXUS_RX_TSS2: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.steerRatio = 14.8 |
|
|
|
ret.steerRatio = 14.8 |
|
|
|
tire_stiffness_factor = 0.5533 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.5533 # not optimized yet |
|
|
|
ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_D) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.LEXUS_RXH_TSS2: |
|
|
|
elif candidate == CAR.LEXUS_RXH_TSS2: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.wheelbase = 2.79 |
|
|
|
ret.steerRatio = 16.0 # 14.8 is spec end-to-end |
|
|
|
ret.steerRatio = 16.0 # 14.8 is spec end-to-end |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
ret.mass = 4481.0 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max |
|
|
|
ret.mass = 4481.0 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.15]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_E) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.CHR, CAR.CHRH]: |
|
|
|
elif candidate in [CAR.CHR, CAR.CHRH]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.63906 |
|
|
|
ret.wheelbase = 2.63906 |
|
|
|
ret.steerRatio = 13.6 |
|
|
|
ret.steerRatio = 13.6 |
|
|
|
tire_stiffness_factor = 0.7933 |
|
|
|
tire_stiffness_factor = 0.7933 |
|
|
|
ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.723], [0.0428]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_F) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2]: |
|
|
|
elif candidate in [CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.82448 |
|
|
|
ret.wheelbase = 2.82448 |
|
|
|
ret.steerRatio = 13.7 |
|
|
|
ret.steerRatio = 13.7 |
|
|
|
tire_stiffness_factor = 0.7933 |
|
|
|
tire_stiffness_factor = 0.7933 |
|
|
|
ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_C) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2]: |
|
|
|
elif candidate in [CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.84988 # 112.2 in = 2.84988 m |
|
|
|
ret.wheelbase = 2.84988 # 112.2 in = 2.84988 m |
|
|
|
ret.steerRatio = 16.0 |
|
|
|
ret.steerRatio = 16.0 |
|
|
|
tire_stiffness_factor = 0.8 |
|
|
|
tire_stiffness_factor = 0.8 |
|
|
|
ret.mass = 4700. * CV.LB_TO_KG + STD_CARGO_KG # 4260 + 4-5 people |
|
|
|
ret.mass = 4700. * CV.LB_TO_KG + STD_CARGO_KG # 4260 + 4-5 people |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_G) |
|
|
|
ret.lateralTuning.pid.kf = 0.00012 # community tuning |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.HIGHLANDER, CAR.HIGHLANDERH]: |
|
|
|
elif candidate in [CAR.HIGHLANDER, CAR.HIGHLANDERH]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.78 |
|
|
|
ret.wheelbase = 2.78 |
|
|
|
ret.steerRatio = 16.0 |
|
|
|
ret.steerRatio = 16.0 |
|
|
|
tire_stiffness_factor = 0.8 |
|
|
|
tire_stiffness_factor = 0.8 |
|
|
|
ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid limited |
|
|
|
ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid limited |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_G) |
|
|
|
ret.lateralTuning.pid.kf = 0.00012 # community tuning |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.AVALON, CAR.AVALON_2019, CAR.AVALONH_2019]: |
|
|
|
elif candidate in [CAR.AVALON, CAR.AVALON_2019, CAR.AVALONH_2019]: |
|
|
|
stop_and_go = False |
|
|
|
stop_and_go = False |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.82 |
|
|
|
ret.wheelbase = 2.82 |
|
|
|
ret.steerRatio = 14.8 # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download |
|
|
|
ret.steerRatio = 14.8 # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download |
|
|
|
tire_stiffness_factor = 0.7983 |
|
|
|
tire_stiffness_factor = 0.7983 |
|
|
|
ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17], [0.03]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_H) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.RAV4_TSS2, CAR.RAV4H_TSS2]: |
|
|
|
elif candidate in [CAR.RAV4_TSS2, CAR.RAV4H_TSS2]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.68986 |
|
|
|
ret.wheelbase = 2.68986 |
|
|
|
ret.steerRatio = 14.3 |
|
|
|
ret.steerRatio = 14.3 |
|
|
|
tire_stiffness_factor = 0.7933 |
|
|
|
tire_stiffness_factor = 0.7933 |
|
|
|
ret.mass = 3585. * CV.LB_TO_KG + STD_CARGO_KG # Average between ICE and Hybrid |
|
|
|
ret.mass = 3585. * CV.LB_TO_KG + STD_CARGO_KG # Average between ICE and Hybrid |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_D) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 2019+ Rav4 TSS2 uses two different steering racks and specific tuning seems to be necessary. |
|
|
|
# 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 |
|
|
|
# See https://github.com/commaai/openpilot/pull/21429#issuecomment-873652891 |
|
|
|
for fw in car_fw: |
|
|
|
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']): |
|
|
|
if fw.ecu == "eps" and (fw.fwVersion.startswith(b'\x02') or fw.fwVersion in [b'8965B42181\x00\x00\x00\x00\x00\x00']): |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15], [0.05]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_I) |
|
|
|
ret.lateralTuning.pid.kf = 0.00004 |
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]: |
|
|
|
elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.67 # Average between 2.70 for sedan and 2.64 for hatchback |
|
|
|
ret.wheelbase = 2.67 # Average between 2.70 for sedan and 2.64 for hatchback |
|
|
|
ret.steerRatio = 13.9 |
|
|
|
ret.steerRatio = 13.9 |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
ret.mass = 3060. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 3060. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_D) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2]: |
|
|
|
elif candidate in [CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.8702 |
|
|
|
ret.wheelbase = 2.8702 |
|
|
|
ret.steerRatio = 16.0 # not optimized |
|
|
|
ret.steerRatio = 16.0 # not optimized |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
ret.mass = 3704. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 3704. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_D) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.LEXUS_ESH: |
|
|
|
elif candidate == CAR.LEXUS_ESH: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.8190 |
|
|
|
ret.wheelbase = 2.8190 |
|
|
|
ret.steerRatio = 16.06 |
|
|
|
ret.steerRatio = 16.06 |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
ret.mass = 3682. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 3682. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_D) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.SIENNA: |
|
|
|
elif candidate == CAR.SIENNA: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 3.03 |
|
|
|
ret.wheelbase = 3.03 |
|
|
|
ret.steerRatio = 15.5 |
|
|
|
ret.steerRatio = 15.5 |
|
|
|
tire_stiffness_factor = 0.444 |
|
|
|
tire_stiffness_factor = 0.444 |
|
|
|
ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.02]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_J) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.LEXUS_IS: |
|
|
|
elif candidate == CAR.LEXUS_IS: |
|
|
|
stop_and_go = False |
|
|
|
|
|
|
|
ret.safetyConfigs[0].safetyParam = 77 |
|
|
|
ret.safetyConfigs[0].safetyParam = 77 |
|
|
|
|
|
|
|
stop_and_go = False |
|
|
|
ret.wheelbase = 2.79908 |
|
|
|
ret.wheelbase = 2.79908 |
|
|
|
ret.steerRatio = 13.3 |
|
|
|
ret.steerRatio = 13.3 |
|
|
|
tire_stiffness_factor = 0.444 |
|
|
|
tire_stiffness_factor = 0.444 |
|
|
|
ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_L) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.LEXUS_CTH: |
|
|
|
elif candidate == CAR.LEXUS_CTH: |
|
|
|
stop_and_go = True |
|
|
|
|
|
|
|
ret.safetyConfigs[0].safetyParam = 100 |
|
|
|
ret.safetyConfigs[0].safetyParam = 100 |
|
|
|
|
|
|
|
stop_and_go = True |
|
|
|
ret.wheelbase = 2.60 |
|
|
|
ret.wheelbase = 2.60 |
|
|
|
ret.steerRatio = 18.6 |
|
|
|
ret.steerRatio = 18.6 |
|
|
|
tire_stiffness_factor = 0.517 |
|
|
|
tire_stiffness_factor = 0.517 |
|
|
|
ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max |
|
|
|
ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_M) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate in [CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.LEXUS_NX_TSS2]: |
|
|
|
elif candidate in [CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.LEXUS_NX_TSS2]: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.66 |
|
|
|
ret.wheelbase = 2.66 |
|
|
|
ret.steerRatio = 14.7 |
|
|
|
ret.steerRatio = 14.7 |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
tire_stiffness_factor = 0.444 # not optimized yet |
|
|
|
ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_C) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.PRIUS_TSS2: |
|
|
|
elif candidate == CAR.PRIUS_TSS2: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.70002 # from toyota online sepc. |
|
|
|
ret.wheelbase = 2.70002 # from toyota online sepc. |
|
|
|
ret.steerRatio = 13.4 # True steerRation from older prius |
|
|
|
ret.steerRatio = 13.4 # True steerRation from older prius |
|
|
|
tire_stiffness_factor = 0.6371 # hand-tune |
|
|
|
tire_stiffness_factor = 0.6371 # hand-tune |
|
|
|
ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.35], [0.15]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_N) |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.MIRAI: |
|
|
|
elif candidate == CAR.MIRAI: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 2.91 |
|
|
|
ret.wheelbase = 2.91 |
|
|
|
ret.steerRatio = 14.8 |
|
|
|
ret.steerRatio = 14.8 |
|
|
|
tire_stiffness_factor = 0.8 |
|
|
|
tire_stiffness_factor = 0.8 |
|
|
|
ret.mass = 4300. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 4300. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_C) |
|
|
|
ret.lateralTuning.pid.kf = 0.00006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif candidate == CAR.ALPHARD_TSS2: |
|
|
|
elif candidate == CAR.ALPHARD_TSS2: |
|
|
|
stop_and_go = True |
|
|
|
stop_and_go = True |
|
|
|
ret.safetyConfigs[0].safetyParam = 73 |
|
|
|
|
|
|
|
ret.wheelbase = 3.00 |
|
|
|
ret.wheelbase = 3.00 |
|
|
|
ret.steerRatio = 14.2 |
|
|
|
ret.steerRatio = 14.2 |
|
|
|
tire_stiffness_factor = 0.444 |
|
|
|
tire_stiffness_factor = 0.444 |
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.02]] |
|
|
|
|
|
|
|
ret.mass = 4305. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.mass = 4305. * CV.LB_TO_KG + STD_CARGO_KG |
|
|
|
ret.lateralTuning.pid.kf = 0.00007818594 |
|
|
|
set_lat_tune(ret.lateralTuning, LatTunes.PID_J) |
|
|
|
|
|
|
|
|
|
|
|
ret.steerRateCost = 1. |
|
|
|
ret.steerRateCost = 1. |
|
|
|
ret.centerToFront = ret.wheelbase * 0.44 |
|
|
|
ret.centerToFront = ret.wheelbase * 0.44 |
|
|
@ -316,28 +258,13 @@ class CarInterface(CarInterfaceBase): |
|
|
|
ret.communityFeature = ret.enableGasInterceptor or ret.enableDsu or smartDsu |
|
|
|
ret.communityFeature = ret.enableGasInterceptor or ret.enableDsu or smartDsu |
|
|
|
|
|
|
|
|
|
|
|
if ret.enableGasInterceptor: |
|
|
|
if ret.enableGasInterceptor: |
|
|
|
ret.longitudinalTuning.kpBP = [0., 5., MIN_ACC_SPEED, MIN_ACC_SPEED + PEDAL_HYST_GAP, 35.] |
|
|
|
set_long_tune(ret.longitudinalTuning, LongTunes.PEDAL) |
|
|
|
ret.longitudinalTuning.kpV = [1.2, 0.8, 0.765, 2.255, 1.5] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kiBP = [0., MIN_ACC_SPEED, MIN_ACC_SPEED + PEDAL_HYST_GAP, 35.] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kiV = [0.18, 0.165, 0.489, 0.36] |
|
|
|
|
|
|
|
elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.RAV4_TSS2, CAR.RAV4H_TSS2, CAR.LEXUS_NX_TSS2]: |
|
|
|
elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.RAV4_TSS2, CAR.RAV4H_TSS2, CAR.LEXUS_NX_TSS2]: |
|
|
|
# Improved longitudinal tune |
|
|
|
set_long_tune(ret.longitudinalTuning, LongTunes.TSS2) |
|
|
|
ret.longitudinalTuning.deadzoneBP = [0., 8.05] |
|
|
|
|
|
|
|
ret.longitudinalTuning.deadzoneV = [.0, .14] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kpBP = [0., 5., 20.] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kpV = [1.3, 1.0, 0.7] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kiBP = [0., 5., 12., 20., 27.] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kiV = [.35, .23, .20, .17, .1] |
|
|
|
|
|
|
|
ret.stoppingDecelRate = 0.3 # reach stopping target smoothly |
|
|
|
ret.stoppingDecelRate = 0.3 # reach stopping target smoothly |
|
|
|
ret.startingAccelRate = 6.0 # release brakes fast |
|
|
|
ret.startingAccelRate = 6.0 # release brakes fast |
|
|
|
else: |
|
|
|
else: |
|
|
|
# Default longitudinal tune |
|
|
|
set_long_tune(ret.longitudinalTuning, LongTunes.TSS) |
|
|
|
ret.longitudinalTuning.deadzoneBP = [0., 9.] |
|
|
|
|
|
|
|
ret.longitudinalTuning.deadzoneV = [0., .15] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kpBP = [0., 5., 35.] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kiBP = [0., 35.] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5] |
|
|
|
|
|
|
|
ret.longitudinalTuning.kiV = [0.54, 0.36] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret |
|
|
|
return ret |
|
|
|
|
|
|
|
|
|
|
|