mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-15 17:32:06 +08:00
538e1e8a9a
* 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>
62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
from cereal import car
|
|
from cereal import messaging
|
|
from 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
|
|
|
|
|
|
class TestSoundd:
|
|
def test_check_selfdrive_timeout_alert(self):
|
|
sm = SubMaster(['selfdriveState', 'selfdriveStateSP'])
|
|
pm = PubMaster(['selfdriveState', 'selfdriveStateSP'])
|
|
|
|
for _ in range(100):
|
|
cs = messaging.new_message('selfdriveState')
|
|
cs.selfdriveState.enabled = True
|
|
|
|
pm.send("selfdriveState", cs)
|
|
|
|
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)
|
|
|
|
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
|
|
|