improved alert verbosity (#24434)

* improved alert verbosity

* better testing script

* better description

* speed diff

* touch ups

* fix that
This commit is contained in:
Adeeb Shihadeh
2022-05-16 21:19:38 -07:00
committed by GitHub
parent fe867df102
commit b1858df00e
4 changed files with 101 additions and 42 deletions
+42 -14
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import time
import random
from cereal import car, log
import cereal.messaging as messaging
@@ -7,9 +8,13 @@ from common.realtime import DT_CTRL
from selfdrive.car.honda.interface import CarInterface
from selfdrive.controls.lib.events import ET, Events
from selfdrive.controls.lib.alertmanager import AlertManager
from selfdrive.manager.process_config import managed_processes
EventName = car.CarEvent.EventName
def randperc() -> float:
return 100. * random.random()
def cycle_alerts(duration=200, is_metric=False):
# all alerts
#alerts = list(EVENTS.keys())
@@ -31,23 +36,21 @@ def cycle_alerts(duration=200, is_metric=False):
# debug alerts
alerts = [
(EventName.highCpuUsage, ET.NO_ENTRY),
(EventName.lowMemory, ET.PERMANENT),
(EventName.overheat, ET.PERMANENT),
(EventName.outOfSpace, ET.PERMANENT),
(EventName.modeldLagging, ET.PERMANENT),
#(EventName.highCpuUsage, ET.NO_ENTRY),
#(EventName.lowMemory, ET.PERMANENT),
#(EventName.overheat, ET.PERMANENT),
#(EventName.outOfSpace, ET.PERMANENT),
#(EventName.modeldLagging, ET.PERMANENT),
#(EventName.processNotRunning, ET.NO_ENTRY),
(EventName.commIssue, ET.NO_ENTRY),
(EventName.calibrationInvalid, ET.PERMANENT),
(EventName.posenetInvalid, ET.NO_ENTRY),
]
CS = car.CarState.new_message()
CP = CarInterface.get_params("HONDA CIVIC 2016")
sm = messaging.SubMaster(['deviceState', 'pandaStates', 'roadCameraState', 'modelV2', 'liveCalibration',
'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman'])
sm['deviceState'].freeSpacePercent = 55
sm['deviceState'].memoryUsagePercent = 55
sm['deviceState'].cpuTempC = [1, 2, 100]
sm['deviceState'].gpuTempC = [211, 2, 100]
sm['deviceState'].cpuUsagePercent = [23, 54]
sm['modelV2'].frameDropPerc = 20
'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman', 'managerState'])
pm = messaging.PubMaster(['controlsState', 'pandaStates', 'deviceState'])
@@ -60,7 +63,32 @@ def cycle_alerts(duration=200, is_metric=False):
events.clear()
events.add(alert)
a = events.create_alerts([et, ], [CP, sm, is_metric, 0])
sm['deviceState'].freeSpacePercent = randperc()
sm['deviceState'].memoryUsagePercent = int(randperc())
sm['deviceState'].cpuTempC = [randperc() for _ in range(3)]
sm['deviceState'].gpuTempC = [randperc() for _ in range(3)]
sm['deviceState'].cpuUsagePercent = [int(randperc()) for _ in range(8)]
sm['modelV2'].frameDropPerc = randperc()
if random.random() > 0.25:
sm['modelV2'].velocity.x = [random.random(), ]
if random.random() > 0.25:
CS.vEgo = random.random()
procs = [p.get_process_state_msg() for p in managed_processes.values()]
random.shuffle(procs)
for i in range(random.randint(0, 10)):
procs[i].shouldBeRunning = True
sm['managerState'].processes = procs
sm['liveCalibration'].rpyCalib = [-1 * random.random() for _ in range(random.randint(0, 3))]
for s in sm.data.keys():
sm.alive[s] = random.random() > 0.08
sm.valid[s] = random.random() > 0.08
sm.freq_ok[s] = random.random() > 0.08
a = events.create_alerts([et, ], [CP, CS, sm, is_metric, 0])
AM.add_many(frame, a)
alert = AM.process_alerts(frame, [])
print(alert)