Mazda: fix occasional main cruise disable (#22807)

Signed-off-by: Jafar Al-Gharaibeh <to.jafar@gmail.com>
old-commit-hash: b18661a3a6
commatwo_master
Jafar Al-Gharaibeh 4 years ago committed by GitHub
parent d6c42f11f4
commit 29528bdcb0
  1. 9
      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

Loading…
Cancel
Save