alerts: use a single duration for sound, text, and HUD (#22856)

* alerts: use a single duration for sound, text, and HUD

* little cleanup

* update refs
pull/22858/head
Adeeb Shihadeh 4 years ago committed by GitHub
parent 93ba52c76c
commit c5d6b85c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      selfdrive/controls/lib/alertmanager.py
  2. 149
      selfdrive/controls/lib/events.py
  3. 2
      selfdrive/controls/tests/test_alerts.py
  4. 2
      selfdrive/test/process_replay/ref_commit

@ -52,10 +52,9 @@ class AlertManager:
def add_many(self, frame: int, alerts: List[Alert], enabled: bool = True) -> None: def add_many(self, frame: int, alerts: List[Alert], enabled: bool = True) -> None:
for alert in alerts: for alert in alerts:
alert_duration = max(alert.duration_sound, alert.duration_hud_alert, alert.duration_text)
self.activealerts[alert.alert_type].alert = alert self.activealerts[alert.alert_type].alert = alert
self.activealerts[alert.alert_type].start_frame = frame self.activealerts[alert.alert_type].start_frame = frame
self.activealerts[alert.alert_type].end_frame = frame + int(alert_duration / DT_CTRL) self.activealerts[alert.alert_type].end_frame = frame + int(alert.duration / DT_CTRL)
def process_alerts(self, frame: int, clear_event_type=None) -> None: def process_alerts(self, frame: int, clear_event_type=None) -> None:
current_alert = AlertEntry() current_alert = AlertEntry()

@ -111,9 +111,7 @@ class Alert:
priority: Priority, priority: Priority,
visual_alert: car.CarControl.HUDControl.VisualAlert, visual_alert: car.CarControl.HUDControl.VisualAlert,
audible_alert: car.CarControl.HUDControl.AudibleAlert, audible_alert: car.CarControl.HUDControl.AudibleAlert,
duration_sound: float, duration: float,
duration_hud_alert: float,
duration_text: float,
alert_rate: float = 0., alert_rate: float = 0.,
creation_delay: float = 0.): creation_delay: float = 0.):
@ -125,9 +123,7 @@ class Alert:
self.visual_alert = visual_alert self.visual_alert = visual_alert
self.audible_alert = audible_alert self.audible_alert = audible_alert
self.duration_sound = duration_sound self.duration = duration
self.duration_hud_alert = duration_hud_alert
self.duration_text = duration_text
self.alert_rate = alert_rate self.alert_rate = alert_rate
self.creation_delay = creation_delay self.creation_delay = creation_delay
@ -144,10 +140,10 @@ class Alert:
class NoEntryAlert(Alert): class NoEntryAlert(Alert):
def __init__(self, alert_text_2, audible_alert=AudibleAlert.chimeError, def __init__(self, alert_text_2, audible_alert=AudibleAlert.chimeError,
visual_alert=VisualAlert.none, duration_hud_alert=2.): visual_alert=VisualAlert.none):
super().__init__("openpilot Unavailable", alert_text_2, AlertStatus.normal, super().__init__("openpilot Unavailable", alert_text_2, AlertStatus.normal,
AlertSize.mid, Priority.LOW, visual_alert, AlertSize.mid, Priority.LOW, visual_alert,
audible_alert, .4, duration_hud_alert, 3.) audible_alert, 3.)
class SoftDisableAlert(Alert): class SoftDisableAlert(Alert):
@ -155,30 +151,30 @@ class SoftDisableAlert(Alert):
super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2, super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2,
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.MID, VisualAlert.steerRequired, Priority.MID, VisualAlert.steerRequired,
AudibleAlert.chimeWarningRepeatInfinite, .1, 2., 2.), AudibleAlert.chimeWarningRepeatInfinite, 2.),
class ImmediateDisableAlert(Alert): class ImmediateDisableAlert(Alert):
def __init__(self, alert_text_2, alert_text_1="TAKE CONTROL IMMEDIATELY"): def __init__(self, alert_text_2):
super().__init__(alert_text_1, alert_text_2, super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2,
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.HIGHEST, VisualAlert.steerRequired, Priority.HIGHEST, VisualAlert.steerRequired,
AudibleAlert.chimeWarningRepeatInfinite, 2.2, 3., 4.), AudibleAlert.chimeWarningRepeatInfinite, 4.),
class EngagementAlert(Alert): class EngagementAlert(Alert):
def __init__(self, audible_alert=True): def __init__(self, audible_alert: car.CarControl.HUDControl.AudibleAlert):
super().__init__("", "", super().__init__("", "",
AlertStatus.normal, AlertSize.none, AlertStatus.normal, AlertSize.none,
Priority.MID, VisualAlert.none, Priority.MID, VisualAlert.none,
audible_alert, .2, 0., 0.), audible_alert, .02),
class NormalPermanentAlert(Alert): class NormalPermanentAlert(Alert):
def __init__(self, alert_text_1: str, alert_text_2: str, duration_text: float = 0.2): def __init__(self, alert_text_1: str, alert_text_2: str = "", duration: float = 0.2):
super().__init__(alert_text_1, alert_text_2, super().__init__(alert_text_1, alert_text_2,
AlertStatus.normal, AlertSize.mid if len(alert_text_2) else AlertSize.small, AlertStatus.normal, AlertSize.mid if len(alert_text_2) else AlertSize.small,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., duration_text), Priority.LOWER, VisualAlert.none, AudibleAlert.none, duration),
# ********** helper functions ********** # ********** helper functions **********
def get_display_speed(speed_ms: float, metric: bool) -> str: def get_display_speed(speed_ms: float, metric: bool) -> str:
@ -197,7 +193,7 @@ def below_steer_speed_alert(CP: car.CarParams, sm: messaging.SubMaster, metric:
f"Steer Unavailable Below {get_display_speed(CP.minSteerSpeed, metric)}", f"Steer Unavailable Below {get_display_speed(CP.minSteerSpeed, metric)}",
"", "",
AlertStatus.userPrompt, AlertSize.small, AlertStatus.userPrompt, AlertSize.small,
Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 0., 0.4, .3) Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 0.4)
def calibration_incomplete_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: def calibration_incomplete_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert:
@ -205,7 +201,7 @@ def calibration_incomplete_alert(CP: car.CarParams, sm: messaging.SubMaster, met
"Calibration in Progress: %d%%" % sm['liveCalibration'].calPerc, "Calibration in Progress: %d%%" % sm['liveCalibration'].calPerc,
f"Drive Above {get_display_speed(MIN_SPEED_FILTER, metric)}", f"Drive Above {get_display_speed(MIN_SPEED_FILTER, metric)}",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2) Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2)
def no_gps_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: def no_gps_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert:
@ -214,24 +210,21 @@ def no_gps_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Al
"Poor GPS reception", "Poor GPS reception",
"If sky is visible, contact support" if gps_integrated else "Check GPS antenna placement", "If sky is visible, contact support" if gps_integrated else "Check GPS antenna placement",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=300.) Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2, creation_delay=300.)
def wrong_car_mode_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: def wrong_car_mode_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert:
text = "Cruise Mode Disabled" text = "Cruise Mode Disabled"
if CP.carName == "honda": if CP.carName == "honda":
text = "Main Switch Off" text = "Main Switch Off"
return NoEntryAlert(text, duration_hud_alert=0.) return NoEntryAlert(text)
def joystick_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: def joystick_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert:
axes = sm['testJoystick'].axes axes = sm['testJoystick'].axes
gb, steer = list(axes)[:2] if len(axes) else (0., 0.) gb, steer = list(axes)[:2] if len(axes) else (0., 0.)
return Alert( vals = f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%"
"Joystick Mode", return NormalPermanentAlert("Joystick Mode", vals)
f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%",
AlertStatus.normal, AlertSize.mid,
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .1)
EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, bool], Alert]]]] = { EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, bool], Alert]]]] = {
@ -243,11 +236,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
EventName.joystickDebug: { EventName.joystickDebug: {
ET.WARNING: joystick_alert, ET.WARNING: joystick_alert,
ET.PERMANENT: Alert( ET.PERMANENT: NormalPermanentAlert("Joystick Mode"),
"Joystick Mode",
"",
AlertStatus.normal, AlertSize.small,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 0.1),
}, },
EventName.controlsInitializing: { EventName.controlsInitializing: {
@ -259,7 +248,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"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.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.),
}, },
EventName.startupMaster: { EventName.startupMaster: {
@ -267,7 +256,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"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.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.),
}, },
# Car is recognized, but marked as dashcam only # Car is recognized, but marked as dashcam only
@ -276,7 +265,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"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.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.),
}, },
# Car is not recognized # Car is not recognized
@ -285,7 +274,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Dashcam mode for unsupported car", "Dashcam mode for 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.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.),
}, },
EventName.startupNoFw: { EventName.startupNoFw: {
@ -293,7 +282,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Car Unrecognized", "Car Unrecognized",
"Check comma power connections", "Check comma power connections",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.),
}, },
EventName.dashcamMode: { EventName.dashcamMode: {
@ -301,7 +290,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Dashcam Mode", "Dashcam Mode",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2),
}, },
EventName.invalidLkasSetting: { EventName.invalidLkasSetting: {
@ -309,7 +298,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Stock LKAS is turned on", "Stock LKAS is turned on",
"Turn off stock LKAS to engage", "Turn off stock LKAS to engage",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2),
}, },
# Some features or cars are marked as community features. If openpilot # Some features or cars are marked as community features. If openpilot
@ -321,7 +310,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"openpilot Not Available", "openpilot Not Available",
"Enable Community Features in Settings to Engage", "Enable Community Features in Settings to Engage",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOW, VisualAlert.none, AudibleAlert.none, .2),
}, },
# openpilot doesn't recognize the car. This switches openpilot into a # openpilot doesn't recognize the car. This switches openpilot into a
@ -332,7 +321,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Dashcam Mode", "Dashcam Mode",
"Car Unrecognized", "Car Unrecognized",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2),
}, },
EventName.stockAeb: { EventName.stockAeb: {
@ -340,7 +329,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"BRAKE!", "BRAKE!",
"Stock AEB: Risk of Collision", "Stock AEB: Risk of Collision",
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.none, 1., 2., 2.), Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.none, 2.),
ET.NO_ENTRY: NoEntryAlert("Stock AEB: Risk of Collision"), ET.NO_ENTRY: NoEntryAlert("Stock AEB: Risk of Collision"),
}, },
@ -349,7 +338,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"BRAKE!", "BRAKE!",
"Risk of Collision", "Risk of Collision",
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeatInfinite, 1., 2., 2.), Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeatInfinite, 2.),
}, },
EventName.ldw: { EventName.ldw: {
@ -357,7 +346,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"TAKE CONTROL", "TAKE CONTROL",
"Lane Departure Detected", "Lane Departure Detected",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, VisualAlert.ldw, AudibleAlert.chimePrompt, 1., 2., 3.), Priority.LOW, VisualAlert.ldw, AudibleAlert.chimePrompt, 3.),
}, },
# ********** events only containing alerts that display while engaged ********** # ********** events only containing alerts that display while engaged **********
@ -367,7 +356,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"openpilot will not brake while gas pressed", "openpilot will not brake while gas pressed",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .0, .0, .1, creation_delay=1.), Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .1, creation_delay=1.),
}, },
# openpilot tries to learn certain parameters about your car by observing # openpilot tries to learn certain parameters about your car by observing
@ -385,7 +374,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Vehicle Parameter Identification Failed", "Vehicle Parameter Identification Failed",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOWEST, VisualAlert.steerRequired, AudibleAlert.none, .0, .0, .1), Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .1),
}, },
EventName.steerTempUnavailableSilent: { EventName.steerTempUnavailableSilent: {
@ -393,7 +382,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Steering Temporarily Unavailable", "Steering Temporarily Unavailable",
"", "",
AlertStatus.userPrompt, AlertSize.small, AlertStatus.userPrompt, AlertSize.small,
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 1., 1.), Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1.),
}, },
EventName.preDriverDistracted: { EventName.preDriverDistracted: {
@ -401,7 +390,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"KEEP EYES ON ROAD: Driver Distracted", "KEEP EYES ON ROAD: Driver Distracted",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1), Priority.LOW, VisualAlert.none, AudibleAlert.none, .1),
}, },
EventName.promptDriverDistracted: { EventName.promptDriverDistracted: {
@ -409,7 +398,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"KEEP EYES ON ROAD", "KEEP EYES ON ROAD",
"Driver Distracted", "Driver Distracted",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1, .1, .1), Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1),
}, },
EventName.driverDistracted: { EventName.driverDistracted: {
@ -417,7 +406,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"DISENGAGE IMMEDIATELY", "DISENGAGE IMMEDIATELY",
"Driver Distracted", "Driver Distracted",
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1, .1, .1), Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1),
}, },
EventName.preDriverUnresponsive: { EventName.preDriverUnresponsive: {
@ -425,7 +414,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"TOUCH STEERING WHEEL: No Face Detected", "TOUCH STEERING WHEEL: No Face Detected",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .1, alert_rate=0.75),
}, },
EventName.promptDriverUnresponsive: { EventName.promptDriverUnresponsive: {
@ -433,7 +422,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"TOUCH STEERING WHEEL", "TOUCH STEERING WHEEL",
"Driver Unresponsive", "Driver Unresponsive",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1, .1, .1), Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1),
}, },
EventName.driverUnresponsive: { EventName.driverUnresponsive: {
@ -441,7 +430,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"DISENGAGE IMMEDIATELY", "DISENGAGE IMMEDIATELY",
"Driver Unresponsive", "Driver Unresponsive",
AlertStatus.critical, AlertSize.full, AlertStatus.critical, AlertSize.full,
Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1, .1, .1), Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1),
}, },
EventName.manualRestart: { EventName.manualRestart: {
@ -449,7 +438,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"TAKE CONTROL", "TAKE CONTROL",
"Resume Driving Manually", "Resume Driving Manually",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOW, VisualAlert.none, AudibleAlert.none, .2),
}, },
EventName.resumeRequired: { EventName.resumeRequired: {
@ -457,7 +446,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"STOPPED", "STOPPED",
"Press Resume to Move", "Press Resume to Move",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOW, VisualAlert.none, AudibleAlert.none, .2),
}, },
EventName.belowSteerSpeed: { EventName.belowSteerSpeed: {
@ -469,7 +458,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Steer Left to Start Lane Change Once Safe", "Steer Left to Start Lane Change Once Safe",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, alert_rate=0.75),
}, },
EventName.preLaneChangeRight: { EventName.preLaneChangeRight: {
@ -477,7 +466,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Steer Right to Start Lane Change Once Safe", "Steer Right to Start Lane Change Once Safe",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, alert_rate=0.75),
}, },
EventName.laneChangeBlocked: { EventName.laneChangeBlocked: {
@ -485,7 +474,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Car Detected in Blindspot", "Car Detected in Blindspot",
"", "",
AlertStatus.userPrompt, AlertSize.small, AlertStatus.userPrompt, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.chimePrompt, .1, .1, .1), Priority.LOW, VisualAlert.none, AudibleAlert.chimePrompt, .1),
}, },
EventName.laneChange: { EventName.laneChange: {
@ -493,7 +482,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Changing Lanes", "Changing Lanes",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1), Priority.LOW, VisualAlert.none, AudibleAlert.none, .1),
}, },
EventName.steerSaturated: { EventName.steerSaturated: {
@ -501,7 +490,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"TAKE CONTROL", "TAKE CONTROL",
"Turn Exceeds Steering Limit", "Turn Exceeds Steering Limit",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 1., 1.), Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1.),
}, },
# Thrown when the fan is driven at >50% but is not rotating # Thrown when the fan is driven at >50% but is not rotating
@ -572,18 +561,12 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
EventName.steerTempUnavailable: { EventName.steerTempUnavailable: {
ET.SOFT_DISABLE: SoftDisableAlert("Steering Temporarily Unavailable"), ET.SOFT_DISABLE: SoftDisableAlert("Steering Temporarily Unavailable"),
ET.NO_ENTRY: NoEntryAlert("Steering Temporarily Unavailable", ET.NO_ENTRY: NoEntryAlert("Steering Temporarily Unavailable"),
duration_hud_alert=0.),
}, },
EventName.outOfSpace: { EventName.outOfSpace: {
ET.PERMANENT: Alert( ET.PERMANENT: NormalPermanentAlert("Out of Storage"),
"Out of Storage", ET.NO_ENTRY: NoEntryAlert("Out of Storage"),
"",
AlertStatus.normal, AlertSize.small,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
ET.NO_ENTRY: NoEntryAlert("Out of Storage Space",
duration_hud_alert=0.),
}, },
EventName.belowEngageSpeed: { EventName.belowEngageSpeed: {
@ -595,7 +578,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"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.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2, creation_delay=1.),
ET.NO_ENTRY: NoEntryAlert("No Data from Device Sensors"), ET.NO_ENTRY: NoEntryAlert("No Data from Device Sensors"),
}, },
@ -613,11 +596,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
}, },
EventName.overheat: { EventName.overheat: {
ET.PERMANENT: Alert( ET.PERMANENT: NormalPermanentAlert("System Overheated"),
"System Overheated",
"",
AlertStatus.normal, AlertSize.small,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
ET.SOFT_DISABLE: SoftDisableAlert("System Overheated"), ET.SOFT_DISABLE: SoftDisableAlert("System Overheated"),
ET.NO_ENTRY: NoEntryAlert("System Overheated"), ET.NO_ENTRY: NoEntryAlert("System Overheated"),
}, },
@ -736,17 +715,17 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
EventName.roadCameraError: { EventName.roadCameraError: {
ET.PERMANENT: NormalPermanentAlert("Road Camera Error", "", ET.PERMANENT: NormalPermanentAlert("Road Camera Error", "",
duration_text=10.), duration=10.),
}, },
EventName.driverCameraError: { EventName.driverCameraError: {
ET.PERMANENT: NormalPermanentAlert("Driver Camera Error", "", ET.PERMANENT: NormalPermanentAlert("Driver Camera Error", "",
duration_text=10.), duration=10.),
}, },
EventName.wideRoadCameraError: { EventName.wideRoadCameraError: {
ET.PERMANENT: NormalPermanentAlert("Wide Road Camera Error", "", ET.PERMANENT: NormalPermanentAlert("Wide Road Camera Error", "",
duration_text=10.), duration=10.),
}, },
# Sometimes the USB stack on the device can get into a bad state # Sometimes the USB stack on the device can get into a bad state
@ -767,7 +746,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"CAN Error: Check Connections", "CAN Error: Check Connections",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), Priority.LOW, VisualAlert.none, AudibleAlert.none, 1., creation_delay=1.),
ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"), ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"),
}, },
@ -777,7 +756,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"LKAS Fault: Restart the car to engage", "LKAS Fault: Restart the car to engage",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2),
ET.NO_ENTRY: NoEntryAlert("LKAS Fault: Restart the Car"), ET.NO_ENTRY: NoEntryAlert("LKAS Fault: Restart the Car"),
}, },
@ -787,7 +766,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Cruise Fault: Restart the car to engage", "Cruise Fault: Restart the car to engage",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2),
ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"), ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"),
}, },
@ -796,7 +775,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Reverse\nGear", "Reverse\nGear",
"", "",
AlertStatus.normal, AlertSize.full, AlertStatus.normal, AlertSize.full,
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=0.5), Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2, creation_delay=0.5),
ET.USER_DISABLE: ImmediateDisableAlert("Reverse Gear"), ET.USER_DISABLE: ImmediateDisableAlert("Reverse Gear"),
ET.NO_ENTRY: NoEntryAlert("Reverse Gear"), ET.NO_ENTRY: NoEntryAlert("Reverse Gear"),
}, },
@ -830,7 +809,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"openpilot Canceled", "openpilot Canceled",
"No close lead car", "No close lead car",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, 3.),
ET.NO_ENTRY: NoEntryAlert("No Close Lead Car"), ET.NO_ENTRY: NoEntryAlert("No Close Lead Car"),
}, },
@ -839,7 +818,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"openpilot Canceled", "openpilot Canceled",
"Speed too low", "Speed too low",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, 3.),
}, },
# When the car is driving faster than most cars in the training data the model outputs can be unpredictable # When the car is driving faster than most cars in the training data the model outputs can be unpredictable
@ -848,12 +827,12 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Speed Too High", "Speed Too High",
"Model uncertain at this speed", "Model uncertain at this speed",
AlertStatus.userPrompt, AlertSize.mid, AlertStatus.userPrompt, AlertSize.mid,
Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, 2.2, 3., 4.), Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, 4.),
ET.NO_ENTRY: Alert( ET.NO_ENTRY: Alert(
"Speed Too High", "Speed Too High",
"Slow down to engage", "Slow down to engage",
AlertStatus.normal, AlertSize.mid, AlertStatus.normal, AlertSize.mid,
Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, 3.),
}, },
EventName.lowSpeedLockout: { EventName.lowSpeedLockout: {
@ -861,7 +840,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
"Cruise Fault: Restart the car to engage", "Cruise Fault: Restart the car to engage",
"", "",
AlertStatus.normal, AlertSize.small, AlertStatus.normal, AlertSize.small,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2),
ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"), ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"),
}, },

@ -82,7 +82,7 @@ class TestAlerts(unittest.TestCase):
if a.alert_size == AlertSize.small: if a.alert_size == AlertSize.small:
self.assertEqual(0, len(a.alert_text_2)) self.assertEqual(0, len(a.alert_text_2))
self.assertTrue(all([n >= 0. for n in [a.duration_sound, a.duration_hud_alert, a.duration_text]])) self.assertGreaterEqual(a.duration, 0.)
def test_offroad_alerts(self): def test_offroad_alerts(self):
params = Params() params = Params()

@ -1 +1 @@
e3619d2382fa67c2c2d5b7a3d89f74f7d85c411d 0ee2d1f6b658ecb823212827f5fd6b996f143119
Loading…
Cancel
Save