Abstract common events + event cleanup (#1129)

* too many if

* unused

* whitespace

* key

* sefldrive/car/*

* no more gctx

* lower

* start abstracting common events

* all cars

* start small

* all cars

* reverse gear

* wrongCarMode

* wrongGear

* espDisabled

* steerUnvailable

* make linter happy

* c isn't used

* fix esp_disabled in VW

* update ref

* more red

* more cleanup

* fix subaru

* update ref

old-commit-hash: e8cb6ea06a
commatwo_master
Adeeb 5 years ago committed by GitHub
parent a8ea2fff77
commit 65a2c62114
  1. 2
      selfdrive/athena/athenad.py
  2. 2
      selfdrive/boardd/tests/boardd_old.py
  3. 27
      selfdrive/car/chrysler/interface.py
  4. 5
      selfdrive/car/ford/interface.py
  5. 2
      selfdrive/car/gm/carstate.py
  6. 17
      selfdrive/car/gm/interface.py
  7. 19
      selfdrive/car/honda/interface.py
  8. 2
      selfdrive/car/hyundai/carstate.py
  9. 22
      selfdrive/car/hyundai/interface.py
  10. 25
      selfdrive/car/interfaces.py
  11. 19
      selfdrive/car/subaru/interface.py
  12. 2
      selfdrive/car/toyota/carstate.py
  13. 19
      selfdrive/car/toyota/interface.py
  14. 2
      selfdrive/car/volkswagen/carstate.py
  15. 13
      selfdrive/car/volkswagen/interface.py
  16. 2
      selfdrive/controls/gps_plannerd.py
  17. 28
      selfdrive/controls/lib/alerts.py
  18. 2
      selfdrive/locationd/test/ubloxd.py
  19. 2
      selfdrive/locationd/test/ubloxd_easy.py
  20. 2
      selfdrive/loggerd/deleter.py
  21. 2
      selfdrive/loggerd/ethernetsniffer.py
  22. 2
      selfdrive/loggerd/uploader.py
  23. 2
      selfdrive/logmessaged.py
  24. 55
      selfdrive/manager.py
  25. 2
      selfdrive/mapd/mapd.py
  26. 2
      selfdrive/pandad.py
  27. 1
      selfdrive/test/longitudinal_maneuvers/test_longitudinal.py
  28. 2
      selfdrive/test/process_replay/ref_commit
  29. 2
      selfdrive/thermald.py
  30. 2
      selfdrive/tombstoned.py
  31. 4
      selfdrive/ui/SConscript
  32. 1
      selfdrive/ui/ui.cc
  33. 2
      selfdrive/updated.py

@ -294,7 +294,7 @@ def ws_send(ws, end_event):
def backoff(retries): def backoff(retries):
return random.randrange(0, min(128, int(2 ** retries))) return random.randrange(0, min(128, int(2 ** retries)))
def main(gctx=None): def main():
params = Params() params = Params()
dongle_id = params.get("DongleId").decode('utf-8') dongle_id = params.get("DongleId").decode('utf-8')
ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id

@ -232,7 +232,7 @@ def boardd_proxy_loop(rate=100, address="192.168.2.251"):
rk.keep_time() rk.keep_time()
def main(gctx=None): def main():
if os.getenv("MOCK") is not None: if os.getenv("MOCK") is not None:
boardd_mock_loop() boardd_mock_loop()
elif os.getenv("PROXY") is not None: elif os.getenv("PROXY") is not None:

@ -6,14 +6,7 @@ from selfdrive.car.chrysler.values import Ecu, ECU_FINGERPRINT, CAR, FINGERPRINT
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint
from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.interfaces import CarInterfaceBase
GearShifter = car.CarState.GearShifter
ButtonType = car.CarState.ButtonEvent.Type
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):
@ -76,24 +69,8 @@ class CarInterface(CarInterfaceBase):
ret.buttonEvents = [] ret.buttonEvents = []
self.low_speed_alert = (ret.vEgo < self.CP.minSteerSpeed)
# events # events
events = [] events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low])
if not (ret.gearShifter in (GearShifter.drive, GearShifter.low)):
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if self.CS.esp_disabled:
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if not ret.cruiseState.available:
events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gearShifter == GearShifter.reverse:
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if self.CS.steer_error:
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
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]))
@ -105,7 +82,7 @@ class CarInterface(CarInterfaceBase):
if (ret.gasPressed and (not self.gas_pressed_prev) and ret.vEgo > 2.0): if (ret.gasPressed and (not self.gas_pressed_prev) and ret.vEgo > 2.0):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
if self.low_speed_alert: if ret.vEgo < self.CP.minSteerSpeed:
events.append(create_event('belowSteerSpeed', [ET.WARNING])) events.append(create_event('belowSteerSpeed', [ET.WARNING]))
ret.events = events ret.events = events

@ -59,10 +59,7 @@ class CarInterface(CarInterfaceBase):
ret.canValid = self.cp.can_valid ret.canValid = self.cp.can_valid
# events # events
events = [] events = self.create_common_events(ret)
if self.CS.steer_error:
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
# enable request in prius is simple, as we activate when Toyota is active (rising edge) # enable request in prius is simple, as we activate when Toyota is active (rising edge)
if ret.cruiseState.enabled and not self.cruise_enabled_prev: if ret.cruiseState.enabled and not self.cruise_enabled_prev:

@ -79,7 +79,7 @@ class CarState(CarStateBase):
# 0 - inactive, 1 - active, 2 - temporary limited, 3 - failed # 0 - inactive, 1 - active, 2 - temporary limited, 3 - failed
self.lkas_status = pt_cp.vl["PSCMStatus"]['LKATorqueDeliveredStatus'] self.lkas_status = pt_cp.vl["PSCMStatus"]['LKATorqueDeliveredStatus']
self.steer_not_allowed = not is_eps_status_ok(self.lkas_status, self.car_fingerprint) self.steer_warning = not is_eps_status_ok(self.lkas_status, self.car_fingerprint)
return ret return ret

@ -163,13 +163,7 @@ class CarInterface(CarInterfaceBase):
ret.buttonEvents = buttonEvents ret.buttonEvents = buttonEvents
events = [] events = self.create_common_events(ret)
if self.CS.steer_not_allowed:
events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING]))
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
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 self.CS.acc_active and not self.acc_active_prev:
@ -178,14 +172,7 @@ class CarInterface(CarInterfaceBase):
events.append(create_event('pcmDisable', [ET.USER_DISABLE])) events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
else: else:
if ret.gearShifter != car.CarState.GearShifter.drive: # TODO: why is this only not supercruise? ignore supercruise?
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if self.CS.esp_disabled:
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if not ret.cruiseState.available:
events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gearShifter == car.CarState.GearShifter.reverse:
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if ret.vEgo < self.CP.minEnableSpeed: if ret.vEgo < self.CP.minEnableSpeed:
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:

@ -14,7 +14,6 @@ from selfdrive.car.interfaces import CarInterfaceBase
A_ACC_MAX = max(_A_CRUISE_MAX_V_FOLLOWING) A_ACC_MAX = max(_A_CRUISE_MAX_V_FOLLOWING)
ButtonType = car.CarState.ButtonEvent.Type ButtonType = car.CarState.ButtonEvent.Type
GearShifter = car.CarState.GearShifter
def compute_gb_honda(accel, speed): def compute_gb_honda(accel, speed):
creep_brake = 0.0 creep_brake = 0.0
@ -440,25 +439,9 @@ class CarInterface(CarInterfaceBase):
ret.buttonEvents = buttonEvents ret.buttonEvents = buttonEvents
# events # events
events = [] events = self.create_common_events(ret)
if self.CS.steer_error:
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
elif self.CS.steer_warning:
events.append(create_event('steerTempUnavailable', [ET.WARNING]))
if self.CS.brake_error: if self.CS.brake_error:
events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT])) events.append(create_event('brakeUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
if not ret.gearShifter == GearShifter.drive:
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if self.CS.esp_disabled:
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if not ret.cruiseState.available:
events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gearShifter == GearShifter.reverse:
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if self.CS.brake_hold and self.CS.CP.carFingerprint not in HONDA_BOSCH: if self.CS.brake_hold and self.CS.CP.carFingerprint not in HONDA_BOSCH:
events.append(create_event('brakeHold', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('brakeHold', [ET.NO_ENTRY, ET.USER_DISABLE]))
if self.CS.park_brake: if self.CS.park_brake:

@ -103,7 +103,7 @@ class CarState(CarStateBase):
self.esp_disabled = cp.vl["TCS15"]['ESC_Off_Step'] 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_error = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail'] self.steer_warning = cp.vl["MDPS12"]['CF_Mdps_ToiUnavail']
self.brake_error = 0 self.brake_error = 0
return ret return ret

@ -6,16 +6,10 @@ from selfdrive.car.hyundai.values import Ecu, ECU_FINGERPRINT, CAR, get_hud_aler
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint
from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.interfaces import CarInterfaceBase
GearShifter = car.CarState.GearShifter
ButtonType = car.CarState.ButtonEvent.Type
class CarInterface(CarInterfaceBase): class CarInterface(CarInterfaceBase):
def __init__(self, CP, CarController, CarState): def __init__(self, CP, CarController, CarState):
super().__init__(CP, CarController, CarState) super().__init__(CP, CarController, CarState)
self.idx = 0
self.lanes = 0
self.lkas_request = 0
self.low_speed_alert = False self.low_speed_alert = False
@staticmethod @staticmethod
@ -121,21 +115,7 @@ class CarInterface(CarInterfaceBase):
if ret.vEgo > (self.CP.minSteerSpeed + 4.): if ret.vEgo > (self.CP.minSteerSpeed + 4.):
self.low_speed_alert = False self.low_speed_alert = False
events = [] events = self.create_common_events(ret)
if not ret.gearShifter == GearShifter.drive:
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if self.CS.esp_disabled:
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if not ret.cruiseState.available:
events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gearShifter == GearShifter.reverse:
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if self.CS.steer_error:
events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING]))
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]))

@ -4,6 +4,7 @@ from cereal import car
from common.kalman.simple_kalman import KF1D from common.kalman.simple_kalman import KF1D
from common.realtime import DT_CTRL from common.realtime import DT_CTRL
from selfdrive.car import gen_empty_fingerprint from selfdrive.car import gen_empty_fingerprint
from selfdrive.controls.lib.drive_helpers import EventTypes as ET, create_event
from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.controls.lib.vehicle_model import VehicleModel
GearShifter = car.CarState.GearShifter GearShifter = car.CarState.GearShifter
@ -79,6 +80,30 @@ class CarInterfaceBase():
def apply(self, c): def apply(self, c):
raise NotImplementedError raise NotImplementedError
def create_common_events(self, cs_out, extra_gears=[]):
events = []
if cs_out.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if cs_out.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if cs_out.gearShifter != GearShifter.drive and cs_out.gearShifter not in extra_gears:
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if cs_out.gearShifter == GearShifter.reverse:
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if not cs_out.cruiseState.available:
events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
# TODO: move this stuff to the capnp strut
if getattr(self.CS, "steer_error", False):
events.append(create_event('steerUnavailable', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE, ET.PERMANENT]))
elif getattr(self.CS, "steer_warning", False):
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
class RadarInterfaceBase(): class RadarInterfaceBase():
def __init__(self, CP): def __init__(self, CP):
self.pts = {} self.pts = {}

@ -6,12 +6,7 @@ from selfdrive.car.subaru.values import CAR
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint
from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.interfaces import CarInterfaceBase
ButtonType = car.CarState.ButtonEvent.Type
class CarInterface(CarInterfaceBase): class CarInterface(CarInterfaceBase):
def __init__(self, CP, CarController, CarState):
super().__init__(CP, CarController, CarState)
self.enabled_prev = 0
@staticmethod @staticmethod
def compute_gb(accel, speed): def compute_gb(accel, speed):
@ -65,17 +60,13 @@ class CarInterface(CarInterfaceBase):
buttonEvents = [] buttonEvents = []
be = car.CarState.ButtonEvent.new_message() be = car.CarState.ButtonEvent.new_message()
be.type = ButtonType.accelCruise be.type = car.CarState.ButtonEvent.Type.accelCruise
buttonEvents.append(be) buttonEvents.append(be)
events = [] # TODO: add gearShifter to carState
if ret.seatbeltUnlatched: events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.unknown])
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.cruiseState.enabled and not self.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]))
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]))
@ -90,7 +81,7 @@ class CarInterface(CarInterfaceBase):
ret.events = events ret.events = events
self.gas_pressed_prev = ret.gasPressed self.gas_pressed_prev = ret.gasPressed
self.enabled_prev = ret.cruiseState.enabled self.cruise_enabled_prev = ret.cruiseState.enabled
self.CS.out = ret.as_reader() self.CS.out = ret.as_reader()
return self.CS.out return self.CS.out

@ -89,7 +89,7 @@ class CarState(CarStateBase):
self.esp_disabled = cp.vl["ESP_CONTROL"]['TC_DISABLED'] self.esp_disabled = cp.vl["ESP_CONTROL"]['TC_DISABLED']
# 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_error = cp.vl["EPS_STATUS"]['LKA_STATE'] not in [1, 5] self.steer_warning = cp.vl["EPS_STATUS"]['LKA_STATE'] not in [1, 5]
self.ipas_active = cp.vl['EPS_STATUS']['IPAS_STATE'] == 3 self.ipas_active = cp.vl['EPS_STATUS']['IPAS_STATE'] == 3
return ret return ret

@ -7,9 +7,6 @@ from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness,
from selfdrive.swaglog import cloudlog from selfdrive.swaglog import cloudlog
from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.interfaces import CarInterfaceBase
ButtonType = car.CarState.ButtonEvent.Type
GearShifter = car.CarState.GearShifter
class CarInterface(CarInterfaceBase): class CarInterface(CarInterfaceBase):
@staticmethod @staticmethod
@ -300,24 +297,10 @@ class CarInterface(CarInterfaceBase):
ret.buttonEvents = [] ret.buttonEvents = []
# events # events
events = [] events = self.create_common_events(ret)
if self.cp_cam.can_invalid_cnt >= 200 and self.CP.enableCamera: if self.cp_cam.can_invalid_cnt >= 200 and self.CP.enableCamera:
events.append(create_event('invalidGiraffeToyota', [ET.PERMANENT])) events.append(create_event('invalidGiraffeToyota', [ET.PERMANENT]))
if not ret.gearShifter == GearShifter.drive and self.CP.openpilotLongitudinalControl:
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if self.CS.esp_disabled and self.CP.openpilotLongitudinalControl:
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if not ret.cruiseState.available and self.CP.openpilotLongitudinalControl:
events.append(create_event('wrongCarMode', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gearShifter == GearShifter.reverse and self.CP.openpilotLongitudinalControl:
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if self.CS.steer_error:
events.append(create_event('steerTempUnavailable', [ET.NO_ENTRY, ET.WARNING]))
if self.CS.low_speed_lockout and self.CP.openpilotLongitudinalControl: if self.CS.low_speed_lockout and self.CP.openpilotLongitudinalControl:
events.append(create_event('lowSpeedLockout', [ET.NO_ENTRY, ET.PERMANENT])) events.append(create_event('lowSpeedLockout', [ET.NO_ENTRY, ET.PERMANENT]))
if ret.vEgo < self.CP.minEnableSpeed and self.CP.openpilotLongitudinalControl: if ret.vEgo < self.CP.minEnableSpeed and self.CP.openpilotLongitudinalControl:

@ -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.stabilityControlDisabled = pt_cp.vl["ESP_21"]['ESP_Tastung_passiv'] self.esp_disabled = pt_cp.vl["ESP_21"]['ESP_Tastung_passiv']
return ret return ret

@ -75,7 +75,6 @@ class CarInterface(CarInterfaceBase):
# returns a car.CarState # returns a car.CarState
def update(self, c, can_strings): def update(self, c, can_strings):
canMonoTimes = [] canMonoTimes = []
events = []
buttonEvents = [] buttonEvents = []
params = Params() params = Params()
@ -103,17 +102,9 @@ class CarInterface(CarInterfaceBase):
be.pressed = self.CS.buttonStates[button] be.pressed = self.CS.buttonStates[button]
buttonEvents.append(be) buttonEvents.append(be)
events = self.create_common_events(ret, extra_gears=[GEAR.eco, GEAR.sport])
# Vehicle operation safety checks and events # Vehicle operation safety checks and events
if ret.doorOpen:
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.seatbeltUnlatched:
events.append(create_event('seatbeltNotLatched', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if ret.gearShifter == GEAR.reverse:
events.append(create_event('reverseGear', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
if not ret.gearShifter in [GEAR.drive, GEAR.eco, GEAR.sport]:
events.append(create_event('wrongGear', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if self.CS.stabilityControlDisabled:
events.append(create_event('espDisabled', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
if self.CS.parkingBrakeSet: if self.CS.parkingBrakeSet:
events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE])) events.append(create_event('parkBrake', [ET.NO_ENTRY, ET.USER_DISABLE]))

@ -362,7 +362,7 @@ def gps_planner_plan():
gps_planner_plan.send(m.to_bytes()) gps_planner_plan.send(m.to_bytes())
def main(gctx=None): def main():
cloudlog.info("Starting gps_plannerd main thread") cloudlog.info("Starting gps_plannerd main thread")
point_thread = Thread(target=gps_planner_point_selection) point_thread = Thread(target=gps_planner_point_selection)

@ -3,7 +3,7 @@ from cereal import car, log
# Priority # Priority
class Priority: class Priority:
LOWEST = 0 LOWEST = 0
LOW_LOWEST = 1 LOWER = 1
LOW = 2 LOW = 2
MID = 3 MID = 3
HIGH = 4 HIGH = 4
@ -169,28 +169,28 @@ ALERTS = [
"Be ready to take over at any time", "Be ready to take over at any time",
"Always keep hands on wheel and eyes on road", "Always keep hands on wheel and eyes on road",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.),
Alert( Alert(
"startupMaster", "startupMaster",
"WARNING: This branch is not tested", "WARNING: This branch is not tested",
"Always keep hands on wheel and eyes on road", "Always keep hands on wheel and eyes on road",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.),
Alert( Alert(
"startupNoControl", "startupNoControl",
"Dashcam mode", "Dashcam mode",
"Always keep hands on wheel and eyes on road", "Always keep hands on wheel and eyes on road",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.),
Alert( Alert(
"startupNoCar", "startupNoCar",
"Dashcam mode with unsupported car", "Dashcam mode with unsupported car",
"Always keep hands on wheel and eyes on road", "Always keep hands on wheel and eyes on road",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., 15.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 15.),
Alert( Alert(
"ethicalDilemma", "ethicalDilemma",
@ -693,21 +693,21 @@ ALERTS = [
"LKAS Fault: Restart the car to engage", "LKAS Fault: Restart the car to engage",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"brakeUnavailablePermanent", "brakeUnavailablePermanent",
"Cruise Fault: Restart the car to engage", "Cruise Fault: Restart the car to engage",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"lowSpeedLockoutPermanent", "lowSpeedLockoutPermanent",
"Cruise Fault: Restart the car to engage", "Cruise Fault: Restart the car to engage",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"calibrationIncompletePermanent", "calibrationIncompletePermanent",
@ -721,14 +721,14 @@ ALERTS = [
"Unsupported Giraffe Configuration", "Unsupported Giraffe Configuration",
"Visit comma.ai/tg", "Visit comma.ai/tg",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"internetConnectivityNeededPermanent", "internetConnectivityNeededPermanent",
"Please connect to Internet", "Please connect to Internet",
"An Update Check Is Required to Engage", "An Update Check Is Required to Engage",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"communityFeatureDisallowedPermanent", "communityFeatureDisallowedPermanent",
@ -742,28 +742,28 @@ ALERTS = [
"No Data from Device Sensors", "No Data from Device Sensors",
"Reboot your Device", "Reboot your Device",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"soundsUnavailablePermanent", "soundsUnavailablePermanent",
"Speaker not found", "Speaker not found",
"Reboot your Device", "Reboot your Device",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"lowMemoryPermanent", "lowMemoryPermanent",
"RAM Critically Low", "RAM Critically Low",
"Reboot your Device", "Reboot your Device",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"carUnrecognizedPermanent", "carUnrecognizedPermanent",
"Dashcam Mode", "Dashcam Mode",
"Car Unrecognized", "Car Unrecognized",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW_LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Alert( Alert(
"vehicleModelInvalid", "vehicleModelInvalid",

@ -276,7 +276,7 @@ def handle_msg(dev, msg, nav_frame_buffer):
#if dev is not None and dev.dev is not None: #if dev is not None and dev.dev is not None:
# dev.close() # dev.close()
def main(gctx=None): def main():
global gpsLocationExternal, ubloxGnss global gpsLocationExternal, ubloxGnss
nav_frame_buffer = {} nav_frame_buffer = {}
nav_frame_buffer[0] = {} nav_frame_buffer[0] = {}

@ -10,7 +10,7 @@ import cereal.messaging as messaging
unlogger = os.getenv("UNLOGGER") is not None # debug prints unlogger = os.getenv("UNLOGGER") is not None # debug prints
def main(gctx=None): def main():
poller = zmq.Poller() poller = zmq.Poller()
gpsLocationExternal = messaging.pub_sock('gpsLocationExternal') gpsLocationExternal = messaging.pub_sock('gpsLocationExternal')

@ -35,7 +35,7 @@ def deleter_thread(exit_event):
exit_event.wait(30) exit_event.wait(30)
def main(gctx=None): def main():
deleter_thread(threading.Event()) deleter_thread(threading.Event())

@ -4,7 +4,7 @@ import cereal.messaging as messaging
from cereal.services import service_list from cereal.services import service_list
import pcap import pcap
def main(gctx=None): def main():
ethernetData = messaging.pub_sock('ethernetData') ethernetData = messaging.pub_sock('ethernetData')
for ts, pkt in pcap.pcap('eth0'): for ts, pkt in pcap.pcap('eth0'):

@ -266,7 +266,7 @@ def uploader_fn(exit_event):
backoff = min(backoff*2, 120) backoff = min(backoff*2, 120)
cloudlog.info("upload done, success=%r", success) cloudlog.info("upload done, success=%r", success)
def main(gctx=None): def main():
uploader_fn(threading.Event()) uploader_fn(threading.Event())
if __name__ == "__main__": if __name__ == "__main__":

@ -3,7 +3,7 @@ import zmq
from logentries import LogentriesHandler from logentries import LogentriesHandler
import cereal.messaging as messaging import cereal.messaging as messaging
def main(gctx=None): def main():
# setup logentries. we forward log messages to it # setup logentries. we forward log messages to it
le_token = "e8549616-0798-4d7e-a2ca-2513ae81fa17" le_token = "e8549616-0798-4d7e-a2ca-2513ae81fa17"
le_handler = LogentriesHandler(le_token, use_tls=False, verbose=False) le_handler = LogentriesHandler(le_token, use_tls=False, verbose=False)

@ -475,40 +475,29 @@ def main():
params = Params() params = Params()
params.manager_start() params.manager_start()
default_params = [
("CommunityFeaturesToggle", "0"),
("CompletedTrainingVersion", "0"),
("IsMetric", "0"),
("RecordFront", "0"),
("HasAcceptedTerms", "0"),
("HasCompletedSetup", "0"),
("IsUploadRawEnabled", "1"),
("IsLdwEnabled", "1"),
("IsGeofenceEnabled", "-1"),
("SpeedLimitOffset", "0"),
("LongitudinalControl", "0"),
("LimitSetSpeed", "0"),
("LimitSetSpeedNeural", "0"),
("LastUpdateTime", datetime.datetime.now().isoformat().encode('utf8')),
("OpenpilotEnabledToggle", "1"),
("LaneChangeEnabled", "1"),
]
# set unset params # set unset params
if params.get("CommunityFeaturesToggle") is None: for k, v in default_params:
params.put("CommunityFeaturesToggle", "0") if params.get(k) is None:
if params.get("CompletedTrainingVersion") is None: params.put(k, v)
params.put("CompletedTrainingVersion", "0")
if params.get("IsMetric") is None:
params.put("IsMetric", "0")
if params.get("RecordFront") is None:
params.put("RecordFront", "0")
if params.get("HasAcceptedTerms") is None:
params.put("HasAcceptedTerms", "0")
if params.get("HasCompletedSetup") is None:
params.put("HasCompletedSetup", "0")
if params.get("IsUploadRawEnabled") is None:
params.put("IsUploadRawEnabled", "1")
if params.get("IsLdwEnabled") is None:
params.put("IsLdwEnabled", "1")
if params.get("IsGeofenceEnabled") is None:
params.put("IsGeofenceEnabled", "-1")
if params.get("SpeedLimitOffset") is None:
params.put("SpeedLimitOffset", "0")
if params.get("LongitudinalControl") is None:
params.put("LongitudinalControl", "0")
if params.get("LimitSetSpeed") is None:
params.put("LimitSetSpeed", "0")
if params.get("LimitSetSpeedNeural") is None:
params.put("LimitSetSpeedNeural", "0")
if params.get("LastUpdateTime") is None:
t = datetime.datetime.now().isoformat()
params.put("LastUpdateTime", t.encode('utf8'))
if params.get("OpenpilotEnabledToggle") is None:
params.put("OpenpilotEnabledToggle", "1")
if params.get("LaneChangeEnabled") is None:
params.put("LaneChangeEnabled", "1")
# is this chffrplus? # is this chffrplus?
if os.getenv("PASSIVE") is not None: if os.getenv("PASSIVE") is not None:

@ -273,7 +273,7 @@ def mapsd_thread():
map_data_sock.send(dat.to_bytes()) map_data_sock.send(dat.to_bytes())
def main(gctx=None): def main():
params = Params() params = Params()
dongle_id = params.get("DongleId") dongle_id = params.get("DongleId")
crash.bind_user(id=dongle_id) crash.bind_user(id=dongle_id)

@ -86,7 +86,7 @@ def update_panda():
raise AssertionError raise AssertionError
def main(gctx=None): def main():
update_panda() update_panda()
os.chdir("boardd") os.chdir("boardd")

@ -333,7 +333,6 @@ class LongitudinalControl(unittest.TestCase):
params.put("OpenpilotEnabledToggle", "1") params.put("OpenpilotEnabledToggle", "1")
params.put("CommunityFeaturesToggle", "1") params.put("CommunityFeaturesToggle", "1")
manager.gctx = {}
manager.prepare_managed_process('radard') manager.prepare_managed_process('radard')
manager.prepare_managed_process('controlsd') manager.prepare_managed_process('controlsd')
manager.prepare_managed_process('plannerd') manager.prepare_managed_process('plannerd')

@ -1 +1 @@
8e94b45bbadf4355135e13905f3e8219ff122f7f 0491cad238025a44b7fc636cf03efc27d80dcdae

@ -393,7 +393,7 @@ def thermald_thread():
count += 1 count += 1
def main(gctx=None): def main():
thermald_thread() thermald_thread()
if __name__ == "__main__": if __name__ == "__main__":

@ -101,7 +101,7 @@ def report_tombstone(fn, client):
cloudlog.error({'tombstone': message}) cloudlog.error({'tombstone': message})
def main(gctx=None): def main():
initial_tombstones = set(get_tombstones()) initial_tombstones = set(get_tombstones())
client = Client('https://d3b175702f62402c91ade04d1c547e68:b20d68c813c74f63a7cdf9c4039d8f56@sentry.io/157615', client = Client('https://d3b175702f62402c91ade04d1c547e68:b20d68c813c74f63a7cdf9c4039d8f56@sentry.io/157615',

@ -1,7 +1,7 @@
Import('env', 'arch', 'common', 'messaging', 'gpucommon', 'visionipc', 'cereal') Import('env', 'arch', 'common', 'messaging', 'gpucommon', 'visionipc', 'cereal')
src = ['ui.cc', 'paint.cc', '#phonelibs/nanovg/nanovg.c'] src = ['ui.cc', 'paint.cc', '#phonelibs/nanovg/nanovg.c']
libs = [common, 'zmq', 'czmq', 'capnp', 'capnp_c', 'm', cereal, 'json', messaging, gpucommon, visionipc] libs = [common, 'zmq', 'czmq', 'capnp', 'capnp_c', 'm', cereal, messaging, gpucommon, visionipc]
if arch == "aarch64": if arch == "aarch64":
src += ['sound.cc', 'slplay.c'] src += ['sound.cc', 'slplay.c']
@ -11,7 +11,7 @@ else:
src += ['linux.cc'] src += ['linux.cc']
libs += ['pthread', 'glfw'] libs += ['pthread', 'glfw']
linkflags = [] linkflags = []
env.Program('_ui', src, env.Program('_ui', src,
LINKFLAGS=linkflags, LINKFLAGS=linkflags,
LIBS=libs) LIBS=libs)

@ -6,7 +6,6 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <json.h>
#include <czmq.h> #include <czmq.h>
#include "common/util.h" #include "common/util.h"

@ -292,7 +292,7 @@ def attempt_update():
set_update_available_params(new_version=new_version) set_update_available_params(new_version=new_version)
def main(gctx=None): def main():
update_failed_count = 0 update_failed_count = 0
overlay_init_done = False overlay_init_done = False
wait_helper = WaitTimeHelper() wait_helper = WaitTimeHelper()

Loading…
Cancel
Save