From 011054030064dc4cf7ff6590681389fdfb66ae19 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sat, 3 Feb 2024 01:43:30 -0600 Subject: [PATCH] Test car interfaces: init controllers (#31282) * not pytest? * copy what build release does * test controls step with CI and lat/long controllers, car controller.update, etc * clean up * not needed * not here * here * better cmt * fix test_fuzzy * see what's failing * need conftest for OPENPILOT_PREFIX to work! * up * clean up * test * fix * params put is slow * stash * Revert "stash" This reverts commit 22cc9f814c0699f7046970763663205907f2890b. * stash bad * just freaking merge * sort * rm --- selfdrive/car/tests/test_car_interfaces.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py index a920bd45da..2306cbf456 100755 --- a/selfdrive/car/tests/test_car_interfaces.py +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -14,6 +14,10 @@ from openpilot.selfdrive.car.car_helpers import interfaces from openpilot.selfdrive.car.fingerprints import all_known_cars from openpilot.selfdrive.car.fw_versions import FW_VERSIONS from openpilot.selfdrive.car.interfaces import get_interface_attr +from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle +from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID +from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque +from openpilot.selfdrive.controls.lib.longcontrol import LongControl from openpilot.selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator ALL_ECUS = list({ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()}) @@ -105,6 +109,17 @@ class TestCarInterfaces(unittest.TestCase): car_interface.apply(CC, now_nanos) now_nanos += DT_CTRL * 1e9 # 10ms + # Test controller initialization + # TODO: wait until card refactor is merged to run controller a few times, + # hypothesis also slows down significantly with just one more message draw + LongControl(car_params) + if car_params.steerControlType == car.CarParams.SteerControlType.angle: + LatControlAngle(car_params, car_interface) + elif car_params.lateralTuning.which() == 'pid': + LatControlPID(car_params, car_interface) + elif car_params.lateralTuning.which() == 'torque': + LatControlTorque(car_params, car_interface) + # Test radar interface RadarInterface = importlib.import_module(f'selfdrive.car.{car_params.carName}.radar_interface').RadarInterface radar_interface = RadarInterface(car_params)