diff --git a/panda b/panda index d51dd496cb..2db69bc941 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit d51dd496cbdc8665928af40247582bc62dba1f2a +Subproject commit 2db69bc94120a3c10f39cdedc9d83315f9ba801e diff --git a/selfdrive/car/gm/carcontroller.py b/selfdrive/car/gm/carcontroller.py index f28a0f7b59..c96b982503 100644 --- a/selfdrive/car/gm/carcontroller.py +++ b/selfdrive/car/gm/carcontroller.py @@ -10,6 +10,9 @@ from selfdrive.car.gm.values import DBC, CanBus, CarControllerParams, CruiseButt VisualAlert = car.CarControl.HUDControl.VisualAlert NetworkLocation = car.CarParams.NetworkLocation +# Camera cancels up to 0.1s after brake is pressed, ECM allows 0.5s +CAMERA_CANCEL_DELAY_FRAMES = 10 + class CarController: def __init__(self, dbc_name, CP, VM): @@ -20,6 +23,7 @@ class CarController: self.apply_brake = 0 self.frame = 0 self.last_button_frame = 0 + self.cancel_counter = 0 self.lka_steering_cmd_counter = 0 self.sent_lka_steering_cmd = False @@ -111,9 +115,13 @@ class CarController: can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN) else: + # While car is braking, cancel button causes ECM to enter a soft disable state with a fault status. + # A delayed cancellation allows camera to cancel and avoids a fault when user depresses brake quickly + self.cancel_counter = self.cancel_counter + 1 if CC.cruiseControl.cancel else 0 + # Stock longitudinal, integrated at camera if (self.frame - self.last_button_frame) * DT_CTRL > 0.04: - if CC.cruiseControl.cancel: + if self.cancel_counter > CAMERA_CANCEL_DELAY_FRAMES: self.last_button_frame = self.frame can_sends.append(gmcan.create_buttons(self.packer_pt, CanBus.CAMERA, CS.buttons_counter, CruiseButtons.CANCEL)) diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index de63f56eab..7cb2274674 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -55,12 +55,7 @@ class CarState(CarStateBase): # To avoid a cruise fault we need to match the ECM's brake pressed signal and threshold # https://static.nhtsa.gov/odi/tsbs/2017/MC-10137629-9999.pdf ret.brake = pt_cp.vl["ECMAcceleratorPos"]["BrakePedalPos"] - if self.CP.networkLocation != NetworkLocation.fwdCamera: - ret.brakePressed = ret.brake >= 8 - else: - # While car is braking, cancel button causes ECM to enter a soft disable state with a fault status. - # Match ECM threshold at a standstill to allow the camera to cancel earlier - ret.brakePressed = ret.brake >= 20 + ret.brakePressed = ret.brake >= 8 # Regen braking is braking if self.CP.transmissionType == TransmissionType.direct: