chestnut: fix offroad alert (#39056)

chestnut: fix offroad alert

(cherry picked from commit 948ad05c6ceb7eed4cd18eb75f048ddd3230e3c1)
This commit is contained in:
Daniel Koepping
2026-10-08 19:18:57 -07:00
committed by firestar5683
parent dd6b26bbba
commit ccd020a472
4 changed files with 11 additions and 3 deletions
@@ -26,7 +26,7 @@
"severity": 0
},
"Offroad_ChestnutNotDetected": {
"text": "Chestnut not detected. Check USB and 12V connections.",
"text": "Chestnut not detected. Check USB and 12V connections, then restart the car.",
"severity": 0
},
"Offroad_ChestnutOverheated": {
+2 -1
View File
@@ -172,6 +172,7 @@ class SelfdriveD:
big_failed = big_active is False or model_unavailable or (self.big_model_active and not chestnut_present)
if big_failed and not self.big_model_failed:
self.events.add(EventName.bigModelFailed)
self.big_model_ready_t = time.monotonic()
self.big_model_failed = big_failed
# soft disable if the big model fails
@@ -453,7 +454,7 @@ class SelfdriveD:
# TODO: fix simulator
if not SIMULATION or REPLAY:
if self.sm['modelV2'].frameDropPerc > 1:
if self.sm['modelV2'].frameDropPerc > 1 and not big_model_settling:
self.events.add(EventName.modeldLagging)
# Decrement personality on distance button press
+5 -1
View File
@@ -14,6 +14,7 @@ from openpilot.system.ui.lib.application import gui_app
from openpilot.common.hardware import HARDWARE, PC
from openpilot.common.hardware.usb import cable_connected, get_usb_state, is_chestnut_usb_id
from openpilot.selfdrive.modeld.helpers import chestnut_compiled
from openpilot.selfdrive.selfdrived.alertmanager import OFFROAD_ALERTS
BACKLIGHT_OFFROAD = 65 if HARDWARE.get_device_type() == "mici" else 50
PARAM_UPDATE_TIME = 1 / 5.0
@@ -90,6 +91,7 @@ class UIState:
self.chestnut_compiled: bool = chestnut_compiled()
self.chestnut_active: bool | None = None
self.chestnut_loading: bool = False
self.chestnut_alert: bool = False
self.usb_connected: bool = False
self.usb_connected_ts: float | None = None
self.usb_disconnected_ts: float | None = None
@@ -212,7 +214,8 @@ class UIState:
detected = self.sm["deviceState"].chestnutPresent
if not self.started:
self.chestnut_present = detected
self.chestnut_state = (ChestnutState.READY if detected and self.chestnut_compiled else
self.chestnut_state = (ChestnutState.FAILED if self.chestnut_alert else
ChestnutState.READY if detected and self.chestnut_compiled else
ChestnutState.UNCOMPILED if detected else ChestnutState.DISCONNECTED)
return
@@ -247,6 +250,7 @@ class UIState:
self.experimental_mode = self.params.get_bool("ExperimentalMode")
self.chestnut_active = self.params.get("ChestnutActive")
self.chestnut_loading = self.params.get_bool("ChestnutLoading")
self.chestnut_alert = any(self.params.get(k) is not None for k, a in OFFROAD_ALERTS.items() if k.startswith("Offroad_Chestnut") and a["severity"] >= 0)
now = time.monotonic()
if cable_connected():
self.usb_disconnected_ts = None
@@ -53,6 +53,8 @@ class ChestnutStatus:
if not offroad and self.usb_seen and len(devices) != 1:
self.usb_failed = True
if offroad and len(devices) == 1:
self.usb_failed = False
if not offroad and state is not None:
powered = state.supplyVoltage >= CHESTNUT_POWERED_VOLTAGE
@@ -74,6 +76,7 @@ class ChestnutStatus:
self.power_unavailable = False
self.power_lost = False
self.power_restored = False
self.model_failed = False
if state is not None:
gpu_limit = GPU_TEMP_LIMIT - (TEMP_HYSTERESIS if self.overheated else 0.)