mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 20:03:53 +08:00
Revert "card: create pedal pressed event" (#32414)
Revert "card: create pedal pressed event (#32393)"
This reverts commit d18da895d3.
This commit is contained in:
@@ -14,12 +14,9 @@ from openpilot.common.realtime import DT_CTRL
|
||||
from openpilot.selfdrive.boardd.boardd import can_list_to_can_capnp
|
||||
from openpilot.selfdrive.car.car_helpers import get_car, get_one_can
|
||||
from openpilot.selfdrive.car.interfaces import CarInterfaceBase
|
||||
from openpilot.selfdrive.controls.lib.events import Events
|
||||
|
||||
REPLAY = "REPLAY" in os.environ
|
||||
|
||||
EventName = car.CarEvent.EventName
|
||||
|
||||
|
||||
class CarD:
|
||||
CI: CarInterfaceBase
|
||||
@@ -50,9 +47,9 @@ class CarD:
|
||||
self.CI, self.CP = CI, CI.CP
|
||||
|
||||
# set alternative experiences from parameters
|
||||
self.disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator")
|
||||
disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator")
|
||||
self.CP.alternativeExperience = 0
|
||||
if not self.disengage_on_accelerator:
|
||||
if not disengage_on_accelerator:
|
||||
self.CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_ON_GAS
|
||||
|
||||
openpilot_enabled_toggle = self.params.get_bool("OpenpilotEnabledToggle")
|
||||
@@ -76,9 +73,6 @@ class CarD:
|
||||
self.params.put_nonblocking("CarParamsCache", cp_bytes)
|
||||
self.params.put_nonblocking("CarParamsPersistent", cp_bytes)
|
||||
|
||||
self.CS_prev = car.CarState.new_message()
|
||||
self.events = Events()
|
||||
|
||||
def initialize(self):
|
||||
"""Initialize CarInterface, once controls are ready"""
|
||||
self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan'])
|
||||
@@ -106,26 +100,10 @@ class CarD:
|
||||
if can_rcv_valid and REPLAY:
|
||||
self.can_log_mono_time = messaging.log_from_bytes(can_strs[0]).logMonoTime
|
||||
|
||||
self.update_events(CS)
|
||||
self.state_publish(CS)
|
||||
|
||||
CS = CS.as_reader()
|
||||
self.CS_prev = CS
|
||||
return CS
|
||||
|
||||
def update_events(self, CS: car.CarState) -> car.CarState:
|
||||
self.events.clear()
|
||||
|
||||
self.events.add_from_msg(CS.events)
|
||||
|
||||
# Disable on rising edge of accelerator or brake. Also disable on brake when speed > 0
|
||||
if (CS.gasPressed and not self.CS_prev.gasPressed and self.disengage_on_accelerator) or \
|
||||
(CS.brakePressed and (not self.CS_prev.brakePressed or not CS.standstill)) or \
|
||||
(CS.regenBraking and (not self.CS_prev.regenBraking or not CS.standstill)):
|
||||
self.events.add(EventName.pedalPressed)
|
||||
|
||||
CS.events = self.events.to_msg()
|
||||
|
||||
def state_publish(self, CS: car.CarState):
|
||||
"""carState and carParams publish loop"""
|
||||
|
||||
|
||||
@@ -242,10 +242,11 @@ class CarInterfaceBase(ABC):
|
||||
ret.cruiseState.speedCluster = ret.cruiseState.speed
|
||||
|
||||
# copy back for next iteration
|
||||
reader = ret.as_reader()
|
||||
if self.CS is not None:
|
||||
self.CS.out = ret.as_reader()
|
||||
self.CS.out = reader
|
||||
|
||||
return ret
|
||||
return reader
|
||||
|
||||
|
||||
def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True, allow_enable=True,
|
||||
|
||||
@@ -96,6 +96,7 @@ class Controls:
|
||||
self.joystick_mode = self.params.get_bool("JoystickDebugMode")
|
||||
|
||||
# read params
|
||||
self.disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator")
|
||||
self.is_metric = self.params.get_bool("IsMetric")
|
||||
self.is_ldw_enabled = self.params.get_bool("IsLdwEnabled")
|
||||
|
||||
@@ -110,6 +111,7 @@ class Controls:
|
||||
if not self.CP.openpilotLongitudinalControl:
|
||||
self.params.remove("ExperimentalMode")
|
||||
|
||||
self.CS_prev = car.CarState.new_message()
|
||||
self.AM = AlertManager()
|
||||
self.events = Events()
|
||||
|
||||
@@ -203,6 +205,12 @@ class Controls:
|
||||
if not self.CP.pcmCruise and not self.v_cruise_helper.v_cruise_initialized and resume_pressed:
|
||||
self.events.add(EventName.resumeBlocked)
|
||||
|
||||
# Disable on rising edge of accelerator or brake. Also disable on brake when speed > 0
|
||||
if (CS.gasPressed and not self.CS_prev.gasPressed and self.disengage_on_accelerator) or \
|
||||
(CS.brakePressed and (not self.CS_prev.brakePressed or not CS.standstill)) or \
|
||||
(CS.regenBraking and (not self.CS_prev.regenBraking or not CS.standstill)):
|
||||
self.events.add(EventName.pedalPressed)
|
||||
|
||||
if not self.CP.notCar:
|
||||
self.events.add_from_msg(self.sm['driverMonitoringState'].events)
|
||||
|
||||
@@ -807,6 +815,8 @@ class Controls:
|
||||
# Publish data
|
||||
self.publish_logs(CS, start_time, CC, lac_log)
|
||||
|
||||
self.CS_prev = CS
|
||||
|
||||
def read_personality_param(self):
|
||||
try:
|
||||
return int(self.params.get('LongitudinalPersonality'))
|
||||
|
||||
@@ -1 +1 @@
|
||||
e5a385503e4307ae77c73736a602380b08e61334
|
||||
ef0c8cb36b9cda6381412493555c21a87360e539
|
||||
Reference in New Issue
Block a user