mirror of https://github.com/commaai/openpilot.git
ui: controls -> selfdrive (#33487)
* ui: controls -> selfdrive * lil more
This commit is contained in:
parent
922348f33d
commit
f6d5f8fccf
|
@ -19,34 +19,34 @@ void OnroadAlerts::clear() {
|
|||
}
|
||||
|
||||
OnroadAlerts::Alert OnroadAlerts::getAlert(const SubMaster &sm, uint64_t started_frame) {
|
||||
const cereal::SelfdriveState::Reader &cs = sm["selfdriveState"].getSelfdriveState();
|
||||
const uint64_t controls_frame = sm.rcv_frame("selfdriveState");
|
||||
const cereal::SelfdriveState::Reader &ss = sm["selfdriveState"].getSelfdriveState();
|
||||
const uint64_t selfdrive_frame = sm.rcv_frame("selfdriveState");
|
||||
|
||||
Alert a = {};
|
||||
if (controls_frame >= started_frame) { // Don't get old alert.
|
||||
a = {cs.getAlertText1().cStr(), cs.getAlertText2().cStr(),
|
||||
cs.getAlertType().cStr(), cs.getAlertSize(), cs.getAlertStatus()};
|
||||
if (selfdrive_frame >= started_frame) { // Don't get old alert.
|
||||
a = {ss.getAlertText1().cStr(), ss.getAlertText2().cStr(),
|
||||
ss.getAlertType().cStr(), ss.getAlertSize(), ss.getAlertStatus()};
|
||||
}
|
||||
|
||||
if (!sm.updated("selfdriveState") && (sm.frame - started_frame) > 5 * UI_FREQ) {
|
||||
const int CONTROLS_TIMEOUT = 5;
|
||||
const int controls_missing = (nanos_since_boot() - sm.rcv_time("selfdriveState")) / 1e9;
|
||||
const int SELFDRIVE_STATE_TIMEOUT = 5;
|
||||
const int ss_missing = (nanos_since_boot() - sm.rcv_time("selfdriveState")) / 1e9;
|
||||
|
||||
// Handle controls timeout
|
||||
if (controls_frame < started_frame) {
|
||||
// Handle selfdrive timeout
|
||||
if (selfdrive_frame < started_frame) {
|
||||
// car is started, but selfdriveState hasn't been seen at all
|
||||
a = {tr("openpilot Unavailable"), tr("Waiting for controls to start"),
|
||||
"controlsWaiting", cereal::SelfdriveState::AlertSize::MID,
|
||||
a = {tr("openpilot Unavailable"), tr("Waiting to start"),
|
||||
"selfdriveWaiting", cereal::SelfdriveState::AlertSize::MID,
|
||||
cereal::SelfdriveState::AlertStatus::NORMAL};
|
||||
} else if (controls_missing > CONTROLS_TIMEOUT && !Hardware::PC()) {
|
||||
// car is started, but controls is lagging or died
|
||||
if (cs.getEnabled() && (controls_missing - CONTROLS_TIMEOUT) < 10) {
|
||||
a = {tr("TAKE CONTROL IMMEDIATELY"), tr("Controls Unresponsive"),
|
||||
"controlsUnresponsive", cereal::SelfdriveState::AlertSize::FULL,
|
||||
} else if (ss_missing > SELFDRIVE_STATE_TIMEOUT && !Hardware::PC()) {
|
||||
// car is started, but selfdrive is lagging or died
|
||||
if (ss.getEnabled() && (ss_missing - SELFDRIVE_STATE_TIMEOUT) < 10) {
|
||||
a = {tr("TAKE CONTROL IMMEDIATELY"), tr("System Unresponsive"),
|
||||
"selfdriveUnresponsive", cereal::SelfdriveState::AlertSize::FULL,
|
||||
cereal::SelfdriveState::AlertStatus::CRITICAL};
|
||||
} else {
|
||||
a = {tr("Controls Unresponsive"), tr("Reboot Device"),
|
||||
"controlsUnresponsivePermanent", cereal::SelfdriveState::AlertSize::MID,
|
||||
a = {tr("System Unresponsive"), tr("Reboot Device"),
|
||||
"selfdriveUnresponsivePermanent", cereal::SelfdriveState::AlertSize::MID,
|
||||
cereal::SelfdriveState::AlertStatus::NORMAL};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
|||
const int SET_SPEED_NA = 255;
|
||||
const SubMaster &sm = *(s.sm);
|
||||
|
||||
const bool cs_alive = sm.alive("controlsState");
|
||||
const bool cs_alive = sm.alive("carState");
|
||||
const auto cs = sm["controlsState"].getControlsState();
|
||||
const auto car_state = sm["carState"].getCarState();
|
||||
|
||||
is_metric = s.scene.is_metric;
|
||||
|
||||
// Handle older routes where vCruiseCluster is not set
|
||||
// Handle older routes where vCruise was in controlsState
|
||||
float v_cruise = car_state.getVCruiseCluster() == 0.0 ? cs.getVCruiseDEPRECATED() : car_state.getVCruiseCluster();
|
||||
setSpeed = cs_alive ? v_cruise : SET_SPEED_NA;
|
||||
is_cruise_set = setSpeed > 0 && (int)setSpeed != SET_SPEED_NA;
|
||||
|
|
|
@ -17,7 +17,7 @@ SAMPLE_RATE = 48000
|
|||
SAMPLE_BUFFER = 4096 # (approx 100ms)
|
||||
MAX_VOLUME = 1.0
|
||||
MIN_VOLUME = 0.1
|
||||
CONTROLS_TIMEOUT = 5 # 5 seconds
|
||||
SELFDRIVE_STATE_TIMEOUT = 5 # 5 seconds
|
||||
FILTER_DT = 1. / (micd.SAMPLE_RATE / micd.FFT_SAMPLES)
|
||||
|
||||
AMBIENT_DB = 30 # DB where MIN_VOLUME is applied
|
||||
|
@ -40,11 +40,11 @@ sound_list: dict[int, tuple[str, int | None, float]] = {
|
|||
AudibleAlert.warningImmediate: ("warning_immediate.wav", None, MAX_VOLUME),
|
||||
}
|
||||
|
||||
def check_controls_timeout_alert(sm):
|
||||
controls_missing = time.monotonic() - sm.recv_time['selfdriveState']
|
||||
def check_selfdrive_timeout_alert(sm):
|
||||
ss_missing = time.monotonic() - sm.recv_time['selfdriveState']
|
||||
|
||||
if controls_missing > CONTROLS_TIMEOUT:
|
||||
if sm['selfdriveState'].enabled and (controls_missing - CONTROLS_TIMEOUT) < 10:
|
||||
if ss_missing > SELFDRIVE_STATE_TIMEOUT:
|
||||
if sm['selfdriveState'].enabled and (ss_missing - SELFDRIVE_STATE_TIMEOUT) < 10:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -58,7 +58,7 @@ class Soundd:
|
|||
self.current_volume = MIN_VOLUME
|
||||
self.current_sound_frame = 0
|
||||
|
||||
self.controls_timeout_alert = False
|
||||
self.selfdrive_timeout_alert = False
|
||||
|
||||
self.spl_filter_weighted = FirstOrderFilter(0, 2.5, FILTER_DT, initialized=False)
|
||||
|
||||
|
@ -114,12 +114,12 @@ class Soundd:
|
|||
if sm.updated['selfdriveState']:
|
||||
new_alert = sm['selfdriveState'].alertSound.raw
|
||||
self.update_alert(new_alert)
|
||||
elif check_controls_timeout_alert(sm):
|
||||
elif check_selfdrive_timeout_alert(sm):
|
||||
self.update_alert(AudibleAlert.warningImmediate)
|
||||
self.controls_timeout_alert = True
|
||||
elif self.controls_timeout_alert:
|
||||
self.selfdrive_timeout_alert = True
|
||||
elif self.selfdrive_timeout_alert:
|
||||
self.update_alert(AudibleAlert.none)
|
||||
self.controls_timeout_alert = False
|
||||
self.selfdrive_timeout_alert = False
|
||||
|
||||
def calculate_volume(self, weighted_db):
|
||||
volume = ((weighted_db - AMBIENT_DB) / DB_SCALE) * (MAX_VOLUME - MIN_VOLUME) + MIN_VOLUME
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from cereal import car
|
||||
from cereal import messaging
|
||||
from cereal.messaging import SubMaster, PubMaster
|
||||
from openpilot.selfdrive.ui.soundd import CONTROLS_TIMEOUT, check_controls_timeout_alert
|
||||
from openpilot.selfdrive.ui.soundd import SELFDRIVE_STATE_TIMEOUT, check_selfdrive_timeout_alert
|
||||
|
||||
import time
|
||||
|
||||
|
@ -9,7 +9,7 @@ AudibleAlert = car.CarControl.HUDControl.AudibleAlert
|
|||
|
||||
|
||||
class TestSoundd:
|
||||
def test_check_controls_timeout_alert(self):
|
||||
def test_check_selfdrive_timeout_alert(self):
|
||||
sm = SubMaster(['selfdriveState'])
|
||||
pm = PubMaster(['selfdriveState'])
|
||||
|
||||
|
@ -23,13 +23,13 @@ class TestSoundd:
|
|||
|
||||
sm.update(0)
|
||||
|
||||
assert not check_controls_timeout_alert(sm)
|
||||
assert not check_selfdrive_timeout_alert(sm)
|
||||
|
||||
for _ in range(CONTROLS_TIMEOUT * 110):
|
||||
for _ in range(SELFDRIVE_STATE_TIMEOUT * 110):
|
||||
sm.update(0)
|
||||
time.sleep(0.01)
|
||||
|
||||
assert check_controls_timeout_alert(sm)
|
||||
assert check_selfdrive_timeout_alert(sm)
|
||||
|
||||
# TODO: add test with micd for checking that soundd actually outputs sounds
|
||||
|
||||
|
|
|
@ -418,22 +418,22 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation>openpilot غير متوفر</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation>في انتظار بدء عناصر التحكم</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation>تحكم على الفور</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<translation>الضوابط غير مستجيبة</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<translation>إعادة التشغيل</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PairingPopup</name>
|
||||
|
|
|
@ -413,20 +413,20 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<source>Reboot Device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
|
|
@ -414,22 +414,22 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation>openpilot no disponible</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation>Esperando que los controles inicien</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation>TOME CONTROL INMEDIATAMENTE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<translation>Controles no responden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<translation>Reiniciar Dispositivo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PairingPopup</name>
|
||||
|
|
|
@ -414,20 +414,20 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<source>Reboot Device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
|
|
@ -412,20 +412,20 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<source>Reboot Device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
|
|
@ -413,22 +413,22 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation>오픈파일럿을 사용할수없습니다</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation>프로세스가 준비중입니다</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation>핸들을 잡아주세요</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<translation>프로세스가 응답하지않습니다</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<translation>장치를 재부팅하세요</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PairingPopup</name>
|
||||
|
|
|
@ -414,22 +414,22 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation>openpilot Indisponível</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation>Aguardando controles para iniciar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation>ASSUMA IMEDIATAMENTE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<translation>Controles Não Respondem</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<translation>Reinicie o Dispositivo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PairingPopup</name>
|
||||
|
|
|
@ -413,22 +413,22 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation>openpilot ไม่สามารถใช้งานได้</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation>กำลังรอให้ controls เริ่มทำงาน</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation>เข้าควบคุมรถเดี๋ยวนี้</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<translation>Controls ไม่ตอบสนอง</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<translation>รีบูตอุปกรณ์</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PairingPopup</name>
|
||||
|
|
|
@ -412,20 +412,20 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<source>Reboot Device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
|
|
@ -413,22 +413,22 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation>无法使用 openpilot</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation>等待控制服务啟動</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation>立即接管</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<translation>控制服务无响应</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<translation>重启设备</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PairingPopup</name>
|
||||
|
|
|
@ -413,22 +413,22 @@
|
|||
<source>openpilot Unavailable</source>
|
||||
<translation>無法使用 openpilot</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting for controls to start</source>
|
||||
<translation>等待操控服務開始</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TAKE CONTROL IMMEDIATELY</source>
|
||||
<translation>立即接管</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Controls Unresponsive</source>
|
||||
<translation>操控服務沒有反應</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reboot Device</source>
|
||||
<translation>請重新啟裝置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Waiting to start</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>System Unresponsive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PairingPopup</name>
|
||||
|
|
Loading…
Reference in New Issue