  from selfdrive.controls.lib.longcontrol import LongControl
  from selfdrive.controls.lib.latcontrol_pid import LatControlPID
  from selfdrive.controls.lib.latcontrol_indi import LatControlINDI
  from selfdrive.controls.lib.latcontrol_angle import LatControlAngle
  from selfdrive.controls.lib.events import Events, ET
  from selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert
  from selfdrive.controls.lib.vehicle_model import VehicleModel
  from selfdrive.locationd.calibrationd import Calibration
 
</s> remove from selfdrive.controls.lib.latcontrol_lqr import LatControlLQR
 </s> add  </s> remove from selfdrive.controls.lib.latcontrol_lqr import LatControlLQR
 </s> add from selfdrive.controls.lib.latcontrol_torque import LatControlTorque </s> remove   @parameterized.expand([(HONDA.CIVIC, LatControlPID), (TOYOTA.RAV4, LatControlLQR), (TOYOTA.PRIUS, LatControlINDI), (NISSAN.LEAF, LatControlAngle)])
 </s> add   @parameterized.expand([(HONDA.CIVIC, LatControlPID), (TOYOTA.RAV4, LatControlTorque), (TOYOTA.PRIUS, LatControlINDI), (NISSAN.LEAF, LatControlAngle)]) </s> remove def set_lat_tune(tune, name):
  if name == LatTunes.INDI_PRIUS:
 </s> add def set_lat_tune(tune, name, MAX_TORQUE=2.5, FRICTION=.1):
  if name == LatTunes.TORQUE:
    tune.init('torque')
    tune.torque.useSteeringAngle = True
    tune.torque.kp = 2.0 / MAX_TORQUE
    tune.torque.kf = 1.0 / MAX_TORQUE
    tune.torque.ki = 0.5 / MAX_TORQUE
    tune.torque.friction = FRICTION
  elif name == LatTunes.INDI_PRIUS: </s> remove       elif tuning == 'lqr':
        self.assertTrue(len(car_params.lateralTuning.lqr.a))
 </s> add       elif tuning == 'torque':
        self.assertTrue(car_params.lateralTuning.torque.kf > 0)
from selfdrive.controls.lib.latcontrol_torque import LatControlTorque
  from selfdrive.controls.lib.longcontrol import LongControl
  from selfdrive.controls.lib.latcontrol_pid import LatControlPID
  from selfdrive.controls.lib.latcontrol_indi import LatControlINDI
  from selfdrive.controls.lib.latcontrol_angle import LatControlAngle
from selfdrive.controls.lib.latcontrol_torque import LatControlTorque
  from selfdrive.controls.lib.events import Events, ET
  from selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert
  from selfdrive.controls.lib.vehicle_model import VehicleModel
  from selfdrive.locationd.calibrationd import Calibration
keep keep keep add keep keep keep keep
 Lateral torque-based control with roll on TSS2 corolla and TSSP rav4 (#24260)

* Initial commit

* Fix bugs

* Need more torque rate

* Cleanup cray cray control

* Write nicely

* Chiiil

* Not relevant for cray cray control

* Do some logging

* Seems like it has more torque than I thought

* Bit more feedforward

* Tune change

* Retune

* Retune

* Little more chill

* Add coroll

* Add corolla

* Give craycray a good name

* Update to proper logging

* D to the PI

* Should be in radians

* Add d

* Start oscillations

* Add D term

* Only change torque rate limits for new tune

* Add d logging

* Should be enough

* Wrong sign in D

* Downtune a little

* Needed to prevent faults

* Add lqr rav4 to tune

* Try derivative again

* Data based retune

* Data based retune

* add friction compensation

* Doesnt need too much P with friction comp

* remove lqr

* Remove kd

* Fix tests

* fix tests

* Too much error

* Get roll induced error under 1cm/deg

* Too much jitter

* Do roll comp

* Add ki

* Final update

* Update refs

* Cleanup latcontrol_torque a little more 
selfdrive/controls/controlsd.py