cars: generic interaction detection (#33710)

* works

* clean up

* bump

* clean up

* it used to consider an action hold down the button, so shouldn't only consider rising edge

* bump
pull/33712/head
Shane Smiskol 7 months ago committed by GitHub
parent 6aebec7b34
commit 06f2ca1179
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      opendbc_repo
  2. 8
      selfdrive/car/car_specific.py

@ -1 +1 @@
Subproject commit 0cdc684e097f386554bbc1a6946a4efe8bc7cfd6
Subproject commit 900246ddb3ff107f55aab1c8e0d96713a6f4a770

@ -1,9 +1,11 @@
from collections import deque
from cereal import car
import cereal.messaging as messaging
from opendbc.car import DT_CTRL, structs
from opendbc.car.interfaces import MAX_CTRL_SPEED, CarStateBase
from opendbc.car.volkswagen.values import CarControllerParams as VWCarControllerParams
from opendbc.car.hyundai.interface import ENABLE_BUTTONS as HYUNDAI_ENABLE_BUTTONS
from opendbc.car.hyundai.carstate import PREV_BUTTON_SAMPLES as HYUNDAI_PREV_BUTTON_SAMPLES
from openpilot.selfdrive.selfdrived.events import Events
@ -37,6 +39,8 @@ class CarSpecificEvents:
self.no_steer_warning = False
self.silent_steer_warning = True
self.cruise_buttons: deque = deque([], maxlen=HYUNDAI_PREV_BUTTON_SAMPLES)
def update(self, CS: CarStateBase, CS_prev: car.CarState, CC_prev: car.CarControl):
if self.CP.carName in ('body', 'mock'):
events = Events()
@ -149,8 +153,8 @@ class CarSpecificEvents:
# On some newer model years, the CANCEL button acts as a pause/resume button based on the PCM state
# To avoid re-engaging when openpilot cancels, check user engagement intention via buttons
# Main button also can trigger an engagement on these cars
allow_enable = any(btn in HYUNDAI_ENABLE_BUTTONS for btn in CS.cruise_buttons) or any(CS.main_buttons) # type: ignore[attr-defined]
events = self.create_common_events(CS.out, CS_prev, pcm_enable=self.CP.pcmCruise, allow_enable=allow_enable)
self.cruise_buttons.append(any(ev.type in HYUNDAI_ENABLE_BUTTONS for ev in CS.out.buttonEvents))
events = self.create_common_events(CS.out, CS_prev, pcm_enable=self.CP.pcmCruise, allow_enable=any(self.cruise_buttons))
# low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s)
if CS.out.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.:

Loading…
Cancel
Save