Abstract gasPressed for all cars (#1151)

* min_steer_speed alert (with adjusted hysteresis) for all cars, abstracted gas pre_enable event

* move lines a bit

* more GM cleanup

* typo

* move espDisabled to carState packet

* brought back min steer speed alert only in hyundai. It's a bit tricky and behavior should be changed

* ops, wrong change

* bug

* update cereal

* update ref
old-commit-hash: 9685a5a743
commatwo_master
rbiasini 5 years ago committed by GitHub
parent 40127bf946
commit 8fc38619c0
  1. 2
      cereal
  2. 2
      selfdrive/car/chrysler/carstate.py
  3. 3
      selfdrive/car/ford/interface.py
  4. 9
      selfdrive/car/gm/carstate.py
  5. 12
      selfdrive/car/gm/interface.py
  6. 2
      selfdrive/car/honda/carstate.py
  7. 3
      selfdrive/car/honda/interface.py
  8. 2
      selfdrive/car/hyundai/carstate.py
  9. 19
      selfdrive/car/hyundai/interface.py
  10. 7
      selfdrive/car/interfaces.py
  11. 3
      selfdrive/car/subaru/interface.py
  12. 2
      selfdrive/car/toyota/carstate.py
  13. 3
      selfdrive/car/toyota/interface.py
  14. 2
      selfdrive/car/volkswagen/carstate.py
  15. 2
      selfdrive/car/volkswagen/interface.py
  16. 2
      selfdrive/test/process_replay/ref_commit

@ -1 +1 @@
Subproject commit bb13121282b8c0800e808b4b27d0e0ac4a770f93 Subproject commit b2e2e071510754a1b6767e35e8129b0e13e36187

@ -30,7 +30,7 @@ class CarState(CarStateBase):
ret.gas = cp.vl["ACCEL_GAS_134"]['ACCEL_134'] ret.gas = cp.vl["ACCEL_GAS_134"]['ACCEL_134']
ret.gasPressed = ret.gas > 1e-5 ret.gasPressed = ret.gas > 1e-5
self.esp_disabled = (cp.vl["TRACTION_BUTTON"]['TRACTION_OFF'] == 1) ret.espDisabled = (cp.vl["TRACTION_BUTTON"]['TRACTION_OFF'] == 1)
ret.wheelSpeeds.fl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FL'] ret.wheelSpeeds.fl = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_FL']
ret.wheelSpeeds.rr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RR'] ret.wheelSpeeds.rr = cp.vl['WHEEL_SPEEDS']['WHEEL_SPEED_RR']

@ -72,9 +72,6 @@ class CarInterface(CarInterfaceBase):
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)): (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gasPressed:
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
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]))

@ -9,7 +9,6 @@ from selfdrive.car.gm.values import DBC, CAR, AccState, CanBus, \
STEER_THRESHOLD, SUPERCRUISE_CARS STEER_THRESHOLD, SUPERCRUISE_CARS
class CarState(CarStateBase): class CarState(CarStateBase):
def __init__(self, CP): def __init__(self, CP):
super().__init__(CP) super().__init__(CP)
@ -57,15 +56,13 @@ class CarState(CarStateBase):
if self.car_fingerprint in SUPERCRUISE_CARS: if self.car_fingerprint in SUPERCRUISE_CARS:
self.park_brake = False self.park_brake = False
ret.cruiseState.available = False ret.cruiseState.available = False
self.acc_active = pt_cp.vl["ASCMActiveCruiseControlStatus"]['ACCCmdActive'] ret.espDisabled = False
self.esp_disabled = False
regen_pressed = False regen_pressed = False
self.pcm_acc_status = int(self.acc_active) self.pcm_acc_status = int(pt_cp.vl["ASCMActiveCruiseControlStatus"]['ACCCmdActive'])
else: else:
self.park_brake = pt_cp.vl["EPBStatus"]['EPBClosed'] self.park_brake = pt_cp.vl["EPBStatus"]['EPBClosed']
ret.cruiseState.available = bool(pt_cp.vl["ECMEngineStatus"]['CruiseMainOn']) ret.cruiseState.available = bool(pt_cp.vl["ECMEngineStatus"]['CruiseMainOn'])
self.acc_active = False ret.espDisabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1
self.esp_disabled = pt_cp.vl["ESPStatus"]['TractionControlOn'] != 1
self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState'] self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]['CruiseState']
if self.car_fingerprint == CAR.VOLT: if self.car_fingerprint == CAR.VOLT:
regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle']) regen_pressed = bool(pt_cp.vl["EBCMRegenPaddle"]['RegenPaddle'])

