mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-22 00:23:43 +08:00
9283040d84
* dd9a502d-c8e2-4831-b365-804b0ae0739d/600 80041070-d276-4fed-bdb9-0075e5442908/420 * no elementwise op * 9dabf0fe-2e60-44bf-8d3a-d20a74aca072/600 ae746590-0bb5-4a16-80db-15f02d314f03/300 c4663a12-b499-4c9b-90dd-b169e3948cb1/60 * explicit slice * some copies are useful * 1456d261-d232-4654-8885-4d9fde883894/440 c06eba55-1931-4e00-9d63-acad00161be0/700 af2eb6ba-1935-4318-aaf8-868db81a4932/425 * 154f663e-d3e9-4020-ad49-0e640588ebbe/399 badb5e69-504f-4544-a99e-ba75ed204b74/800 08330327-7663-4874-af7a-dcbd2c994ba7/800 * set steer rate cost to 1.0 * smaller temporal size * Update model reg * update model ref again * This did upload somehow * Update steer rate cost Co-authored-by: Yassine Yousfi <yyousfi1@binghamton.edu>
75 lines
2.4 KiB
Python
Executable File
75 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import math
|
|
import unittest
|
|
import importlib
|
|
from parameterized import parameterized
|
|
|
|
from cereal import car
|
|
from selfdrive.car.fingerprints import all_known_cars
|
|
from selfdrive.car.car_helpers import interfaces
|
|
from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS
|
|
|
|
class TestCarInterfaces(unittest.TestCase):
|
|
|
|
@parameterized.expand([(car,) for car in all_known_cars()])
|
|
def test_car_interfaces(self, car_name):
|
|
if car_name in FINGERPRINTS:
|
|
fingerprint = FINGERPRINTS[car_name][0]
|
|
else:
|
|
fingerprint = {}
|
|
|
|
CarInterface, CarController, CarState = interfaces[car_name]
|
|
fingerprints = {
|
|
0: fingerprint,
|
|
1: fingerprint,
|
|
2: fingerprint,
|
|
}
|
|
|
|
car_fw = []
|
|
|
|
car_params = CarInterface.get_params(car_name, fingerprints, car_fw)
|
|
car_interface = CarInterface(car_params, CarController, CarState)
|
|
assert car_params
|
|
assert car_interface
|
|
|
|
self.assertGreater(car_params.mass, 1)
|
|
|
|
if car_params.steerControlType != car.CarParams.SteerControlType.angle:
|
|
tuning = car_params.lateralTuning.which()
|
|
if tuning == 'pid':
|
|
self.assertTrue(len(car_params.lateralTuning.pid.kpV))
|
|
elif tuning == 'torque':
|
|
kf = car_params.lateralTuning.torque.kf
|
|
self.assertTrue(not math.isnan(kf) and kf > 0)
|
|
self.assertTrue(not math.isnan(car_params.lateralTuning.torque.friction))
|
|
elif tuning == 'indi':
|
|
self.assertTrue(len(car_params.lateralTuning.indi.outerLoopGainV))
|
|
|
|
# Run car interface
|
|
CC = car.CarControl.new_message()
|
|
for _ in range(10):
|
|
car_interface.update(CC, [])
|
|
car_interface.apply(CC)
|
|
car_interface.apply(CC)
|
|
|
|
CC = car.CarControl.new_message()
|
|
CC.enabled = True
|
|
for _ in range(10):
|
|
car_interface.update(CC, [])
|
|
car_interface.apply(CC)
|
|
car_interface.apply(CC)
|
|
|
|
# Test radar interface
|
|
RadarInterface = importlib.import_module(f'selfdrive.car.{car_params.carName}.radar_interface').RadarInterface
|
|
radar_interface = RadarInterface(car_params)
|
|
assert radar_interface
|
|
|
|
# Run radar interface once
|
|
radar_interface.update([])
|
|
if not car_params.radarOffCan and radar_interface.rcp is not None and \
|
|
hasattr(radar_interface, '_update') and hasattr(radar_interface, 'trigger_msg'):
|
|
radar_interface._update([radar_interface.trigger_msg])
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|