2022-01-26 08:10:41 -08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
from parameterized import parameterized
|
|
|
|
|
|
|
|
|
|
from cereal import car, log
|
|
|
|
|
from selfdrive.car.car_helpers import interfaces
|
|
|
|
|
from selfdrive.car.honda.values import CAR as HONDA
|
|
|
|
|
from selfdrive.car.toyota.values import CAR as TOYOTA
|
|
|
|
|
from selfdrive.car.nissan.values import CAR as NISSAN
|
|
|
|
|
from selfdrive.controls.lib.latcontrol_pid import LatControlPID
|
2022-05-24 17:52:33 -07:00
|
|
|
from selfdrive.controls.lib.latcontrol_torque import LatControlTorque
|
2022-01-26 08:10:41 -08:00
|
|
|
from selfdrive.controls.lib.latcontrol_angle import LatControlAngle
|
|
|
|
|
from selfdrive.controls.lib.vehicle_model import VehicleModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestLatControl(unittest.TestCase):
|
|
|
|
|
|
2023-06-01 21:05:49 -07:00
|
|
|
@parameterized.expand([(HONDA.CIVIC, LatControlPID), (TOYOTA.RAV4, LatControlTorque), (NISSAN.LEAF, LatControlAngle)])
|
2022-01-26 08:10:41 -08:00
|
|
|
def test_saturation(self, car_name, controller):
|
|
|
|
|
CarInterface, CarController, CarState = interfaces[car_name]
|
2023-01-12 12:25:24 -08:00
|
|
|
CP = CarInterface.get_non_essential_params(car_name)
|
2022-01-26 08:10:41 -08:00
|
|
|
CI = CarInterface(CP, CarController, CarState)
|
|
|
|
|
VM = VehicleModel(CP)
|
|
|
|
|
|
|
|
|
|
controller = controller(CP, CI)
|
|
|
|
|
|
|
|
|
|
CS = car.CarState.new_message()
|
|
|
|
|
CS.vEgo = 30
|
|
|
|
|
|
|
|
|
|
last_actuators = car.CarControl.Actuators.new_message()
|
|
|
|
|
|
|
|
|
|
params = log.LiveParametersData.new_message()
|
|
|
|
|
|
|
|
|
|
for _ in range(1000):
|
2022-07-24 14:56:55 -07:00
|
|
|
_, _, lac_log = controller.update(True, CS, CP, VM, params, last_actuators, True, 1, 0)
|
2022-01-26 08:10:41 -08:00
|
|
|
|
|
|
|
|
self.assertTrue(lac_log.saturated)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|