Skip to content

Commit 5c30208

Browse files
authored
car interfaces: each specify their own dependencies (#34874)
* remove these * fix * oops * clean up * nl * bump
1 parent 4e7c605 commit 5c30208

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

selfdrive/car/card.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from opendbc.car.can_definitions import CanData, CanRecvCallable, CanSendCallable
1616
from opendbc.car.carlog import carlog
1717
from opendbc.car.fw_versions import ObdCallback
18-
from opendbc.car.car_helpers import get_car, get_radar_interface
18+
from opendbc.car.car_helpers import get_car, interfaces
1919
from opendbc.car.interfaces import CarInterfaceBase, RadarInterfaceBase
2020
from opendbc.safety import ALTERNATIVE_EXPERIENCE
2121
from openpilot.selfdrive.pandad import can_capnp_to_list, can_list_to_can_capnp
@@ -99,7 +99,7 @@ def __init__(self, CI=None, RI=None) -> None:
9999
cached_params = _cached_params
100100

101101
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, cached_params)
102-
self.RI = get_radar_interface(self.CI.CP)
102+
self.RI = interfaces[self.CI.CP.carFingerprint].RadarInterface(self.CI.CP)
103103
self.CP = self.CI.CP
104104

105105
# continue onto next fingerprinting step in pandad

selfdrive/car/tests/test_car_interfaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ class TestCarInterfaces:
3434
phases=(Phase.reuse, Phase.generate, Phase.shrink))
3535
@given(data=st.data())
3636
def test_car_interfaces(self, car_name, data):
37-
CarInterface, CarController, CarState, RadarInterface = interfaces[car_name]
37+
CarInterface = interfaces[car_name]
3838

3939
args = get_fuzzy_car_interface_args(data.draw)
4040

4141
car_params = CarInterface.get_params(car_name, args['fingerprints'], args['car_fw'],
4242
experimental_long=args['experimental_long'], docs=False)
4343
car_params = car_params.as_reader()
44-
car_interface = CarInterface(car_params, CarController, CarState)
44+
car_interface = CarInterface(car_params)
4545
assert car_params
4646
assert car_interface
4747

selfdrive/car/tests/test_models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def setUpClass(cls):
151151
# if relay is expected to be open in the route
152152
cls.openpilot_enabled = cls.car_safety_mode_frame is not None
153153

154-
cls.CarInterface, cls.CarController, cls.CarState, cls.RadarInterface = interfaces[cls.platform]
155-
cls.CP = cls.CarInterface.get_params(cls.platform, cls.fingerprint, car_fw, experimental_long, docs=False)
154+
cls.CarInterface = interfaces[cls.platform]
155+
cls.CP = cls.CarInterface.get_params(cls.platform, cls.fingerprint, car_fw, experimental_long, docs=False)
156156
assert cls.CP
157157
assert cls.CP.carFingerprint == cls.platform
158158

@@ -163,7 +163,7 @@ def tearDownClass(cls):
163163
del cls.can_msgs
164164

165165
def setUp(self):
166-
self.CI = self.CarInterface(self.CP.copy(), self.CarController, self.CarState)
166+
self.CI = self.CarInterface(self.CP.copy())
167167
assert self.CI
168168

169169
# TODO: check safetyModel is in release panda build
@@ -210,7 +210,7 @@ def test_car_interface(self):
210210
self.assertEqual(can_invalid_cnt, 0)
211211

212212
def test_radar_interface(self):
213-
RI = self.RadarInterface(self.CP)
213+
RI = self.CarInterface.RadarInterface(self.CP)
214214
assert RI
215215

216216
# Since OBD port is multiplexed to bus 1 (commonly radar bus) while fingerprinting,
@@ -273,7 +273,7 @@ def test_panda_safety_tx_cases(self, data=None):
273273
def test_car_controller(car_control):
274274
now_nanos = 0
275275
msgs_sent = 0
276-
CI = self.CarInterface(self.CP, self.CarController, self.CarState)
276+
CI = self.CarInterface(self.CP)
277277
for _ in range(round(10.0 / DT_CTRL)): # make sure we hit the slowest messages
278278
CI.update([])
279279
_, sendcan = CI.apply(car_control, now_nanos)

selfdrive/controls/controlsd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from openpilot.common.realtime import config_realtime_process, Priority, Ratekeeper
1010
from openpilot.common.swaglog import cloudlog
1111

12-
from opendbc.car.car_helpers import get_car_interface
12+
from opendbc.car.car_helpers import interfaces
1313
from opendbc.car.vehicle_model import VehicleModel
1414
from openpilot.selfdrive.controls.lib.drive_helpers import clip_curvature
1515
from openpilot.selfdrive.controls.lib.latcontrol import LatControl, MIN_LATERAL_CONTROL_SPEED
@@ -33,7 +33,7 @@ def __init__(self) -> None:
3333
self.CP = messaging.log_from_bytes(self.params.get("CarParams", block=True), car.CarParams)
3434
cloudlog.info("controlsd got CarParams")
3535

36-
self.CI = get_car_interface(self.CP)
36+
self.CI = interfaces[self.CP.carFingerprint](self.CP)
3737

3838
self.sm = messaging.SubMaster(['liveParameters', 'liveTorqueParameters', 'modelV2', 'selfdriveState',
3939
'liveCalibration', 'livePose', 'longitudinalPlan', 'carState', 'carOutput',

selfdrive/controls/lib/tests/test_latcontrol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class TestLatControl:
1717

1818
@parameterized.expand([(HONDA.HONDA_CIVIC, LatControlPID), (TOYOTA.TOYOTA_RAV4, LatControlTorque), (NISSAN.NISSAN_LEAF, LatControlAngle)])
1919
def test_saturation(self, car_name, controller):
20-
CarInterface, CarController, CarState, RadarInterface = interfaces[car_name]
20+
CarInterface = interfaces[car_name]
2121
CP = CarInterface.get_non_essential_params(car_name)
22-
CI = CarInterface(CP, CarController, CarState)
22+
CI = CarInterface(CP)
2323
VM = VehicleModel(CP)
2424

2525
controller = controller(CP.as_reader(), CI)

selfdrive/test/process_replay/process_replay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def card_fingerprint_callback(rc, pm, msgs, fingerprint):
342342
def get_car_params_callback(rc, pm, msgs, fingerprint):
343343
params = Params()
344344
if fingerprint:
345-
CarInterface, _, _, _ = interfaces[fingerprint]
345+
CarInterface = interfaces[fingerprint]
346346
CP = CarInterface.get_non_essential_params(fingerprint)
347347
else:
348348
can = DummySocket()

0 commit comments

Comments
 (0)