From 9b588590f7030df04f844097d07fcb94c1b6aad3 Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Mon, 31 Mar 2025 13:42:02 +0800 Subject: [PATCH] Toyota Radar Filter - 2025/05/27 --- opendbc_repo/opendbc/car/toyota/carcontroller.py | 4 ++-- opendbc_repo/opendbc/car/toyota/interface.py | 12 +++++++++++- opendbc_repo/opendbc/car/toyota/values.py | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/opendbc_repo/opendbc/car/toyota/carcontroller.py b/opendbc_repo/opendbc/car/toyota/carcontroller.py index 80864c2cc..6d5a9bf35 100644 --- a/opendbc_repo/opendbc/car/toyota/carcontroller.py +++ b/opendbc_repo/opendbc/car/toyota/carcontroller.py @@ -268,7 +268,7 @@ class CarController(CarControllerBase): hud_control.rightLaneVisible, hud_control.leftLaneDepart, hud_control.rightLaneDepart, lat_active, CS.lkas_hud)) - if (self.frame % 100 == 0 or send_ui) and (self.CP.enableDsu or self.CP.flags & ToyotaFlags.DISABLE_RADAR.value): + if not self.CP.flags & ToyotaFlags.RADAR_FILTER.value and (self.frame % 100 == 0 or send_ui) and (self.CP.enableDsu or self.CP.flags & ToyotaFlags.DISABLE_RADAR.value): can_sends.append(toyotacan.create_fcw_command(self.packer, fcw_alert)) # *** static msgs *** @@ -277,7 +277,7 @@ class CarController(CarControllerBase): can_sends.append(CanData(addr, vl, bus)) # keep radar disabled - if self.frame % 20 == 0 and self.CP.flags & ToyotaFlags.DISABLE_RADAR.value: + if not self.CP.flags & ToyotaFlags.RADAR_FILTER.value and self.frame % 20 == 0 and self.CP.flags & ToyotaFlags.DISABLE_RADAR.value: can_sends.append(make_tester_present_msg(0x750, 0, 0xF)) new_actuators = actuators.as_builder() diff --git a/opendbc_repo/opendbc/car/toyota/interface.py b/opendbc_repo/opendbc/car/toyota/interface.py index b0f75ef7d..e5ab33958 100644 --- a/opendbc_repo/opendbc/car/toyota/interface.py +++ b/opendbc_repo/opendbc/car/toyota/interface.py @@ -118,6 +118,16 @@ class CarInterface(CarInterfaceBase): if experimental_long and candidate in RADAR_ACC_CAR: ret.flags |= ToyotaFlags.DISABLE_RADAR.value + # RADAR_ACC_CAR = CHR TSS2 / RAV4 TSS2 + # NO_DSU_CAR = CAMRY / CHR + if 0x2FF in fingerprint[0] or 0x2AA in fingerprint[0]: + print("----------------------------------------------") + print("dragonpilot: RADAR_FILTER detected!") + print("----------------------------------------------") + ret.safetyConfigs[0].safetyParam |= ToyotaSafetyFlags.LONG_FILTER.value + ret.experimentalLongitudinalAvailable = False + ret.flags |= ToyotaFlags.RADAR_FILTER.value | ToyotaFlags.DISABLE_RADAR.value + # openpilot longitudinal enabled by default: # - cars w/ DSU disconnected # - TSS2 cars with camera sending ACC_CONTROL where we can block it @@ -156,6 +166,6 @@ class CarInterface(CarInterfaceBase): @staticmethod def init(CP, can_recv, can_send): # disable radar if alpha longitudinal toggled on radar-ACC car - if CP.flags & ToyotaFlags.DISABLE_RADAR.value: + if not CP.flags & ToyotaFlags.RADAR_FILTER.value and CP.flags & ToyotaFlags.DISABLE_RADAR.value: communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) disable_ecu(can_recv, can_send, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=communication_control) diff --git a/opendbc_repo/opendbc/car/toyota/values.py b/opendbc_repo/opendbc/car/toyota/values.py index 4848a354e..e82af27d0 100644 --- a/opendbc_repo/opendbc/car/toyota/values.py +++ b/opendbc_repo/opendbc/car/toyota/values.py @@ -55,6 +55,7 @@ class ToyotaSafetyFlags(IntFlag): STOCK_LONGITUDINAL = (2 << 8) LTA = (4 << 8) SECOC = (8 << 8) + LONG_FILTER = (16 << 8) class ToyotaFlags(IntFlag): @@ -77,6 +78,7 @@ class ToyotaFlags(IntFlag): SECOC = 2048 ALKA = 2 ** 12 + RADAR_FILTER = 2 ** 13 class Footnote(Enum): CAMRY = CarFootnote(