Files
sunnypilot/selfdrive/controls/lib/tests/test_latcontrol.py
Shane Smiskol 7556233cca Reapply "move car.capnp to opendbc (#33722)" (#33728)
* Reapply "move car.capnp to opendbc" (#33725)

This reverts commit 9d52a5b485.

* why can't i repro?!

* Revert "why can't i repro?!"

This reverts commit 0435d218f790faf7b7aaed27d05ab9ee67b087e6.

* does this cause card to try and read it?

* better place

* wtf

* Reapply "why can't i repro?!"

This reverts commit d24fd5a0abf454f47d5591e3b39039fdc4d0251c.

* also here
2024-10-03 22:47:03 -07:00

40 lines
1.5 KiB
Python

from parameterized import parameterized
from cereal import car, log
from opendbc.car.car_helpers import interfaces
from opendbc.car.honda.values import CAR as HONDA
from opendbc.car.toyota.values import CAR as TOYOTA
from opendbc.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
from openpilot.selfdrive.locationd.helpers import Pose
from openpilot.common.mock.generators import generate_livePose
class TestLatControl:
@parameterized.expand([(HONDA.HONDA_CIVIC, LatControlPID), (TOYOTA.TOYOTA_RAV4, LatControlTorque), (NISSAN.NISSAN_LEAF, LatControlAngle)])
def test_saturation(self, car_name, controller):
CarInterface, CarController, CarState, RadarInterface = interfaces[car_name]
CP = CarInterface.get_non_essential_params(car_name)
CI = CarInterface(CP, CarController, CarState)
VM = VehicleModel(CP)
controller = controller(CP.as_reader(), CI)
CS = car.CarState.new_message()
CS.vEgo = 30
CS.steeringPressed = False
params = log.LiveParametersData.new_message()
lp = generate_livePose()
pose = Pose.from_live_pose(lp.livePose)
for _ in range(1000):
_, _, lac_log = controller.update(True, CS, VM, params, False, 1, pose)
assert lac_log.saturated