mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 05:24:06 +08:00
Move gas/brake pedal event logic to controlsd (#23850)
* move some state machine logic to controlsd move some state machine logic to controlsd * same order same order * move unsafeMode up * disable at standstill * save last CS save last CS * do we need to copy at all? * don't copy * rename * Update selfdrive/controls/controlsd.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Revert "Update selfdrive/controls/controlsd.py" This reverts commit 10bb51a0f0ee0d8e2a27c746a0638280a5eaea8a. * Update refs Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
@@ -72,7 +72,6 @@ class CarInterfaceBase(ABC):
|
||||
def get_std_params(candidate, fingerprint):
|
||||
ret = car.CarParams.new_message()
|
||||
ret.carFingerprint = candidate
|
||||
ret.unsafeMode = 0 # see panda/board/safety_declarations.h for allowed values
|
||||
|
||||
# standard ALC params
|
||||
ret.steerControlType = car.CarParams.SteerControlType.torque
|
||||
@@ -142,7 +141,6 @@ class CarInterfaceBase(ABC):
|
||||
if cs_out.parkingBrake:
|
||||
events.add(EventName.parkBrake)
|
||||
|
||||
|
||||
# Handle permanent and temporary steering faults
|
||||
self.steering_unpressed = 0 if cs_out.steeringPressed else self.steering_unpressed + 1
|
||||
if cs_out.steerFaultTemporary:
|
||||
@@ -157,11 +155,6 @@ class CarInterfaceBase(ABC):
|
||||
if cs_out.steerFaultPermanent:
|
||||
events.add(EventName.steerUnavailable)
|
||||
|
||||
# Disable on rising edge of gas or brake. Also disable on brake when speed > 0.
|
||||
if (cs_out.gasPressed and not self.CS.out.gasPressed) or \
|
||||
(cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)):
|
||||
events.add(EventName.pedalPressed)
|
||||
|
||||
# we engage when pcm is active (rising edge)
|
||||
if pcm_enable:
|
||||
if cs_out.cruiseState.enabled and not self.CS.out.cruiseState.enabled:
|
||||
|
||||
@@ -94,6 +94,7 @@ class Controls:
|
||||
get_one_can(self.can_sock)
|
||||
|
||||
self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan'])
|
||||
self.CP.unsafeMode = 0 # see panda/board/safety_declarations.h for allowed values
|
||||
|
||||
# read params
|
||||
self.is_metric = params.get_bool("IsMetric")
|
||||
@@ -119,6 +120,7 @@ class Controls:
|
||||
put_nonblocking("CarParamsCache", cp_bytes)
|
||||
|
||||
self.CC = car.CarControl.new_message()
|
||||
self.CS_prev = car.CarState.new_message()
|
||||
self.AM = AlertManager()
|
||||
self.events = Events()
|
||||
|
||||
@@ -192,6 +194,11 @@ class Controls:
|
||||
self.events.add(EventName.controlsInitializing)
|
||||
return
|
||||
|
||||
# Disable on rising edge of gas or brake. Also disable on brake when speed > 0
|
||||
if (CS.gasPressed and not self.CS_prev.gasPressed) or \
|
||||
(CS.brakePressed and (not self.CS_prev.brakePressed or not CS.standstill)):
|
||||
self.events.add(EventName.pedalPressed)
|
||||
|
||||
self.events.add_from_msg(CS.events)
|
||||
self.events.add_from_msg(self.sm['driverMonitoringState'].events)
|
||||
|
||||
@@ -733,6 +740,7 @@ class Controls:
|
||||
self.prof.checkpoint("Sent")
|
||||
|
||||
self.update_button_timers(CS.buttonEvents)
|
||||
self.CS_prev = CS
|
||||
|
||||
def controlsd_thread(self):
|
||||
while True:
|
||||
|
||||
@@ -1 +1 @@
|
||||
6b5f707e5c58b0162044b2d5a07a35ec00296504
|
||||
927918307b45657df0a4ac0255c3e8e3dc62d7cd
|
||||
Reference in New Issue
Block a user