openpilot crashed alert

This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent 453ecd5891
commit c67fd46776
4 changed files with 24 additions and 3 deletions
+1
View File
@@ -123,6 +123,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
laneChangeBlockedLoud @123;
leadDeparting @124;
noLaneAvailable @125;
openpilotCrashed @126;
torqueNNLoad @130;
radarCanErrorDEPRECATED @15;
+9 -2
View File
@@ -7,6 +7,7 @@ from types import SimpleNamespace
from typing import SupportsFloat
import cereal.messaging as messaging
import openpilot.selfdrive.sentry as sentry
from cereal import car, log, custom
from cereal.visionipc import VisionIpcClient, VisionStreamType
@@ -179,6 +180,7 @@ class Controls:
self.driving_gear = False
self.previously_enabled = False
self.openpilot_crashed = False
self.stopped_for_light_previously = False
self.previous_lead_distance = 0
@@ -325,6 +327,11 @@ class Controls:
frogpilot_plan = self.sm['frogpilotPlan']
# Show crash log event if openpilot crashed
if os.path.isfile(os.path.join(sentry.CRASHES_DIR, 'error.txt')):
self.events.add(EventName.openpilotCrashed)
return
# Add joystick event, static on cars, dynamic on nonCars
if self.joystick_mode:
self.events.add(EventName.joystickDebug)
@@ -761,8 +768,8 @@ class Controls:
# Check which actuators can be enabled
standstill = CS.vEgo <= max(self.CP.minSteerSpeed, MIN_LATERAL_CONTROL_SPEED) or CS.standstill
CC.latActive = (self.active or self.FPCC.alwaysOnLateral) and not CS.steerFaultTemporary and not CS.steerFaultPermanent and \
(not standstill or self.joystick_mode)
CC.longActive = self.enabled and not self.events.contains(ET.OVERRIDE_LONGITUDINAL) and self.CP.openpilotLongitudinalControl
(not standstill or self.joystick_mode) and not self.openpilot_crashed
CC.longActive = self.enabled and not self.events.contains(ET.OVERRIDE_LONGITUDINAL) and self.CP.openpilotLongitudinalControl and not self.openpilot_crashed
actuators = CC.actuators
actuators.longControlState = self.LoC.long_control_state
+8
View File
@@ -1020,6 +1020,14 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = {
ET.PERMANENT: no_lane_available_alert,
},
EventName.openpilotCrashed: {
ET.PERMANENT: Alert(
"openpilot crashed",
"Please post the error log in the FrogPilot Discord!",
AlertStatus.normal, AlertSize.mid,
Priority.HIGH, VisualAlert.none, AudibleAlert.none, .1),
},
EventName.torqueNNLoad: {
ET.PERMANENT: torque_nn_load_alert,
},
+6 -1
View File
@@ -76,7 +76,12 @@ struct Alert {
const int controls_missing = (nanos_since_boot() - sm.rcv_time("controlsState")) / 1e9;
// Handle controls timeout
if (controls_frame < started_frame) {
if (std::ifstream("/data/community/crashes/error.txt")) {
alert = {"openpilot crashed", "Please post the error log in the FrogPilot Discord!",
"controlsWaiting", cereal::ControlsState::AlertSize::MID,
cereal::ControlsState::AlertStatus::NORMAL,
AudibleAlert::NONE};
} else if (controls_frame < started_frame) {
// car is started, but controlsState hasn't been seen at all
alert = {"openpilot Unavailable", "Waiting for controls to start",
"controlsWaiting", cereal::ControlsState::AlertSize::MID,