2022-01-26 08:10:41 -08:00
|
|
|
from parameterized import parameterized
|
|
|
|
|
|
|
|
|
|
from cereal import car, log
|
2023-08-20 20:49:55 -07:00
|
|
|
from openpilot.selfdrive.car.car_helpers import interfaces
|
|
|
|
|
from openpilot.selfdrive.car.honda.values import CAR as HONDA
|
|
|
|
|
from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA
|
|
|
|
|
from openpilot.selfdrive.car.nissan.values import CAR as NISSAN
|
|
|
|
|
from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID
|
|
|
|
|
from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque
|
|
|
|
|
from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle
|
|
|
|
|
from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel
|
2024-08-13 21:11:16 -07:00
|
|
|
from openpilot.selfdrive.locationd.helpers import Pose
|
|
|
|
|
from openpilot.common.mock.generators import generate_livePose
|
2022-01-26 08:10:41 -08:00
|
|
|
|
|
|
|
|
|
2024-05-17 11:01:44 -07:00
|
|
|
class TestLatControl:
|
2022-01-26 08:10:41 -08:00
|
|
|
|
2024-03-19 20:29:50 -04:00
|
|
|
@parameterized.expand([(HONDA.HONDA_CIVIC, LatControlPID), (TOYOTA.TOYOTA_RAV4, LatControlTorque), (NISSAN.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)
|
|
|
|
|
|
2024-07-02 13:27:45 -07:00
|
|
|
controller = controller(CP.as_reader(), CI)
|
2022-01-26 08:10:41 -08:00
|
|
|
|
|
|
|
|
CS = car.CarState.new_message()
|
|
|
|
|
CS.vEgo = 30
|
2023-08-22 16:48:02 -07:00
|
|
|
CS.steeringPressed = False
|
2022-01-26 08:10:41 -08:00
|
|
|
|
|
|
|
|
params = log.LiveParametersData.new_message()
|
|
|
|
|
|
2024-08-13 21:11:16 -07:00
|
|
|
lp = generate_livePose()
|
|
|
|
|
pose = Pose.from_live_pose(lp.livePose)
|
|
|
|
|
|
2022-01-26 08:10:41 -08:00
|
|
|
for _ in range(1000):
|
2024-08-13 21:11:16 -07:00
|
|
|
_, _, lac_log = controller.update(True, CS, VM, params, False, 1, pose)
|
2022-01-26 08:10:41 -08:00
|
|
|
|
2024-05-17 11:01:44 -07:00
|
|
|
assert lac_log.saturated
|