@ -10,10 +10,6 @@ from selfdrive.car.interfaces import CarInterfaceBase
ButtonType = car.CarState.ButtonEvent.Type ButtonType = car.CarState.ButtonEvent.Type
class CarInterface(CarInterfaceBase): class CarInterface(CarInterfaceBase):
def __init__(self, CP, CarController, CarState):
super().__init__(CP, CarController, CarState)
self.acc_active_prev = 0
@staticmethod @staticmethod
def compute_gb(accel, speed): def compute_gb(accel, speed):
@ -166,9 +162,9 @@ class CarInterface(CarInterfaceBase):
events = self.create_common_events(ret) events = self.create_common_events(ret)
if self.CS.car_fingerprint in SUPERCRUISE_CARS: if self.CS.car_fingerprint in SUPERCRUISE_CARS:
if self.CS.acc_active and not self.acc_active_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]))
if not self.CS.acc_active: if not ret.cruiseState.enabled:
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
else: else:
@ -181,8 +177,6 @@ class CarInterface(CarInterfaceBase):
if (ret.gasPressed and not self.gas_pressed_prev) or \ if (ret.gasPressed and not self.gas_pressed_prev) or \
(ret.brakePressed): # and (not self.brake_pressed_prev or ret.vEgo > 0.001)): (ret.brakePressed): # and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gasPressed:
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
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:
@ -200,7 +194,7 @@ class CarInterface(CarInterfaceBase):
ret.events = events ret.events = events
# update previous brake/gas pressed # update previous brake/gas pressed
self.acc_active_prev = self.CS.acc_active self.cruise_enabled_prev = ret.cruiseState.enabled
self.gas_pressed_prev = ret.gasPressed self.gas_pressed_prev = ret.gasPressed
self.brake_pressed_prev = ret.brakePressed self.brake_pressed_prev = ret.brakePressed

@ -199,7 +199,7 @@ class CarState(CarStateBase):
self.brake_error = 0 self.brake_error = 0
else: else:
self.brake_error = cp.vl["STANDSTILL"]['BRAKE_ERROR_1'] or cp.vl["STANDSTILL"]['BRAKE_ERROR_2'] self.brake_error = cp.vl["STANDSTILL"]['BRAKE_ERROR_1'] or cp.vl["STANDSTILL"]['BRAKE_ERROR_2']
self.esp_disabled = cp.vl["VSA_STATUS"]['ESP_DISABLED'] ret.espDisabled = cp.vl["VSA_STATUS"]['ESP_DISABLED'] != 0
speed_factor = SPEED_FACTOR[self.CP.carFingerprint] speed_factor = SPEED_FACTOR[self.CP.carFingerprint]
ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FL'] * CV.KPH_TO_MS * speed_factor ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]['WHEEL_SPEED_FL'] * CV.KPH_TO_MS * speed_factor

@ -455,9 +455,6 @@ class CarInterface(CarInterfaceBase):
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)): (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gasPressed:
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
# 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):

@ -52,6 +52,7 @@ class CarState(CarStateBase):
pedal_gas = cp.vl["EMS12"]['TPS'] pedal_gas = cp.vl["EMS12"]['TPS']
ret.gasPressed = pedal_gas > 1e-3 ret.gasPressed = pedal_gas > 1e-3
ret.gas = cp.vl["EMS12"]['TPS'] ret.gas = cp.vl["EMS12"]['TPS']
ret.espDisabled = cp.vl["TCS15"]['ESC_Off_Step'] != 0
# Gear Selecton - This is not compatible with all Kia/Hyundai's, But is the best way for those it is compatible with # Gear Selecton - This is not compatible with all Kia/Hyundai's, But is the best way for those it is compatible with
gear = cp.vl["LVR12"]["CF_Lvr_Gear"] gear = cp.vl["LVR12"]["CF_Lvr_Gear"]
@ -100,7 +101,6 @@ class CarState(CarStateBase):
# save the entire LKAS11 and CLU11 # save the entire LKAS11 and CLU11
self.lkas11 = cp_cam.vl["LKAS11"] self.lkas11 = cp_cam.vl["LKAS11"]
self.clu11 = cp.vl["CLU11"] self.clu11 = cp.vl["CLU11"]
self.esp_disabled = cp.vl["TCS15"]['ESC_Off_Step']
self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw'] self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw']
self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE
self.steer_warning = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail'] self.steer_warning = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail']

@ -7,10 +7,6 @@ from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness,
from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.interfaces import CarInterfaceBase
class CarInterface(CarInterfaceBase): class CarInterface(CarInterfaceBase):
def __init__(self, CP, CarController, CarState):
super().__init__(CP, CarController, CarState)
self.low_speed_alert = False
@staticmethod @staticmethod
def compute_gb(accel, speed): def compute_gb(accel, speed):
@ -103,18 +99,11 @@ class CarInterface(CarInterfaceBase):
self.cp_cam.update_strings(can_strings) self.cp_cam.update_strings(can_strings)
ret = self.CS.update(self.cp, self.cp_cam) ret = self.CS.update(self.cp, self.cp_cam)
ret.canValid = self.cp.can_valid and self.cp_cam.can_valid ret.canValid = self.cp.can_valid and self.cp_cam.can_valid
# TODO: button presses # TODO: button presses
ret.buttonEvents = [] ret.buttonEvents = []
# 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
if ret.vEgo > (self.CP.minSteerSpeed + 4.):
self.low_speed_alert = False
events = self.create_common_events(ret) events = self.create_common_events(ret)
if ret.cruiseState.enabled and not self.cruise_enabled_prev: if ret.cruiseState.enabled and not self.cruise_enabled_prev:
@ -127,9 +116,11 @@ class CarInterface(CarInterfaceBase):
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgoRaw > 0.1)): (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgoRaw > 0.1)):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gasPressed: # low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s)
events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.:
self.low_speed_alert = True
if ret.vEgo > (self.CP.minSteerSpeed + 4.):
self.low_speed_alert = False
if self.low_speed_alert: if self.low_speed_alert:
events.append(create_event('belowSteerSpeed', [ET.WARNING])) events.append(create_event('belowSteerSpeed', [ET.WARNING]))

