mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-13 05:12:11 +08:00
per camera alerts (#20992)
* per camera alert * bump cereal * cleanup * space old-commit-hash: 12ed986333856086c774b3142659dfbaecdf654b
This commit is contained in:
+1
-1
Submodule cereal updated: a8055c3f21...b1675bac3d
@@ -72,7 +72,6 @@ class Controls:
|
||||
|
||||
if TICI:
|
||||
self.log_sock = messaging.sub_sock('androidLog')
|
||||
self.crc_seen = False
|
||||
|
||||
# wait for one pandaState and one CAN packet
|
||||
print("Waiting for CAN messages...")
|
||||
@@ -258,24 +257,24 @@ class Controls:
|
||||
self.events.add(EventName.fcw)
|
||||
|
||||
if TICI and self.enable_lte_onroad:
|
||||
if not self.crc_seen:
|
||||
logs = messaging.drain_sock(self.log_sock, wait_for_one=False)
|
||||
messages = []
|
||||
for m in logs:
|
||||
try:
|
||||
messages.append(m.androidLog.message)
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
logs = messaging.drain_sock(self.log_sock, wait_for_one=False)
|
||||
messages = []
|
||||
for m in logs:
|
||||
try:
|
||||
messages.append(m.androidLog.message)
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
||||
for err in ["ERROR_CRC", "ERROR_ECC", "ERROR_STREAM_UNDERFLOW", "APPLY FAILED"]:
|
||||
err_cnt = sum(err in m for m in messages)
|
||||
if err_cnt:
|
||||
self.crc_seen = True
|
||||
self.events.add(EventName.cameraError)
|
||||
break
|
||||
for err in ["ERROR_CRC", "ERROR_ECC", "ERROR_STREAM_UNDERFLOW", "APPLY FAILED"]:
|
||||
for m in messages:
|
||||
if err not in m:
|
||||
continue
|
||||
|
||||
if self.crc_seen:
|
||||
self.events.add(EventName.cameraError)
|
||||
csid = m.split("CSID:")[-1].split(" ")[0]
|
||||
evt = {"0": EventName.wideRoadCameraError, "1": EventName.roadCameraError,
|
||||
"2": EventName.driverCameraError}.get(csid, None)
|
||||
if evt is not None:
|
||||
self.events.add(evt)
|
||||
|
||||
# TODO: fix simulator
|
||||
if not SIMULATION:
|
||||
|
||||
@@ -169,10 +169,10 @@ class EngagementAlert(Alert):
|
||||
audible_alert, .2, 0., 0.),
|
||||
|
||||
class NormalPermanentAlert(Alert):
|
||||
def __init__(self, alert_text_1, alert_text_2):
|
||||
def __init__(self, alert_text_1: str, alert_text_2: str, duration_text: 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., .2),
|
||||
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., duration_text),
|
||||
|
||||
# ********** alert callback functions **********
|
||||
|
||||
@@ -672,8 +672,19 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
|
||||
ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Controls Mismatch"),
|
||||
},
|
||||
|
||||
EventName.cameraError: {
|
||||
ET.PERMANENT: NormalPermanentAlert("CRC Error", ""),
|
||||
EventName.roadCameraError: {
|
||||
ET.PERMANENT: NormalPermanentAlert("Road Camera Error", "",
|
||||
duration_text=10.),
|
||||
},
|
||||
|
||||
EventName.driverCameraError: {
|
||||
ET.PERMANENT: NormalPermanentAlert("Driver Camera Error", "",
|
||||
duration_text=10.),
|
||||
},
|
||||
|
||||
EventName.wideRoadCameraError: {
|
||||
ET.PERMANENT: NormalPermanentAlert("Wide Road Camera Error", "",
|
||||
duration_text=10.),
|
||||
},
|
||||
|
||||
EventName.usbError: {
|
||||
|
||||
Reference in New Issue
Block a user