move getting platform to get_params (#31871)

* better

* string

* not here
pull/31873/head
Justin Newberry 1 year ago committed by GitHub
parent 1ecbbef46b
commit ca5a2ed942
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      selfdrive/car/car_helpers.py
  2. 25
      selfdrive/car/interfaces.py
  3. 4
      selfdrive/car/tests/test_models.py
  4. 5
      tools/car_porting/test_car_model.py

@ -5,7 +5,6 @@ from collections.abc import Callable
from cereal import car
from openpilot.common.params import Params
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car.values import PLATFORMS
from openpilot.system.version import is_comma_remote, is_tested_branch
from openpilot.selfdrive.car.interfaces import get_interface_attr
from openpilot.selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars
@ -192,9 +191,7 @@ def fingerprint(logcan, sendcan, num_pandas):
fw_count=len(car_fw), ecu_responses=list(ecu_rx_addrs), vin_rx_addr=vin_rx_addr, vin_rx_bus=vin_rx_bus,
fingerprints=repr(finger), fw_query_time=fw_query_time, error=True)
car_platform = PLATFORMS.get(car_fingerprint, MOCK.MOCK)
return car_platform, finger, vin, car_fw, source, exact_match
return car_fingerprint, finger, vin, car_fw, source, exact_match
def get_car_interface(CP):

@ -14,7 +14,8 @@ from openpilot.common.simple_kalman import KF1D, get_kalman_gain
from openpilot.common.numpy_fast import clip
from openpilot.common.realtime import DT_CTRL
from openpilot.selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG
from openpilot.selfdrive.car.values import Platform
from openpilot.selfdrive.car.mock.values import CAR as MOCK
from openpilot.selfdrive.car.values import PLATFORMS
from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, get_friction
from openpilot.selfdrive.controls.lib.events import Events
from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel
@ -102,24 +103,26 @@ class CarInterfaceBase(ABC):
return ACCEL_MIN, ACCEL_MAX
@classmethod
def get_non_essential_params(cls, candidate: Platform):
def get_non_essential_params(cls, candidate: str):
"""
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: Platform, fingerprint: dict[int, dict[int, int]], car_fw: list[car.CarParams.CarFw], experimental_long: bool, docs: bool):
def get_params(cls, candidate: str, fingerprint: dict[int, dict[int, int]], car_fw: list[car.CarParams.CarFw], experimental_long: bool, docs: bool):
platform = PLATFORMS.get(candidate, MOCK.MOCK)
ret = CarInterfaceBase.get_std_params(candidate)
ret.mass = candidate.config.specs.mass
ret.wheelbase = candidate.config.specs.wheelbase
ret.steerRatio = candidate.config.specs.steerRatio
ret.centerToFront = ret.wheelbase * candidate.config.specs.centerToFrontRatio
ret.minEnableSpeed = candidate.config.specs.minEnableSpeed
ret.minSteerSpeed = candidate.config.specs.minSteerSpeed
ret.tireStiffnessFactor = candidate.config.specs.tireStiffnessFactor
ret.flags |= int(candidate.config.flags)
ret.mass = platform.config.specs.mass
ret.wheelbase = platform.config.specs.wheelbase
ret.steerRatio = platform.config.specs.steerRatio
ret.centerToFront = ret.wheelbase * platform.config.specs.centerToFrontRatio
ret.minEnableSpeed = platform.config.specs.minEnableSpeed
ret.minSteerSpeed = platform.config.specs.minSteerSpeed
ret.tireStiffnessFactor = platform.config.specs.tireStiffnessFactor
ret.flags |= int(platform.config.flags)
ret = cls._get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs)

@ -19,7 +19,7 @@ from openpilot.selfdrive.car.fingerprints import all_known_cars
from openpilot.selfdrive.car.car_helpers import FRAME_FINGERPRINT, interfaces
from openpilot.selfdrive.car.honda.values import CAR as HONDA, HondaFlags
from openpilot.selfdrive.car.tests.routes import non_tested_cars, routes, CarTestRoute
from openpilot.selfdrive.car.values import PLATFORMS, Platform
from openpilot.selfdrive.car.values import Platform
from openpilot.selfdrive.controls.controlsd import Controls
from openpilot.selfdrive.test.helpers import read_segment_list
from openpilot.system.hardware.hw import DEFAULT_DOWNLOAD_CACHE_ROOT
@ -95,7 +95,7 @@ class TestCarModelBase(unittest.TestCase):
if msg.carParams.openpilotLongitudinalControl:
experimental_long = True
if cls.platform is None and not cls.ci:
cls.platform = PLATFORMS.get(msg.carParams.carFingerprint)
cls.platform = msg.carParams.carFingerprint
# Log which can frame the panda safety mode left ELM327, for CAN validity checks
elif msg.which() == 'pandaStates':

@ -5,7 +5,6 @@ import unittest
from openpilot.selfdrive.car.tests.routes import CarTestRoute
from openpilot.selfdrive.car.tests.test_models import TestCarModel
from openpilot.selfdrive.car.values import PLATFORMS
from openpilot.tools.lib.route import SegmentName
@ -33,9 +32,7 @@ if __name__ == "__main__":
route_or_segment_name = SegmentName(args.route_or_segment_name.strip(), allow_route_name=True)
segment_num = route_or_segment_name.segment_num if route_or_segment_name.segment_num != -1 else None
platform = PLATFORMS.get(args.car)
test_route = CarTestRoute(route_or_segment_name.route_name.canonical_name, platform, segment=segment_num)
test_route = CarTestRoute(route_or_segment_name.route_name.canonical_name, args.car, segment=segment_num)
test_suite = create_test_models_suite([test_route], ci=args.ci)
unittest.TextTestRunner().run(test_suite)

Loading…
Cancel
Save