diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 6ab561fece6877..a26137234e77be 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -47,8 +47,8 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disabl ret.longitudinalTuning.kiV = [0.0] ret.stopAccel = 0.0 - ret.longitudinalActuatorDelayUpperBound = 1.0 # s - + ret.longitudinalActuatorDelayUpperBound = 1.0 # s + torque_params = CarInterfaceBase.get_torque_params(candidate) 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 @@ -71,25 +71,11 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disabl 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.lateralTuning.pid.kf = 0.00005 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 - if Params().get_bool('Torque'): - MAX_LAT_ACCEL = 2.5 - friction = 0.05 - - ret.lateralTuning.init('torque') - ret.lateralTuning.torque.useSteeringAngle = True - ret.lateralTuning.torque.kp = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.kf = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.ki = 0.1 / MAX_LAT_ACCEL - ret.lateralTuning.torque.friction = friction - else: - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] - + set_torque_tune(ret.lateralTuning, torque_params['LAT_ACCEL_FACTOR'], torque_params['FRICTION']) elif candidate == CAR.SONATA_LF: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 4497. * CV.LB_TO_KG @@ -140,45 +126,17 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disabl ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate == CAR.ELANTRA_2021: - ret.lateralTuning.pid.kf = 0.00005 ret.mass = (2800. * CV.LB_TO_KG) + STD_CARGO_KG ret.wheelbase = 2.72 ret.steerRatio = 12.9 tire_stiffness_factor = 0.65 - if Params().get_bool('Torque'): - MAX_LAT_ACCEL = 2.5 - friction = 0.05 - - ret.lateralTuning.init('torque') - ret.lateralTuning.torque.useSteeringAngle = True - ret.lateralTuning.torque.kp = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.kf = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.ki = 0.1 / MAX_LAT_ACCEL - ret.lateralTuning.torque.friction = friction - else: - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] - + set_torque_tune(ret.lateralTuning, torque_params['LAT_ACCEL_FACTOR'], torque_params['FRICTION']) elif candidate == CAR.ELANTRA_HEV_2021: - ret.lateralTuning.pid.kf = 0.00005 ret.mass = (3017. * CV.LB_TO_KG) + STD_CARGO_KG ret.wheelbase = 2.72 ret.steerRatio = 12.9 tire_stiffness_factor = 0.65 - if Params().get_bool('Torque'): - MAX_LAT_ACCEL = 2.5 - friction = 0.05 - - ret.lateralTuning.init('torque') - ret.lateralTuning.torque.useSteeringAngle = True - ret.lateralTuning.torque.kp = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.kf = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.ki = 0.1 / MAX_LAT_ACCEL - ret.lateralTuning.torque.friction = friction - else: - ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] - ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] - + set_torque_tune(ret.lateralTuning, torque_params['LAT_ACCEL_FACTOR'], torque_params['FRICTION']) elif candidate == CAR.HYUNDAI_GENESIS: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 2060. + STD_CARGO_KG @@ -325,25 +283,13 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disabl ret.lateralTuning.indi.actuatorEffectivenessV = [1.8] elif candidate in (CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H): - 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 - if Params().get_bool('Torque'): - MAX_LAT_ACCEL = 2.5 - friction = 0.05 + torque_params = CarInterfaceBase.get_torque_params(CAR.KIA_OPTIMA) + set_torque_tune(ret.lateralTuning, torque_params['LAT_ACCEL_FACTOR'], torque_params['FRICTION']) - ret.lateralTuning.init('torque') - ret.lateralTuning.torque.useSteeringAngle = True - ret.lateralTuning.torque.kp = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.kf = 1.0 / MAX_LAT_ACCEL - ret.lateralTuning.torque.ki = 0.1 / MAX_LAT_ACCEL - ret.lateralTuning.torque.friction = friction - else: - 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_STINGER: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 1825. + STD_CARGO_KG @@ -391,6 +337,18 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disabl 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. + ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput), + get_safety_config(car.CarParams.SafetyModel.hyundaiHDA2)] + tire_stiffness_factor = 0.65 + + ret.maxLateralAccel = 2. + # TODO override until there is more data + set_torque_tune(ret.lateralTuning, 2.0, 0.05) + # Genesis elif candidate == CAR.GENESIS_G70: ret.lateralTuning.init('indi')