Alert when controls fails to start (#1750)

* alert when controls fails to start

* more friendly

* fix sound

* remove that

* just else

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 968443c545
commatwo_master
Adeeb Shihadeh 5 years ago committed by GitHub
parent f9cae2aa8f
commit dd3247d128
  1. 27
      selfdrive/ui/ui.cc

@ -510,6 +510,7 @@ static void ui_update(UIState *s) {
s->vision_connect_firstrun = false; s->vision_connect_firstrun = false;
s->controls_timeout = 6 * UI_FREQ;
s->alert_blinking_alpha = 1.0; s->alert_blinking_alpha = 1.0;
s->alert_blinked = false; s->alert_blinked = false;
} }
@ -853,22 +854,30 @@ int main(int argc, char* argv[]) {
s->sound.setVolume(fmin(MAX_VOLUME, MIN_VOLUME + s->scene.controls_state.getVEgo() / 5), 5); // up one notch every 5 m/s s->sound.setVolume(fmin(MAX_VOLUME, MIN_VOLUME + s->scene.controls_state.getVEgo() / 5), 5); // up one notch every 5 m/s
// If car is started and controlsState times out, display an alert
if (s->controls_timeout > 0) { if (s->controls_timeout > 0) {
s->controls_timeout--; s->controls_timeout--;
} else { } else if (s->started) {
if (s->started && s->controls_seen && s->scene.alert_text2 != "Controls Unresponsive") { if (!s->controls_seen) {
// car is started, but controlsState hasn't been seen at all
LOGE("Controls failed to start");
s->scene.alert_text1 = "openpilot Unavailable";
s->scene.alert_text2 = "Controls Failed to Start";
s->scene.alert_size = cereal::ControlsState::AlertSize::MID;
update_status(s, STATUS_WARNING);
} else {
// car is started, but controls is lagging or died
LOGE("Controls unresponsive"); LOGE("Controls unresponsive");
s->scene.alert_size = cereal::ControlsState::AlertSize::FULL;
update_status(s, STATUS_ALERT); if (s->scene.alert_text2 != "Controls Unresponsive") {
s->sound.play(AudibleAlert::CHIME_WARNING_REPEAT, 3); // loop sound 3 times
}
s->scene.alert_text1 = "TAKE CONTROL IMMEDIATELY"; s->scene.alert_text1 = "TAKE CONTROL IMMEDIATELY";
s->scene.alert_text2 = "Controls Unresponsive"; s->scene.alert_text2 = "Controls Unresponsive";
ui_draw_vision_alert(s, s->scene.alert_size, s->status, s->scene.alert_text1.c_str(), s->scene.alert_text2.c_str()); s->scene.alert_size = cereal::ControlsState::AlertSize::FULL;
update_status(s, STATUS_ALERT);
s->sound.play(AudibleAlert::CHIME_WARNING_REPEAT, 3); // loop sound 3 times
} }
s->controls_seen = false; ui_draw_vision_alert(s, s->scene.alert_size, s->status, s->scene.alert_text1.c_str(), s->scene.alert_text2.c_str());
} }
read_param_timeout(&s->is_metric, "IsMetric", &s->is_metric_timeout); read_param_timeout(&s->is_metric, "IsMetric", &s->is_metric_timeout);

Loading…
Cancel
Save