diff --git a/opendbc/sunnypilot/car/interfaces.py b/opendbc/sunnypilot/car/interfaces.py index 4f9e1345..61513be4 100644 --- a/opendbc/sunnypilot/car/interfaces.py +++ b/opendbc/sunnypilot/car/interfaces.py @@ -75,7 +75,10 @@ class NanoFFModel: def setup_interfaces(CI, CP: structs.CarParams, CP_SP: structs.CarParamsSP, - params_list: list[dict[str, str]], can_recv: CanRecvCallable = None, can_send: CanSendCallable = None) -> None: + params_list: list[dict[str, str]] | None = None, can_recv: CanRecvCallable = None, can_send: CanSendCallable = None) -> None: + if params_list is None: + params_list = [] + params_dict = {k: v for param in params_list for k, v in param.items()} _initialize_custom_longitudinal_tuning(CI, CP, CP_SP, params_dict) @@ -90,7 +93,7 @@ def _initialize_custom_longitudinal_tuning(CI, CP: structs.CarParams, CP_SP: str # Hyundai Custom Longitudinal Tuning if CP.brand == 'hyundai': - hyundai_longitudinal_tuning = int(params_dict["HyundaiLongitudinalTuning"]) + hyundai_longitudinal_tuning = int(params_dict.get("HyundaiLongitudinalTuning", 0)) if hyundai_longitudinal_tuning == LongitudinalTuningType.DYNAMIC: CP_SP.flags |= HyundaiFlagsSP.LONG_TUNING_DYNAMIC.value if hyundai_longitudinal_tuning == LongitudinalTuningType.PREDICTIVE: @@ -116,8 +119,8 @@ def _initialize_radar_tracks(CP: structs.CarParams, CP_SP: structs.CarParamsSP, def _initialize_stop_and_go(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params_dict: dict[str, str]) -> None: if CP.brand == 'subaru' and not CP.flags & (SubaruFlags.GLOBAL_GEN2 | SubaruFlags.HYBRID): - stop_and_go = int(params_dict["SubaruStopAndGo"]) == 1 - stop_and_go_manual_parking_brake = int(params_dict["SubaruStopAndGoManualParkingBrake"]) == 1 + stop_and_go = int(params_dict.get("SubaruStopAndGo", 0)) == 1 + stop_and_go_manual_parking_brake = int(params_dict.get("SubaruStopAndGoManualParkingBrake", 0)) == 1 if stop_and_go: CP_SP.flags |= SubaruFlagsSP.STOP_AND_GO.value @@ -129,7 +132,7 @@ def _initialize_stop_and_go(CP: structs.CarParams, CP_SP: structs.CarParamsSP, p def _initialize_toyota(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params_dict: dict[str, str]) -> None: if CP.brand == 'toyota': - toyota_stock_long = int(params_dict["ToyotaEnforceStockLongitudinal"]) == 1 + toyota_stock_long = int(params_dict.get("ToyotaEnforceStockLongitudinal", 0)) == 1 if toyota_stock_long: CP_SP.flags |= ToyotaFlagsSP.STOCK_LONGITUDINAL.value