Delay alert creation for some events (#1689)

* add creation delay parameter to alerts

* 1s delay for sensorsInvalid and canError

* bump cereal

* update refs
albatross
Adeeb 2020-06-12 15:32:50 -07:00 committed by GitHub
parent 955d2aefdd
commit 0bbe870b5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 21 deletions

2
cereal

@ -1 +1 @@
Subproject commit 9915b2086a4205d9a28eead6139d5d7cbb73b00b
Subproject commit b93b165a5c9de33325d7b01aa033073c978d1007

View File

@ -118,7 +118,6 @@ class Controls:
self.v_cruise_kph_last = 0
self.mismatch_counter = 0
self.can_error_counter = 0
self.consecutive_can_error_count = 0
self.last_blinker_frame = 0
self.saturated_count = 0
self.events_prev = []
@ -191,11 +190,6 @@ class Controls:
if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL):
self.events.add(EventName.canError)
self.consecutive_can_error_count += 1
else:
self.consecutive_can_error_count = 0
if self.consecutive_can_error_count > 2 / DT_CTRL:
self.events.add(EventName.canErrorPersistent)
if self.mismatch_counter >= 200:
self.events.add(EventName.controlsMismatch)
if not self.sm.alive['plan'] and self.sm.alive['pathPlan']:

View File

@ -1,7 +1,7 @@
from cereal import log, car
from common.realtime import DT_CTRL
from selfdrive.config import Conversions as CV
from selfdrive.locationd.calibration_helpers import Filter
AlertSize = log.ControlsState.AlertSize
@ -37,6 +37,7 @@ class Events:
def __init__(self):
self.events = []
self.static_events = []
self.events_prev = dict.fromkeys(EVENTS.keys(), 0)
@property
def names(self):
@ -51,6 +52,7 @@ class Events:
self.events.append(event_name)
def clear(self):
self.events_prev = {k: (v+1 if k in self.events else 0) for k, v in self.events_prev.items()}
self.events = self.static_events.copy()
def any(self, event_type):
@ -71,8 +73,10 @@ class Events:
alert = EVENTS[e][et]
if not isinstance(alert, Alert):
alert = alert(*callback_args)
alert.alert_type = EVENT_NAME[e]
ret.append(alert)
if DT_CTRL * (self.events_prev[e] + 1) >= alert.creation_delay:
alert.alert_type = EVENT_NAME[e]
ret.append(alert)
return ret
def add_from_msg(self, events):
@ -101,7 +105,8 @@ class Alert:
duration_sound,
duration_hud_alert,
duration_text,
alert_rate=0.):
alert_rate=0.,
creation_delay=0.):
self.alert_type = ""
self.alert_text_1 = alert_text_1
@ -118,6 +123,7 @@ class Alert:
self.start_time = 0.
self.alert_rate = alert_rate
self.creation_delay = creation_delay
# typecheck that enums are valid on startup
tst = car.CarControl.new_message()
@ -308,14 +314,6 @@ EVENTS = {
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.),
},
EventName.canErrorPersistent: {
ET.PERMANENT: Alert(
"CAN Error: Check Connections",
"",
AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
},
# ********** events only containing alerts that display while engaged **********
EventName.vehicleModelInvalid: {
@ -515,7 +513,7 @@ EVENTS = {
"No Data from Device Sensors",
"Reboot your Device",
AlertStatus.normal, AlertSize.mid,
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2),
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.),
ET.NO_ENTRY: NoEntryAlert("No Data from Device Sensors"),
},
@ -617,6 +615,11 @@ EVENTS = {
EventName.canError: {
ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("CAN Error: Check Connections"),
ET.PERMANENT: Alert(
"CAN Error: Check Connections",
"",
AlertStatus.normal, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.),
ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"),
},

View File

@ -1 +1 @@
6f46eed874e85f41de1bca4a7b0b65bfc4a295d8
b85c090b3dba832b4af83a847df5b5ac2c824284