abstract pedalPressed event (#1218)

* abstract pedalPressed event

* Fix bug

* update refs
pull/1219/head
rbiasini 5 years ago committed by GitHub
parent 6554e04c0c
commit fe911bcca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      selfdrive/car/chrysler/interface.py
  2. 5
      selfdrive/car/ford/interface.py
  3. 4
      selfdrive/car/gm/interface.py
  4. 7
      selfdrive/car/honda/interface.py
  5. 5
      selfdrive/car/hyundai/interface.py
  6. 9
      selfdrive/car/interfaces.py
  7. 8
      selfdrive/car/nissan/interface.py
  8. 5
      selfdrive/car/subaru/interface.py
  9. 5
      selfdrive/car/toyota/interface.py
  10. 6
      selfdrive/car/volkswagen/interface.py
  11. 2
      selfdrive/test/process_replay/ref_commit

@ -70,19 +70,13 @@ class CarInterface(CarInterfaceBase):
ret.buttonEvents = [] ret.buttonEvents = []
# events # 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: if ret.cruiseState.enabled and not self.cruise_enabled_prev:
events.append(create_event('pcmEnable', [ET.ENABLE])) events.append(create_event('pcmEnable', [ET.ENABLE]))
elif not ret.cruiseState.enabled: elif not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) 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: if ret.vEgo < self.CP.minSteerSpeed:
events.append(create_event('belowSteerSpeed', [ET.WARNING])) events.append(create_event('belowSteerSpeed', [ET.WARNING]))

@ -67,11 +67,6 @@ class CarInterface(CarInterfaceBase):
elif not ret.cruiseState.enabled: elif not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) 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: 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])) events.append(create_event('steerTempUnavailableMute', [ET.WARNING]))

@ -173,10 +173,6 @@ class CarInterface(CarInterfaceBase):
events.append(create_event('speedTooLow', [ET.NO_ENTRY])) events.append(create_event('speedTooLow', [ET.NO_ENTRY]))
if self.CS.park_brake: if self.CS.park_brake:
events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE])) 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: if ret.cruiseState.standstill:
events.append(create_event('resumeRequired', [ET.WARNING])) events.append(create_event('resumeRequired', [ET.WARNING]))
if self.CS.pcm_acc_status == AccState.FAULTED: 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.kpV = [1.2, 0.8, 0.5]
ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiBP = [0., 35.]
ret.longitudinalTuning.kiV = [0.18, 0.12] ret.longitudinalTuning.kiV = [0.18, 0.12]
elif candidate == CAR.INSIGHT: elif candidate == CAR.INSIGHT:
stop_and_go = True stop_and_go = True
ret.mass = 2987. * CV.LB_TO_KG + STD_CARGO_KG 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: if self.CP.enableCruise and ret.vEgo < self.CP.minEnableSpeed:
events.append(create_event('speedTooLow', [ET.NO_ENTRY])) 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 # 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 # 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): 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: elif not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) 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) # 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.: if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.:
self.low_speed_alert = True self.low_speed_alert = True

@ -81,7 +81,7 @@ class CarInterfaceBase():
def apply(self, c): def apply(self, c):
raise NotImplementedError 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 = [] events = []
if cs_out.doorOpen: if cs_out.doorOpen:
@ -105,6 +105,13 @@ class CarInterfaceBase():
elif getattr(self.CS, "steer_warning", False): elif getattr(self.CS, "steer_warning", False):
events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING])) 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 return events
class RadarInterfaceBase(): class RadarInterfaceBase():

@ -75,14 +75,6 @@ class CarInterface(CarInterfaceBase):
if not ret.cruiseState.enabled: if not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) 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 ret.events = events
# update previous brake/gas pressed # update previous brake/gas pressed

@ -70,11 +70,6 @@ class CarInterface(CarInterfaceBase):
if not ret.cruiseState.enabled: if not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) 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 ret.events = events
self.gas_pressed_prev = ret.gasPressed self.gas_pressed_prev = ret.gasPressed

@ -316,11 +316,6 @@ class CarInterface(CarInterfaceBase):
elif not ret.cruiseState.enabled: elif not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) 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 ret.events = events
self.gas_pressed_prev = ret.gasPressed self.gas_pressed_prev = ret.gasPressed

@ -110,12 +110,6 @@ class CarInterface(CarInterfaceBase):
if self.CS.steeringFault: if self.CS.steeringFault:
events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING])) 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 # Engagement and longitudinal control using stock ACC. Make sure OP is
# disengaged if stock ACC is disengaged. # disengaged if stock ACC is disengaged.
if not ret.cruiseState.enabled: if not ret.cruiseState.enabled:

@ -1 +1 @@
f48e39778dc502d62fa2eac515f886f7d7520ffa 7bc2ec3b0888827c0028bc7b35ede111ba2b0419
Loading…
Cancel
Save