Skip to content

Commit

Permalink
Test car interfaces: init controllers (commaai#31282)
Browse files Browse the repository at this point in the history
* 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 22cc9f8.

* stash

bad

* just freaking merge

* sort

* rm
  • Loading branch information
sshane authored Feb 3, 2024
1 parent d0a1fa6 commit 0110540
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions selfdrive/car/tests/test_car_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
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()})
Expand Down Expand Up @@ -105,6 +109,17 @@ def test_car_interfaces(self, car_name, data):
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)
Expand Down

0 comments on commit 0110540

Please sign in to comment.