From 2f31c511f036275653c8bbe34793b100190187b2 Mon Sep 17 00:00:00 2001 From: James <91348155+FrogAi@users.noreply.github.com> Date: Mon, 1 Dec 2025 12:00:00 -0700 Subject: [PATCH] SDSU support --- opendbc_repo/opendbc/car/car_helpers.py | 5 +++++ opendbc_repo/opendbc/car/interfaces.py | 8 +++++++- opendbc_repo/opendbc/car/toyota/carstate.py | 8 ++++++++ opendbc_repo/opendbc/car/toyota/values.py | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/opendbc_repo/opendbc/car/car_helpers.py b/opendbc_repo/opendbc/car/car_helpers.py index 78b35c35..e2f1040b 100644 --- a/opendbc_repo/opendbc/car/car_helpers.py +++ b/opendbc_repo/opendbc/car/car_helpers.py @@ -11,6 +11,7 @@ from opendbc.car.structs import CarParams, CarParamsT from opendbc.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars from opendbc.car.fw_versions import ObdCallback, get_fw_versions_ordered, get_present_ecus, match_fw_to_car from opendbc.car.mock.values import CAR as MOCK +from opendbc.car.toyota.values import ToyotaFrogPilotFlags from opendbc.car.values import BRANDS from opendbc.car.vin import get_vin, is_valid_vin, VIN_UNKNOWN @@ -175,6 +176,10 @@ def get_car(can_recv: CanRecvCallable, can_send: CanSendCallable, set_obd_multip # FrogPilot variables FPCP: FrogPilotCarParams = CarInterface.get_frogpilot_params(candidate, fingerprints, car_fw, CP, frogpilot_toggles) + if CP.brand == "toyota" and FPCP.flags & ToyotaFrogPilotFlags.SMART_DSU.value: + CP.minEnableSpeed = -1 + CP.openpilotLongitudinalControl = True + if not CP.alphaLongitudinalAvailable and frogpilot_toggles.disable_openpilot_long: CP.openpilotLongitudinalControl = False FPCP.openpilotLongitudinalControlDisabled = True diff --git a/opendbc_repo/opendbc/car/interfaces.py b/opendbc_repo/opendbc/car/interfaces.py index 794d558e..e7f44519 100644 --- a/opendbc_repo/opendbc/car/interfaces.py +++ b/opendbc_repo/opendbc/car/interfaces.py @@ -22,7 +22,7 @@ from opendbc.car.honda.values import CAR as HONDA, HONDA_BOSCH, HondaSafetyFlags from opendbc.car.hyundai.hyundaicanfd import CanBus from opendbc.car.hyundai.values import CAR as HYUNDAI, CANFD_CAR, HyundaiFlags, HyundaiFrogPilotSafetyFlags from opendbc.car.mock.values import CAR as MOCK -from opendbc.car.toyota.values import CAR as TOYOTA, TSS2_CAR, UNSUPPORTED_DSU_CAR, ToyotaFrogPilotFlags, ToyotaSafetyFlags +from opendbc.car.toyota.values import CAR as TOYOTA, NO_DSU_CAR, TSS2_CAR, UNSUPPORTED_DSU_CAR, ToyotaFrogPilotFlags, ToyotaSafetyFlags from opendbc.car.values import PLATFORMS from opendbc.can import CANParser from openpilot.common.params import Params @@ -211,6 +211,12 @@ class CarInterfaceBase(ABC): fp_ret.canUsePedal = not CP.autoResumeSng fp_ret.canUseSDSU = candidate not in UNSUPPORTED_DSU_CAR and candidate not in TSS2_CAR + if 0x2AA in fingerprint[0] and candidate in NO_DSU_CAR: + fp_ret.flags |= ToyotaFlags.RADAR_CAN_FILTER.value + + if 0x2FF in fingerprint[0] or (0x2AA in fingerprint[0] and candidate in NO_DSU_CAR): + fp_ret.flags |= ToyotaFrogPilotFlags.SMART_DSU.value + return fp_ret @staticmethod diff --git a/opendbc_repo/opendbc/car/toyota/carstate.py b/opendbc_repo/opendbc/car/toyota/carstate.py index 549915f7..8f07935b 100644 --- a/opendbc_repo/opendbc/car/toyota/carstate.py +++ b/opendbc_repo/opendbc/car/toyota/carstate.py @@ -55,6 +55,8 @@ class CarState(CarStateBase): self.secoc_synchronization = None # FrogPilot variables + self.has_can_filter = self.FPCP.flags & ToyotaFrogPilotFlags.RADAR_CAN_FILTER.value + self.has_SDSU = self.FPCP.flags & ToyotaFrogPilotFlags.SMART_DSU.value def update(self, can_parsers, frogpilot_toggles) -> structs.CarState: cp = can_parsers[Bus.pt] @@ -204,6 +206,12 @@ class CarState(CarStateBase): # FrogPilot variables fp_ret = custom.FrogPilotCarState.new_message() + if self.has_SDSU and not self.has_can_filter: + prev_distance_button = self.distance_button + self.distance_button = cp.vl["SDSU"]["FD_BUTTON"] + + buttonEvents += create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise}) + buttonEvents += [ *create_button_events(self.pcm_acc_status == 9, False, {1: ButtonType.accelCruise}), *create_button_events(self.pcm_acc_status == 10, False, {1: ButtonType.decelCruise}), diff --git a/opendbc_repo/opendbc/car/toyota/values.py b/opendbc_repo/opendbc/car/toyota/values.py index c1b1dd03..b4d4bb85 100644 --- a/opendbc_repo/opendbc/car/toyota/values.py +++ b/opendbc_repo/opendbc/car/toyota/values.py @@ -82,6 +82,8 @@ class ToyotaFlags(IntFlag): # FrogPilot variables class ToyotaFrogPilotFlags(IntFlag): + RADAR_CAN_FILTER = 1 + SMART_DSU = 2 def dbc_dict(pt, radar):