Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't read params in car interfaces #23978

Merged
merged 1 commit into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions selfdrive/car/car_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,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
2 changes: 1 addition & 1 deletion selfdrive/car/chrysler/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/ford/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
5 changes: 2 additions & 3 deletions selfdrive/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,15 +17,15 @@ 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"
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)]
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

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/mazda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/mock/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/nissan/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/subaru/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/tesla/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
9 changes: 3 additions & 6 deletions selfdrive/car/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/volkswagen/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down