From a87ad763037056df84f778b477a275d87c020c58 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sun, 9 Aug 2026 16:12:40 -0400 Subject: [PATCH] Toyota: delay cancel command send --- opendbc/car/toyota/carcontroller.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opendbc/car/toyota/carcontroller.py b/opendbc/car/toyota/carcontroller.py index 8216a4f8a77..ff952639ed1 100644 --- a/opendbc/car/toyota/carcontroller.py +++ b/opendbc/car/toyota/carcontroller.py @@ -32,6 +32,8 @@ # EPS allows user torque above threshold for 50 frames before permanently faulting MAX_USER_TORQUE = 500 +CRUISE_CANCEL_DELAY_FRAMES = 10 + def get_long_tune(CP, params): if CP.flags & ToyotaFlags.TSS2: @@ -57,6 +59,7 @@ def __init__(self, dbc_names, CP): self.permit_braking = True self.steer_rate_counter = 0 self.distance_button = 0 + self.cancel_counter = 0 # *** start long control state *** self.long_pid = get_long_tune(self.CP, self.params) @@ -79,7 +82,8 @@ def update(self, CC, CS, now_nanos): actuators = CC.actuators stopping = actuators.longControlState == LongCtrlState.stopping hud_control = CC.hudControl - pcm_cancel_cmd = CC.cruiseControl.cancel + self.cancel_counter = self.cancel_counter + 1 if CC.cruiseControl.cancel else 0 + pcm_cancel_cmd = self.cancel_counter > CRUISE_CANCEL_DELAY_FRAMES lat_active = CC.latActive and abs(CS.out.steeringTorque) < MAX_USER_TORQUE if len(CC.orientationNED) == 3: