sound: use log enum (#38246)

This commit is contained in:
ZwX1616
2026-06-26 13:55:30 -07:00
committed by GitHub
parent 5629b5a83d
commit 069506aa36
5 changed files with 29 additions and 12 deletions
+21 -2
View File
@@ -771,13 +771,28 @@ struct SelfdriveState {
alertStatus @5 :AlertStatus;
alertSize @6 :AlertSize;
alertType @7 :Text;
alertSound @8 :Car.CarControl.HUDControl.AudibleAlert;
alertSound @13 :AudibleAlert;
alertHudVisual @12 :Car.CarControl.HUDControl.VisualAlert;
# configurable driving settings
experimentalMode @10 :Bool;
personality @11 :LongitudinalPersonality;
enum AudibleAlert {
none @0;
engage @1;
disengage @2;
refuse @3;
warningSoft @4;
warningImmediate @5;
prompt @6;
promptRepeat @7;
promptDistracted @8;
}
enum OpenpilotState @0xdbe58b96d2d1ac61 {
disabled @0;
preEnabled @1;
@@ -798,6 +813,10 @@ struct SelfdriveState {
mid @2;
full @3;
}
deprecated :group {
alertSound @8 :Car.CarControl.HUDControl.AudibleAlert;
}
}
struct ControlsState @0x97ff69c53601abf1 {
@@ -918,7 +937,7 @@ struct ControlsState @0x97ff69c53601abf1 {
alertStatus @38 :SelfdriveState.AlertStatus;
alertSize @39 :SelfdriveState.AlertSize;
alertType @44 :Text;
alertSound2 @56 :Car.CarControl.HUDControl.AudibleAlert;
alertSound2 @56 :SelfdriveState.AudibleAlert;
engageable @41 :Bool; # can OP be engaged?
state @31 :SelfdriveState.OpenpilotState;
enabled @19 :Bool;
+3 -3
View File
@@ -19,7 +19,7 @@ from openpilot.common.hardware import HARDWARE
AlertSize = log.SelfdriveState.AlertSize
AlertStatus = log.SelfdriveState.AlertStatus
VisualAlert = car.CarControl.HUDControl.VisualAlert
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
AudibleAlert = log.SelfdriveState.AudibleAlert
EventName = log.OnroadEvent.EventName
@@ -118,7 +118,7 @@ class Alert:
alert_size: log.SelfdriveState.AlertSize,
priority: Priority,
visual_alert: car.CarControl.HUDControl.VisualAlert,
audible_alert: car.CarControl.HUDControl.AudibleAlert,
audible_alert: log.SelfdriveState.AudibleAlert,
duration: float,
creation_delay: float = 0.):
@@ -183,7 +183,7 @@ class ImmediateDisableAlert(Alert):
class EngagementAlert(Alert):
def __init__(self, audible_alert: car.CarControl.HUDControl.AudibleAlert):
def __init__(self, audible_alert: log.SelfdriveState.AudibleAlert):
super().__init__("", "",
AlertStatus.normal, AlertSize.none,
Priority.MID, VisualAlert.none,
@@ -1,6 +1,5 @@
import pyray as rl
from openpilot.cereal import log, messaging
from opendbc.car.structs import car
from msgq.visionipc import VisionStreamType
from openpilot.selfdrive.ui.mici.onroad.cameraview import CameraView
from openpilot.selfdrive.ui.mici.onroad.driver_state import DriverStateRenderer
@@ -105,7 +104,7 @@ class BaseDriverCameraDialog(Widget):
if self._pm is None:
return
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
AudibleAlert = log.SelfdriveState.AudibleAlert
ALERT_SOUNDS = {
'two': AudibleAlert.promptDistracted,
'three': AudibleAlert.warningImmediate,
+2 -3
View File
@@ -4,8 +4,7 @@ import time
import wave
from openpilot.cereal import messaging
from opendbc.car.structs import car
from openpilot.cereal import log, messaging
from openpilot.common.basedir import BASEDIR
from openpilot.common.filter_simple import FirstOrderFilter
from openpilot.common.realtime import Ratekeeper
@@ -31,7 +30,7 @@ if HARDWARE.get_device_type() == "tizi":
AMBIENT_DB = 30
VOLUME_BASE = 10
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
AudibleAlert = log.SelfdriveState.AudibleAlert
sound_list: dict[int, tuple[str, int | None, float]] = {
+2 -2
View File
@@ -1,11 +1,11 @@
from opendbc.car.structs import car
from openpilot.cereal import log
from openpilot.cereal import messaging
from openpilot.cereal.messaging import SubMaster, PubMaster
from openpilot.selfdrive.ui.soundd import SELFDRIVE_STATE_TIMEOUT, check_selfdrive_timeout_alert
import time
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
AudibleAlert = log.SelfdriveState.AudibleAlert
class TestSoundd: