soundd: trigger timeout warning during MADS lateral-only (#1717)

* soundd: trigger timeout warning during MADS lateral-only

The selfdrive timeout alert (warningImmediate) only fires when
selfdriveState.enabled is True. During MADS lateral-only mode,
enabled is False even though the system is actively steering.

If selfdrived stops publishing while MADS lateral is active, the
driver gets no audible warning that steering has become unresponsive.

Add selfdriveStateSP to the SubMaster and check mads.active alongside
selfdriveState.enabled so the timeout alert fires whenever the system
is actuating steering.

* test_soundd: add MADS lateral-only timeout test

Test that the selfdrive timeout warning fires when selfdriveState.enabled
is False but selfdriveStateSP.mads.active is True.

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
Zeph
2026-02-25 01:00:07 -06:00
committed by GitHub
parent 7a43e2cb67
commit 538e1e8a9a
2 changed files with 30 additions and 4 deletions
+2 -2
View File
@@ -65,7 +65,7 @@ def check_selfdrive_timeout_alert(sm):
ss_missing = time.monotonic() - sm.recv_time['selfdriveState']
if ss_missing > SELFDRIVE_STATE_TIMEOUT:
if sm['selfdriveState'].enabled and (ss_missing - SELFDRIVE_STATE_TIMEOUT) < 10:
if (sm['selfdriveState'].enabled or sm['selfdriveStateSP'].mads.enabled) and (ss_missing - SELFDRIVE_STATE_TIMEOUT) < 10:
return True
return False
@@ -158,7 +158,7 @@ class Soundd(QuietMode):
# sounddevice must be imported after forking processes
import sounddevice as sd
sm = messaging.SubMaster(['selfdriveState', 'soundPressure'])
sm = messaging.SubMaster(['selfdriveState', 'selfdriveStateSP', 'soundPressure'])
with self.get_stream(sd) as stream:
rk = Ratekeeper(20)
+28 -2
View File
@@ -10,8 +10,8 @@ AudibleAlert = car.CarControl.HUDControl.AudibleAlert
class TestSoundd:
def test_check_selfdrive_timeout_alert(self):
sm = SubMaster(['selfdriveState'])
pm = PubMaster(['selfdriveState'])
sm = SubMaster(['selfdriveState', 'selfdriveStateSP'])
pm = PubMaster(['selfdriveState', 'selfdriveStateSP'])
for _ in range(100):
cs = messaging.new_message('selfdriveState')
@@ -31,5 +31,31 @@ class TestSoundd:
assert check_selfdrive_timeout_alert(sm)
def test_check_selfdrive_timeout_alert_mads_lateral_only(self):
sm = SubMaster(['selfdriveState', 'selfdriveStateSP'])
pm = PubMaster(['selfdriveState', 'selfdriveStateSP'])
for _ in range(100):
cs = messaging.new_message('selfdriveState')
cs.selfdriveState.enabled = False
ss_sp = messaging.new_message('selfdriveStateSP')
ss_sp.selfdriveStateSP.mads.enabled = True
pm.send("selfdriveState", cs)
pm.send("selfdriveStateSP", ss_sp)
time.sleep(0.01)
sm.update(0)
assert not check_selfdrive_timeout_alert(sm)
for _ in range(SELFDRIVE_STATE_TIMEOUT * 110):
sm.update(0)
time.sleep(0.01)
assert check_selfdrive_timeout_alert(sm)
# TODO: add test with micd for checking that soundd actually outputs sounds