remove cereal from car_helpers (TODO: caching)

pull/33208/head
Shane Smiskol 10 months ago
parent 672fc00b02
commit 37304e1325
  1. 8
      selfdrive/car/car_helpers.py
  2. 14
      selfdrive/car/data_structures.py
  3. 6
      selfdrive/car/interfaces.py

@ -1,9 +1,9 @@
import os
import time
from cereal import car
from openpilot.selfdrive.car import carlog
from openpilot.selfdrive.car.can_definitions import CanRecvCallable, CanSendCallable
from openpilot.selfdrive.car.data_structures import CarParams
from openpilot.selfdrive.car.interfaces import get_interface_attr
from openpilot.selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars
from openpilot.selfdrive.car.vin import get_vin, is_valid_vin, VIN_UNKNOWN
@ -135,17 +135,17 @@ def fingerprint(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_mu
car_fingerprint, finger = can_fingerprint(can_recv)
exact_match = True
source = car.CarParams.FingerprintSource.can
source = CarParams.FingerprintSource.can
# If FW query returns exactly 1 candidate, use it
if len(fw_candidates) == 1:
car_fingerprint = list(fw_candidates)[0]
source = car.CarParams.FingerprintSource.fw
source = CarParams.FingerprintSource.fw
exact_match = exact_fw_match
if fixed_fingerprint:
car_fingerprint = fixed_fingerprint
source = car.CarParams.FingerprintSource.fixed
source = CarParams.FingerprintSource.fixed
carlog.error({"event": "fingerprinted", "car_fingerprint": str(car_fingerprint), "source": source, "fuzzy": not exact_match,
"cached": cached, "fw_count": len(car_fw), "ecu_responses": list(ecu_rx_addrs), "vin_rx_addr": vin_rx_addr,

@ -170,8 +170,9 @@ class CarParams:
carFw: list['CarParams.CarFw'] = auto_field()
radarTimeStep: float = 0.05 # time delta between radar updates, 20Hz is very standard
# fingerprintSource: FingerprintSource = auto_field()
# networkLocation: NetworkLocation = auto_field() # Where Panda/C2 is integrated into the car's CAN network
fingerprintSource: 'CarParams.FingerprintSource' = field(default_factory=lambda: CarParams.FingerprintSource.can)
# Where Panda/C2 is integrated into the car's CAN network
networkLocation: 'CarParams.NetworkLocation' = field(default_factory=lambda: CarParams.NetworkLocation.fwdCamera)
wheelSpeedFactor: float = auto_field() # Multiplier on wheels speeds to computer actual speeds
@ -274,3 +275,12 @@ class CarParams:
programmedFuelInjection = auto()
debug = auto()
class FingerprintSource(StrEnum):
can = auto()
fw = auto()
fixed = auto()
class NetworkLocation(StrEnum):
fwdCamera = auto() # Standard/default integration at LKAS camera
gateway = auto() # Integration at vehicle's CAN gateway

@ -117,14 +117,14 @@ class CarInterfaceBase(ABC):
return ACCEL_MIN, ACCEL_MAX
@classmethod
def get_non_essential_params(cls, candidate: str):
def get_non_essential_params(cls, candidate: str) -> CarParams:
"""
Parameters essential to controlling the car may be incomplete or wrong without FW versions or fingerprints.
"""
return cls.get_params(candidate, gen_empty_fingerprint(), list(), False, False)
@classmethod
def get_params(cls, candidate: str, fingerprint: dict[int, dict[int, int]], car_fw: list[CarParams.CarFw], experimental_long: bool, docs: bool):
def get_params(cls, candidate: str, fingerprint: dict[int, dict[int, int]], car_fw: list[CarParams.CarFw], experimental_long: bool, docs: bool) -> CarParams:
ret = CarInterfaceBase.get_std_params(candidate)
platform = PLATFORMS[candidate]
@ -152,7 +152,7 @@ class CarInterfaceBase(ABC):
@staticmethod
@abstractmethod
def _get_params(ret: CarParams, candidate, fingerprint: dict[int, dict[int, int]],
car_fw: list[CarParams.CarFw], experimental_long: bool, docs: bool):
car_fw: list[CarParams.CarFw], experimental_long: bool, docs: bool) -> CarParams:
raise NotImplementedError
@staticmethod

Loading…
Cancel
Save