show which cameras are malfunctioning (#24558)

old-commit-hash: 0b1f6e3620
taco
Adeeb Shihadeh 3 years ago committed by GitHub
parent bec4ca8e7d
commit a6bcd14abd
  1. 14
      selfdrive/controls/lib/events.py
  2. 19
      selfdrive/debug/cycle_alerts.py

@ -282,6 +282,12 @@ def comm_issue_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaste
return NoEntryAlert(msg, alert_text_1="Communication Issue Between Processes") return NoEntryAlert(msg, alert_text_1="Communication Issue Between Processes")
def camera_malfunction_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert:
all_cams = ('roadCameraState', 'driverCameraState', 'wideRoadCameraState')
bad_cams = [s for s in all_cams if s in sm.data.keys() and not sm.all_checks([s, ])]
return NormalPermanentAlert("Camera Malfunction", ', '.join(bad_cams))
def calibration_invalid_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert: def calibration_invalid_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int) -> Alert:
rpy = sm['liveCalibration'].rpyCalib rpy = sm['liveCalibration'].rpyCalib
yaw = math.degrees(rpy[2] if len(rpy) == 3 else math.nan) yaw = math.degrees(rpy[2] if len(rpy) == 3 else math.nan)
@ -551,7 +557,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = {
# Camera is not outputting frames # Camera is not outputting frames
EventName.cameraMalfunction: { EventName.cameraMalfunction: {
ET.PERMANENT: NormalPermanentAlert("Camera Malfunction", "Likely Hardware Issue"), ET.PERMANENT: camera_malfunction_alert,
}, },
# Camera framerate too low # Camera framerate too low
EventName.cameraFrameRate: { EventName.cameraFrameRate: {
@ -882,9 +888,9 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = {
# are received on the car side this usually means the relay hasn't opened correctly # are received on the car side this usually means the relay hasn't opened correctly
# and this alert is thrown. # and this alert is thrown.
EventName.relayMalfunction: { EventName.relayMalfunction: {
ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Harness Malfunction"), ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Harness Relay Malfunction"),
ET.PERMANENT: NormalPermanentAlert("Harness Malfunction", "Check Hardware"), ET.PERMANENT: NormalPermanentAlert("Harness Relay Malfunction", "Check Hardware"),
ET.NO_ENTRY: NoEntryAlert("Harness Malfunction"), ET.NO_ENTRY: NoEntryAlert("Harness Relay Malfunction"),
}, },
EventName.noTarget: { EventName.noTarget: {

@ -42,15 +42,19 @@ def cycle_alerts(duration=200, is_metric=False):
#(EventName.outOfSpace, ET.PERMANENT), #(EventName.outOfSpace, ET.PERMANENT),
#(EventName.modeldLagging, ET.PERMANENT), #(EventName.modeldLagging, ET.PERMANENT),
#(EventName.processNotRunning, ET.NO_ENTRY), #(EventName.processNotRunning, ET.NO_ENTRY),
(EventName.commIssue, ET.NO_ENTRY), #(EventName.commIssue, ET.NO_ENTRY),
(EventName.calibrationInvalid, ET.PERMANENT), #(EventName.calibrationInvalid, ET.PERMANENT),
(EventName.posenetInvalid, ET.NO_ENTRY), (EventName.cameraMalfunction, ET.PERMANENT),
(EventName.cameraFrameRate, ET.PERMANENT),
] ]
cameras = ['roadCameraState', 'wideRoadCameraState', 'driverCameraState']
CS = car.CarState.new_message() CS = car.CarState.new_message()
CP = CarInterface.get_params("HONDA CIVIC 2016") CP = CarInterface.get_params("HONDA CIVIC 2016")
sm = messaging.SubMaster(['deviceState', 'pandaStates', 'roadCameraState', 'modelV2', 'liveCalibration', sm = messaging.SubMaster(['deviceState', 'pandaStates', 'roadCameraState', 'modelV2', 'liveCalibration',
'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman', 'managerState']) 'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman',
'managerState'] + cameras)
pm = messaging.PubMaster(['controlsState', 'pandaStates', 'deviceState']) pm = messaging.PubMaster(['controlsState', 'pandaStates', 'deviceState'])
@ -84,9 +88,10 @@ def cycle_alerts(duration=200, is_metric=False):
sm['liveCalibration'].rpyCalib = [-1 * random.random() for _ in range(random.randint(0, 3))] sm['liveCalibration'].rpyCalib = [-1 * random.random() for _ in range(random.randint(0, 3))]
for s in sm.data.keys(): for s in sm.data.keys():
sm.alive[s] = random.random() > 0.08 prob = 0.3 if s in cameras else 0.08
sm.valid[s] = random.random() > 0.08 sm.alive[s] = random.random() > prob
sm.freq_ok[s] = random.random() > 0.08 sm.valid[s] = random.random() > prob
sm.freq_ok[s] = random.random() > prob
a = events.create_alerts([et, ], [CP, CS, sm, is_metric, 0]) a = events.create_alerts([et, ], [CP, CS, sm, is_metric, 0])
AM.add_many(frame, a) AM.add_many(frame, a)

Loading…
Cancel
Save