diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py index 1c28236fb2..42d9f457be 100644 --- a/selfdrive/controls/lib/alertmanager.py +++ b/selfdrive/controls/lib/alertmanager.py @@ -52,10 +52,9 @@ class AlertManager: def add_many(self, frame: int, alerts: List[Alert], enabled: bool = True) -> None: 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].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: current_alert = AlertEntry() diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 110b1e2037..7afd4f493e 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -111,9 +111,7 @@ class Alert: priority: Priority, visual_alert: car.CarControl.HUDControl.VisualAlert, audible_alert: car.CarControl.HUDControl.AudibleAlert, - duration_sound: float, - duration_hud_alert: float, - duration_text: float, + duration: float, alert_rate: float = 0., creation_delay: float = 0.): @@ -125,9 +123,7 @@ class Alert: self.visual_alert = visual_alert self.audible_alert = audible_alert - self.duration_sound = duration_sound - self.duration_hud_alert = duration_hud_alert - self.duration_text = duration_text + self.duration = duration self.alert_rate = alert_rate self.creation_delay = creation_delay @@ -144,10 +140,10 @@ class Alert: class NoEntryAlert(Alert): 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, AlertSize.mid, Priority.LOW, visual_alert, - audible_alert, .4, duration_hud_alert, 3.) + audible_alert, 3.) class SoftDisableAlert(Alert): @@ -155,30 +151,30 @@ class SoftDisableAlert(Alert): super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2, AlertStatus.critical, AlertSize.full, Priority.MID, VisualAlert.steerRequired, - AudibleAlert.chimeWarningRepeatInfinite, .1, 2., 2.), + AudibleAlert.chimeWarningRepeatInfinite, 2.), class ImmediateDisableAlert(Alert): - def __init__(self, alert_text_2, alert_text_1="TAKE CONTROL IMMEDIATELY"): - super().__init__(alert_text_1, alert_text_2, + def __init__(self, alert_text_2): + super().__init__("TAKE CONTROL IMMEDIATELY", alert_text_2, AlertStatus.critical, AlertSize.full, Priority.HIGHEST, VisualAlert.steerRequired, - AudibleAlert.chimeWarningRepeatInfinite, 2.2, 3., 4.), + AudibleAlert.chimeWarningRepeatInfinite, 4.), class EngagementAlert(Alert): - def __init__(self, audible_alert=True): + def __init__(self, audible_alert: car.CarControl.HUDControl.AudibleAlert): super().__init__("", "", AlertStatus.normal, AlertSize.none, Priority.MID, VisualAlert.none, - audible_alert, .2, 0., 0.), + audible_alert, .02), 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, 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 ********** 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)}", "", 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: @@ -205,7 +201,7 @@ def calibration_incomplete_alert(CP: car.CarParams, sm: messaging.SubMaster, met "Calibration in Progress: %d%%" % sm['liveCalibration'].calPerc, f"Drive Above {get_display_speed(MIN_SPEED_FILTER, metric)}", 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: @@ -214,24 +210,21 @@ def no_gps_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Al "Poor GPS reception", "If sky is visible, contact support" if gps_integrated else "Check GPS antenna placement", 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: text = "Cruise Mode Disabled" if CP.carName == "honda": 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: axes = sm['testJoystick'].axes gb, steer = list(axes)[:2] if len(axes) else (0., 0.) - return Alert( - "Joystick Mode", - f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .1) + vals = f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%" + return NormalPermanentAlert("Joystick Mode", vals) 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: { ET.WARNING: joystick_alert, - ET.PERMANENT: Alert( - "Joystick Mode", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 0.1), + ET.PERMANENT: NormalPermanentAlert("Joystick Mode"), }, 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", "Always keep hands on wheel and eyes on road", AlertStatus.normal, AlertSize.mid, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.), }, EventName.startupMaster: { @@ -267,7 +256,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "WARNING: This branch is not tested", "Always keep hands on wheel and eyes on road", 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 @@ -276,7 +265,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Dashcam mode", "Always keep hands on wheel and eyes on road", AlertStatus.normal, AlertSize.mid, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.), }, # 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", "Always keep hands on wheel and eyes on road", AlertStatus.normal, AlertSize.mid, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.), }, EventName.startupNoFw: { @@ -293,7 +282,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Car Unrecognized", "Check comma power connections", AlertStatus.userPrompt, AlertSize.mid, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 10.), }, EventName.dashcamMode: { @@ -301,7 +290,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Dashcam Mode", "", AlertStatus.normal, AlertSize.small, - Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2), }, EventName.invalidLkasSetting: { @@ -309,7 +298,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Stock LKAS is turned on", "Turn off stock LKAS to engage", 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 @@ -321,7 +310,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "openpilot Not Available", "Enable Community Features in Settings to Engage", 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 @@ -332,7 +321,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Dashcam Mode", "Car Unrecognized", AlertStatus.normal, AlertSize.mid, - Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2), }, EventName.stockAeb: { @@ -340,7 +329,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "BRAKE!", "Stock AEB: Risk of Collision", 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"), }, @@ -349,7 +338,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "BRAKE!", "Risk of Collision", AlertStatus.critical, AlertSize.full, - Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeatInfinite, 1., 2., 2.), + Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeatInfinite, 2.), }, EventName.ldw: { @@ -357,7 +346,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "TAKE CONTROL", "Lane Departure Detected", 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 ********** @@ -367,7 +356,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "openpilot will not brake while gas pressed", "", 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 @@ -385,7 +374,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Vehicle Parameter Identification Failed", "", AlertStatus.normal, AlertSize.small, - Priority.LOWEST, VisualAlert.steerRequired, AudibleAlert.none, .0, .0, .1), + Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .1), }, EventName.steerTempUnavailableSilent: { @@ -393,7 +382,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Steering Temporarily Unavailable", "", AlertStatus.userPrompt, AlertSize.small, - Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 1., 1.), + Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1.), }, EventName.preDriverDistracted: { @@ -401,7 +390,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "KEEP EYES ON ROAD: Driver Distracted", "", AlertStatus.normal, AlertSize.small, - Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1), + Priority.LOW, VisualAlert.none, AudibleAlert.none, .1), }, EventName.promptDriverDistracted: { @@ -409,7 +398,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "KEEP EYES ON ROAD", "Driver Distracted", AlertStatus.userPrompt, AlertSize.mid, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1, .1, .1), + Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1), }, EventName.driverDistracted: { @@ -417,7 +406,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "DISENGAGE IMMEDIATELY", "Driver Distracted", AlertStatus.critical, AlertSize.full, - Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1, .1, .1), + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1), }, EventName.preDriverUnresponsive: { @@ -425,7 +414,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "TOUCH STEERING WHEEL: No Face Detected", "", 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: { @@ -433,7 +422,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "TOUCH STEERING WHEEL", "Driver Unresponsive", AlertStatus.userPrompt, AlertSize.mid, - Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1, .1, .1), + Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2RepeatInfinite, .1), }, EventName.driverUnresponsive: { @@ -441,7 +430,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "DISENGAGE IMMEDIATELY", "Driver Unresponsive", AlertStatus.critical, AlertSize.full, - Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1, .1, .1), + Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeatInfinite, .1), }, EventName.manualRestart: { @@ -449,7 +438,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "TAKE CONTROL", "Resume Driving Manually", AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + Priority.LOW, VisualAlert.none, AudibleAlert.none, .2), }, EventName.resumeRequired: { @@ -457,7 +446,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "STOPPED", "Press Resume to Move", AlertStatus.userPrompt, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + Priority.LOW, VisualAlert.none, AudibleAlert.none, .2), }, 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", "", 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: { @@ -477,7 +466,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Steer Right to Start Lane Change Once Safe", "", 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: { @@ -485,7 +474,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Car Detected in Blindspot", "", AlertStatus.userPrompt, AlertSize.small, - Priority.LOW, VisualAlert.none, AudibleAlert.chimePrompt, .1, .1, .1), + Priority.LOW, VisualAlert.none, AudibleAlert.chimePrompt, .1), }, EventName.laneChange: { @@ -493,7 +482,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Changing Lanes", "", AlertStatus.normal, AlertSize.small, - Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1), + Priority.LOW, VisualAlert.none, AudibleAlert.none, .1), }, EventName.steerSaturated: { @@ -501,7 +490,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "TAKE CONTROL", "Turn Exceeds Steering Limit", 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 @@ -572,18 +561,12 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo EventName.steerTempUnavailable: { ET.SOFT_DISABLE: SoftDisableAlert("Steering Temporarily Unavailable"), - ET.NO_ENTRY: NoEntryAlert("Steering Temporarily Unavailable", - duration_hud_alert=0.), + ET.NO_ENTRY: NoEntryAlert("Steering Temporarily Unavailable"), }, EventName.outOfSpace: { - ET.PERMANENT: Alert( - "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.), + ET.PERMANENT: NormalPermanentAlert("Out of Storage"), + ET.NO_ENTRY: NoEntryAlert("Out of Storage"), }, EventName.belowEngageSpeed: { @@ -595,7 +578,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "No Data from Device Sensors", "Reboot your Device", 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"), }, @@ -613,11 +596,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo }, EventName.overheat: { - ET.PERMANENT: Alert( - "System Overheated", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + ET.PERMANENT: NormalPermanentAlert("System Overheated"), ET.SOFT_DISABLE: SoftDisableAlert("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: { ET.PERMANENT: NormalPermanentAlert("Road Camera Error", "", - duration_text=10.), + duration=10.), }, EventName.driverCameraError: { ET.PERMANENT: NormalPermanentAlert("Driver Camera Error", "", - duration_text=10.), + duration=10.), }, EventName.wideRoadCameraError: { 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 @@ -767,7 +746,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "CAN Error: Check Connections", "", 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"), }, @@ -777,7 +756,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "LKAS Fault: Restart the car to engage", "", 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"), }, @@ -787,7 +766,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Cruise Fault: Restart the car to engage", "", 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"), }, @@ -796,7 +775,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Reverse\nGear", "", 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.NO_ENTRY: NoEntryAlert("Reverse Gear"), }, @@ -830,7 +809,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "openpilot Canceled", "No close lead car", 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"), }, @@ -839,7 +818,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "openpilot Canceled", "Speed too low", 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 @@ -848,12 +827,12 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo "Speed Too High", "Model uncertain at this speed", 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( "Speed Too High", "Slow down to engage", AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), + Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, 3.), }, 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", "", 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"), }, diff --git a/selfdrive/controls/tests/test_alerts.py b/selfdrive/controls/tests/test_alerts.py index a0f3689a92..d32bc2365d 100755 --- a/selfdrive/controls/tests/test_alerts.py +++ b/selfdrive/controls/tests/test_alerts.py @@ -82,7 +82,7 @@ class TestAlerts(unittest.TestCase): if a.alert_size == AlertSize.small: 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): params = Params() diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index e16d08dddd..b2df9d03c8 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -e3619d2382fa67c2c2d5b7a3d89f74f7d85c411d \ No newline at end of file +0ee2d1f6b658ecb823212827f5fd6b996f143119 \ No newline at end of file