mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-25 07:43:52 +08:00
abstract pedalPressed event (#1218)
* abstract pedalPressed event * Fix bug * update refs
This commit is contained in:
@@ -70,19 +70,13 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.buttonEvents = []
|
||||
|
||||
# events
|
||||
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low])
|
||||
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low], gas_resume_speed = 2.)
|
||||
|
||||
if ret.cruiseState.enabled and not self.cruise_enabled_prev:
|
||||
events.append(create_event('pcmEnable', [ET.ENABLE]))
|
||||
elif not ret.cruiseState.enabled:
|
||||
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
|
||||
|
||||
# disable on gas pedal and speed isn't zero. Gas pedal is used to resume ACC
|
||||
# from a 3+ second stop.
|
||||
if (ret.gasPressed and (not self.gas_pressed_prev) and ret.vEgo > 2.0) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or not ret.standstill)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
if ret.vEgo < self.CP.minSteerSpeed:
|
||||
events.append(create_event('belowSteerSpeed', [ET.WARNING]))
|
||||
|
||||
|
||||
@@ -67,11 +67,6 @@ class CarInterface(CarInterfaceBase):
|
||||
elif not ret.cruiseState.enabled:
|
||||
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
|
||||
|
||||
# disable on pedals rising edge or when brake is pressed and speed isn't zero
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
if self.CS.lkas_state not in [2, 3] and ret.vEgo > 13.* CV.MPH_TO_MS and ret.cruiseState.enabled:
|
||||
events.append(create_event('steerTempUnavailableMute', [ET.WARNING]))
|
||||
|
||||
|
||||
@@ -173,10 +173,6 @@ class CarInterface(CarInterfaceBase):
|
||||
events.append(create_event('speedTooLow', [ET.NO_ENTRY]))
|
||||
if self.CS.park_brake:
|
||||
events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
# disable on pedals rising edge or when brake is pressed and speed isn't zero
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed): # and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
if ret.cruiseState.standstill:
|
||||
events.append(create_event('resumeRequired', [ET.WARNING]))
|
||||
if self.CS.pcm_acc_status == AccState.FAULTED:
|
||||
|
||||
@@ -353,7 +353,7 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
|
||||
ret.longitudinalTuning.kiBP = [0., 35.]
|
||||
ret.longitudinalTuning.kiV = [0.18, 0.12]
|
||||
|
||||
|
||||
elif candidate == CAR.INSIGHT:
|
||||
stop_and_go = True
|
||||
ret.mass = 2987. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
@@ -465,11 +465,6 @@ class CarInterface(CarInterfaceBase):
|
||||
if self.CP.enableCruise and ret.vEgo < self.CP.minEnableSpeed:
|
||||
events.append(create_event('speedTooLow', [ET.NO_ENTRY]))
|
||||
|
||||
# disable on pedals rising edge or when brake is pressed and speed isn't zero
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
# it can happen that car cruise disables while comma system is enabled: need to
|
||||
# keep braking if needed or if the speed is very low
|
||||
if self.CP.enableCruise and not ret.cruiseState.enabled and (c.actuators.brake <= 0. or not self.CP.openpilotLongitudinalControl):
|
||||
|
||||
@@ -111,11 +111,6 @@ class CarInterface(CarInterfaceBase):
|
||||
elif not ret.cruiseState.enabled:
|
||||
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
|
||||
|
||||
# disable on pedals rising edge or when brake is pressed and speed isn't zero
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgoRaw > 0.1)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
# low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s)
|
||||
if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.:
|
||||
self.low_speed_alert = True
|
||||
|
||||
@@ -81,7 +81,7 @@ class CarInterfaceBase():
|
||||
def apply(self, c):
|
||||
raise NotImplementedError
|
||||
|
||||
def create_common_events(self, cs_out, extra_gears=[]):
|
||||
def create_common_events(self, cs_out, extra_gears=[], gas_resume_speed=-1):
|
||||
events = []
|
||||
|
||||
if cs_out.doorOpen:
|
||||
@@ -105,6 +105,13 @@ class CarInterfaceBase():
|
||||
elif getattr(self.CS, "steer_warning", False):
|
||||
events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING]))
|
||||
|
||||
# Disable on rising edge of gas or brake. Also disable on brake when speed > 0.
|
||||
# Optionally allow to press gas at zero speed to resume.
|
||||
# e.g. Chrysler does not spam the resume button yet, so resuming with gas is handy. FIXME!
|
||||
if (cs_out.gasPressed and (not self.gas_pressed_prev) and cs_out.vEgo > gas_resume_speed) or \
|
||||
(cs_out.brakePressed and (not self.brake_pressed_prev or not cs_out.standstill)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
return events
|
||||
|
||||
class RadarInterfaceBase():
|
||||
|
||||
@@ -75,14 +75,6 @@ class CarInterface(CarInterfaceBase):
|
||||
if not ret.cruiseState.enabled:
|
||||
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
|
||||
|
||||
# disable on pedals rising edge or when brake is pressed and speed isn't zero
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
if ret.gasPressed:
|
||||
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
|
||||
|
||||
ret.events = events
|
||||
|
||||
# update previous brake/gas pressed
|
||||
|
||||
@@ -70,11 +70,6 @@ class CarInterface(CarInterfaceBase):
|
||||
if not ret.cruiseState.enabled:
|
||||
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
|
||||
|
||||
# disable on gas pedal rising edge
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
ret.events = events
|
||||
|
||||
self.gas_pressed_prev = ret.gasPressed
|
||||
|
||||
@@ -316,11 +316,6 @@ class CarInterface(CarInterfaceBase):
|
||||
elif not ret.cruiseState.enabled:
|
||||
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
|
||||
|
||||
# disable on pedals rising edge or when brake is pressed and speed isn't zero
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
ret.events = events
|
||||
|
||||
self.gas_pressed_prev = ret.gasPressed
|
||||
|
||||
@@ -110,12 +110,6 @@ class CarInterface(CarInterfaceBase):
|
||||
if self.CS.steeringFault:
|
||||
events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING]))
|
||||
|
||||
# Per the Comma safety model, disable on pedals rising edge or when brake
|
||||
# is pressed and speed isn't zero.
|
||||
if (ret.gasPressed and not self.gas_pressed_prev) or \
|
||||
(ret.brakePressed and (not self.brake_pressed_prev or not ret.standstill)):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
# Engagement and longitudinal control using stock ACC. Make sure OP is
|
||||
# disengaged if stock ACC is disengaged.
|
||||
if not ret.cruiseState.enabled:
|
||||
|
||||
@@ -1 +1 @@
|
||||
f48e39778dc502d62fa2eac515f886f7d7520ffa
|
||||
7bc2ec3b0888827c0028bc7b35ede111ba2b0419
|
||||
Reference in New Issue
Block a user