From 29528bdcb0780f429b0d9c263e5b7c1fcad15a0e Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Wed, 10 Nov 2021 23:25:41 -0600 Subject: [PATCH] Mazda: fix occasional main cruise disable (#22807) Signed-off-by: Jafar Al-Gharaibeh old-commit-hash: b18661a3a66979d2c12a8bbde109cb7e50f00e1a --- selfdrive/car/mazda/carcontroller.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/mazda/carcontroller.py b/selfdrive/car/mazda/carcontroller.py index 32a02fd15d..06c5eb0948 100644 --- a/selfdrive/car/mazda/carcontroller.py +++ b/selfdrive/car/mazda/carcontroller.py @@ -33,13 +33,14 @@ class CarController(): can_sends.append(mazdacan.create_button_cmd(self.packer, CS.CP.carFingerprint, CS.crz_btns_counter, Buttons.RESUME)) if c.cruiseControl.cancel or (CS.out.cruiseState.enabled and not c.enabled): - # if brake is pressed, let us wait >20ms before trying to disable crz to avoid + # If brake is pressed, let us wait >70ms before trying to disable crz to avoid # a race condition with the stock system, where the second cancel from openpilot - # will disable the crz 'main on' + # will disable the crz 'main on'. crz ctrl msg runs at 50hz. 70ms allows us to + # read 3 messages and most likely sync state before we attempt cancel. self.brake_counter = self.brake_counter + 1 - if frame % 20 == 0 and not (CS.out.brakePressed and self.brake_counter < 3): + if frame % 10 == 0 and not (CS.out.brakePressed and self.brake_counter < 7): # Cancel Stock ACC if it's enabled while OP is disengaged - # Send at a rate of 5hz until we sync with stock ACC state + # Send at a rate of 10hz until we sync with stock ACC state can_sends.append(mazdacan.create_button_cmd(self.packer, CS.CP.carFingerprint, CS.crz_btns_counter, Buttons.CANCEL)) else: self.brake_counter = 0