diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 0e49af07c35243..eef8ddb8028d6d 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -176,11 +176,13 @@ def get_car(logcan, sendcan): cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints) candidate = "mock" + disable_radar = Params().get_bool("DisableRadar") + CarInterface, CarController, CarState = interfaces[candidate] - car_params = CarInterface.get_params(candidate, fingerprints, car_fw) - car_params.carVin = vin - car_params.carFw = car_fw - car_params.fingerprintSource = source - car_params.fuzzyFingerprint = not exact_match + CP = CarInterface.get_params(candidate, fingerprints, car_fw, disable_radar) + CP.carVin = vin + CP.carFw = car_fw + CP.fingerprintSource = source + CP.fuzzyFingerprint = not exact_match - return CarInterface(car_params, CarController, CarState), car_params + return CarInterface(CP, CarController, CarState), CP diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index aead037815b7b6..1bc34dff4dc9f1 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -7,7 +7,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "chrysler" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.chrysler)] diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 5d899508163c68..3b15f03c9193e0 100755 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -8,7 +8,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "ford" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.ford)] diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 0473abfc74dbf6..7a0d20b4e485cb 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -39,7 +39,7 @@ def get_steer_feedforward_function(self): return CarInterfaceBase.get_steer_feedforward_default @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "gm" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.gm)] diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index f7c1be72e8af25..352fb2eb440192 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -3,7 +3,6 @@ from panda import Panda from common.conversions import Conversions as CV from common.numpy_fast import interp -from common.params import Params from selfdrive.car.honda.values import CarControllerParams, CruiseButtons, HondaFlags, CAR, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_ALT_BRAKE_SIGNAL from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config from selfdrive.car.interfaces import CarInterfaceBase @@ -28,7 +27,7 @@ def get_pid_accel_limits(CP, current_speed, cruise_speed): return CarControllerParams.NIDEC_ACCEL_MIN, interp(current_speed, ACCEL_MAX_BP, ACCEL_MAX_VALS) @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disable_radar=False): # pylint: disable=dangerous-default-value ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "honda" @@ -38,7 +37,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py # Disable the radar and let openpilot control longitudinal # WARNING: THIS DISABLES AEB! - ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar") + ret.openpilotLongitudinalControl = disable_radar ret.pcmCruise = not ret.openpilotLongitudinalControl else: diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 5d75be0aa458fa..f3a06c950ef5af 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 from cereal import car from panda import Panda -from common.params import Params from common.conversions import Conversions as CV from selfdrive.car.hyundai.values import CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, Buttons, CarControllerParams from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR @@ -18,7 +17,7 @@ def get_pid_accel_limits(CP, current_speed, cruise_speed): return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disable_radar=False): # pylint: disable=dangerous-default-value ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "hyundai" @@ -26,7 +25,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py ret.radarOffCan = RADAR_START_ADDR not in fingerprint[1] # WARNING: disabling radar also disables AEB (and we show the same warning on the instrument cluster as if you manually disabled AEB) - ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar") and (candidate not in LEGACY_SAFETY_MODE_CAR) + ret.openpilotLongitudinalControl = disable_radar and (candidate not in LEGACY_SAFETY_MODE_CAR) ret.pcmCruise = not ret.openpilotLongitudinalControl diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 9aa065801c4d88..95fabffb44591f 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -52,7 +52,7 @@ def get_pid_accel_limits(CP, current_speed, cruise_speed): @staticmethod @abstractmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): pass @staticmethod diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index c910d7e14880eb..b9a3d66ff26c2f 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -15,7 +15,7 @@ def compute_gb(accel, speed): return float(accel) / 4.0 @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "mazda" diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index d7fcad074834eb..79f37097c8c294 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -33,7 +33,7 @@ def compute_gb(accel, speed): return accel @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "mock" ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput)] diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index 63b4dad7fdb804..c078556434bf27 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -10,7 +10,7 @@ def __init__(self, CP, CarController, CarState): self.cp_adas = self.CS.get_adas_can_parser(CP) @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "nissan" diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index b56815682b80d8..64f2f41df3f577 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -7,7 +7,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "subaru" diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index 3bd1a0efca8656..9b0e5ba2b75ac6 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -8,7 +8,7 @@ class CarInterface(CarInterfaceBase): @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "tesla" diff --git a/selfdrive/car/tests/test_models.py b/selfdrive/car/tests/test_models.py index 71c9ac90d85702..ac0cc27164d8a1 100755 --- a/selfdrive/car/tests/test_models.py +++ b/selfdrive/car/tests/test_models.py @@ -8,7 +8,6 @@ from parameterized import parameterized_class from cereal import log, car -from common.params import Params from common.realtime import DT_CTRL from selfdrive.boardd.boardd import can_capnp_to_can_list, can_list_to_can_capnp from selfdrive.car.fingerprints import all_known_cars @@ -56,9 +55,7 @@ def setUpClass(cls): raise unittest.SkipTest raise Exception(f"missing test route for {cls.car_model}") - params = Params() - params.clear_all() - + disable_radar = False for seg in (2, 1, 0): try: lr = LogReader(get_url(cls.route, seg)) @@ -75,7 +72,7 @@ def setUpClass(cls): can_msgs.append(msg) elif msg.which() == "carParams": if msg.carParams.openpilotLongitudinalControl: - params.put_bool("DisableRadar", True) + disable_radar = True if len(can_msgs) > int(50 / DT_CTRL): break @@ -85,7 +82,7 @@ def setUpClass(cls): cls.can_msgs = sorted(can_msgs, key=lambda msg: msg.logMonoTime) cls.CarInterface, cls.CarController, cls.CarState = interfaces[cls.car_model] - cls.CP = cls.CarInterface.get_params(cls.car_model, fingerprint, []) + cls.CP = cls.CarInterface.get_params(cls.car_model, fingerprint, [], disable_radar) assert cls.CP assert cls.CP.carFingerprint == cls.car_model diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 4ac13d3d9781dd..aeac4ce2b215ff 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -15,7 +15,7 @@ def get_pid_accel_limits(CP, current_speed, cruise_speed): return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[], disable_radar=False): # pylint: disable=dangerous-default-value ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "toyota" diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index f96f1bae5a5660..ef42d63e962809 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -21,7 +21,7 @@ def __init__(self, CP, CarController, CarState): self.cp_ext = self.cp_cam @staticmethod - def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): + def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disable_radar=False): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "volkswagen" ret.radarOffCan = True