Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,10 @@ struct AudioFeedback {
blockNum @1 :UInt16;
}

struct SoundRequest {
sound @0 :Car.CarControl.HUDControl.AudibleAlert;
}

struct Touch {
sec @0 :Int64;
usec @1 :Int64;
Expand Down Expand Up @@ -2537,6 +2541,8 @@ struct Event {
livestreamWideRoadEncodeData @121 :EncodeData;
livestreamDriverEncodeData @122 :EncodeData;

soundRequest @152 :SoundRequest;

# *********** Custom: reserved for forks ***********

# DO change the name of the field
Expand Down
1 change: 1 addition & 0 deletions cereal/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self, should_log: bool, frequency: float, decimation: Optional[int]
"rawAudioData": (False, 20.),
"bookmarkButton": (True, 0., 1),
"audioFeedback": (True, 0., 1),
"soundRequest": (False, 0.),
"roadEncodeData": (False, 20., None, QueueSize.BIG),
"driverEncodeData": (False, 20., None, QueueSize.BIG),
"wideRoadEncodeData": (False, 20., None, QueueSize.BIG),
Expand Down
7 changes: 4 additions & 3 deletions selfdrive/ui/soundd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import time
import wave


from cereal import car, messaging
from openpilot.common.basedir import BASEDIR
from openpilot.common.filter_simple import FirstOrderFilter
Expand Down Expand Up @@ -128,7 +127,9 @@ def update_alert(self, new_alert):
self.current_sound_frame = 0

def get_audible_alert(self, sm):
if sm.updated['selfdriveState']:
if sm.updated['soundRequest'] and sm['soundRequest'].sound.raw != AudibleAlert.none:
self.update_alert(sm['soundRequest'].sound.raw)
elif sm.updated['selfdriveState']:
new_alert = sm['selfdriveState'].alertSound.raw
self.update_alert(new_alert)
elif check_selfdrive_timeout_alert(sm):
Expand All @@ -153,7 +154,7 @@ def soundd_thread(self):
# sounddevice must be imported after forking processes
import sounddevice as sd

sm = messaging.SubMaster(['selfdriveState', 'soundPressure'])
sm = messaging.SubMaster(['selfdriveState', 'soundPressure', 'soundRequest'])

with self.get_stream(sd) as stream:
rk = Ratekeeper(20)
Expand Down
2 changes: 1 addition & 1 deletion system/athena/athenad.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def startStream(sdp: str) -> dict:
if cp_bytes is not None:
with car.CarParams.from_bytes(cp_bytes) as CP:
if CP.notCar:
bridge_services_in.append("testJoystick")
bridge_services_in += ["testJoystick", "soundRequest"]

body = StreamRequestBody(sdp, ["driver"], bridge_services_in, ["carState"])
try:
Expand Down
1 change: 0 additions & 1 deletion system/webrtc/webrtcd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3

import argparse
import asyncio
import contextlib
Expand Down
Loading