From 2258ea310ddcd7caeb8f63ede3ae4656d0bffe3f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 14 Jan 2025 21:37:55 -0800 Subject: [PATCH] Hyundai: match cancel button panda safety logic (#34390) * rising edge * should work * TODO * fix --- selfdrive/car/car_specific.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/car_specific.py b/selfdrive/car/car_specific.py index 0545430967..144f9f073b 100644 --- a/selfdrive/car/car_specific.py +++ b/selfdrive/car/car_specific.py @@ -149,7 +149,7 @@ class CarSpecificEvents: # Main button also can trigger an engagement on these cars self.cruise_buttons.append(any(ev.type in HYUNDAI_ENABLE_BUTTONS for ev in CS.buttonEvents)) events = self.create_common_events(CS, CS_prev, extra_gears=(GearShifter.sport, GearShifter.manumatic), - pcm_enable=self.CP.pcmCruise, allow_enable=any(self.cruise_buttons)) + pcm_enable=self.CP.pcmCruise, allow_enable=any(self.cruise_buttons), allow_button_cancel=False) # low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s) if CS.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.: @@ -165,7 +165,7 @@ class CarSpecificEvents: return events def create_common_events(self, CS: structs.CarState, CS_prev: car.CarState, extra_gears=None, pcm_enable=True, - allow_enable=True, enable_buttons=(ButtonType.accelCruise, ButtonType.decelCruise)): + allow_enable=True, allow_button_cancel=True, enable_buttons=(ButtonType.accelCruise, ButtonType.decelCruise)): events = Events() if CS.doorOpen: @@ -216,7 +216,8 @@ class CarSpecificEvents: if not self.CP.pcmCruise and (b.type in enable_buttons and not b.pressed): events.add(EventName.buttonEnable) # Disable on rising and falling edge of cancel for both stock and OP long - if b.type == ButtonType.cancel: + # TODO: only check the cancel button with openpilot longitudinal on all brands to match panda safety + if b.type == ButtonType.cancel and (allow_button_cancel or not self.CP.pcmCruise): events.add(EventName.buttonCancel) # Handle permanent and temporary steering faults