@ -20,6 +20,7 @@ class CarInterfaceBase():
self.gas_pressed_prev = False self.gas_pressed_prev = False
self.brake_pressed_prev = False self.brake_pressed_prev = False
self.cruise_enabled_prev = False self.cruise_enabled_prev = False
self.low_speed_alert = False
self.CS = CarState(CP) self.CS = CarState(CP)
self.cp = self.CS.get_can_parser(CP) self.cp = self.CS.get_can_parser(CP)
@ -93,14 +94,16 @@ class CarInterfaceBase():
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if not cs_out.cruiseState.available: if not cs_out.cruiseState.available:
events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
if cs_out.espDisabled:
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if cs_out.gasPressed:
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
# TODO: move this stuff to the capnp strut # TODO: move this stuff to the capnp strut
if getattr(self.CS, "steer_error", False): if getattr(self.CS, "steer_error", False):
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
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]))
if getattr(self.CS, "esp_disabled", False):
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
return events return events

@ -75,9 +75,6 @@ class CarInterface(CarInterfaceBase):
if (ret.gasPressed and not self.gas_pressed_prev): if (ret.gasPressed and not self.gas_pressed_prev):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) 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
self.gas_pressed_prev = ret.gasPressed self.gas_pressed_prev = ret.gasPressed

@ -86,7 +86,7 @@ class CarState(CarStateBase):
ret.genericToggle = bool(cp.vl["LIGHT_STALK"]['AUTO_HIGH_BEAM']) ret.genericToggle = bool(cp.vl["LIGHT_STALK"]['AUTO_HIGH_BEAM'])
ret.stockAeb = bool(cp_cam.vl["PRE_COLLISION"]["PRECOLLISION_ACTIVE"] and cp_cam.vl["PRE_COLLISION"]["FORCE"] < -1e-5) ret.stockAeb = bool(cp_cam.vl["PRE_COLLISION"]["PRECOLLISION_ACTIVE"] and cp_cam.vl["PRE_COLLISION"]["FORCE"] < -1e-5)
self.esp_disabled = cp.vl["ESP_CONTROL"]['TC_DISABLED'] ret.espDisabled = cp.vl["ESP_CONTROL"]['TC_DISABLED'] != 0
# 2 is standby, 10 is active. TODO: check that everything else is really a faulty state # 2 is standby, 10 is active. TODO: check that everything else is really a faulty state
self.steer_state = cp.vl["EPS_STATUS"]['LKA_STATE'] self.steer_state = cp.vl["EPS_STATUS"]['LKA_STATE']
self.steer_warning = cp.vl["EPS_STATUS"]['LKA_STATE'] not in [1, 5] self.steer_warning = cp.vl["EPS_STATUS"]['LKA_STATE'] not in [1, 5]

@ -323,9 +323,6 @@ class CarInterface(CarInterfaceBase):
(ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)): (ret.brakePressed and (not self.brake_pressed_prev or ret.vEgo > 0.001)):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) 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
self.gas_pressed_prev = ret.gasPressed self.gas_pressed_prev = ret.gasPressed

@ -116,7 +116,7 @@ class CarState(CarStateBase):
# Additional safety checks performed in CarInterface. # Additional safety checks performed in CarInterface.
self.parkingBrakeSet = bool(pt_cp.vl["Kombi_01"]['KBI_Handbremse']) # FIXME: need to include an EPB check as well self.parkingBrakeSet = bool(pt_cp.vl["Kombi_01"]['KBI_Handbremse']) # FIXME: need to include an EPB check as well
self.esp_disabled = pt_cp.vl["ESP_21"]['ESP_Tastung_passiv'] ret.espDisabled = pt_cp.vl["ESP_21"]['ESP_Tastung_passiv'] != 0
return ret return ret

@ -119,8 +119,6 @@ class CarInterface(CarInterfaceBase):
if (ret.gasPressed and not self.gas_pressed_prev) or \ if (ret.gasPressed and not self.gas_pressed_prev) or \
(ret.brakePressed and (not self.brake_pressed_prev or not ret.standstill)): (ret.brakePressed and (not self.brake_pressed_prev or not ret.standstill)):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gasPressed:
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
# 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.

@ -1 +1 @@
0491cad238025a44b7fc636cf03efc27d80dcdae bc912a9ead7664ae4e393a7dc7cd38ba733dd694
Loading…
Cancel
Save