Skip to content

Commit

Permalink
Couple more cars to torque tune (commaai#24848)
Browse files Browse the repository at this point in the history
* try sonata on torque tune

* Couple known cars to torque control

* fix

* more fix
  • Loading branch information
haraschax authored and Casey Francis committed Jun 23, 2022
1 parent 7503288 commit 0746971
Showing 1 changed file with 19 additions and 61 deletions.
80 changes: 19 additions & 61 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 0746971

Please sign in to comment.