|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
#pragma once |
|
|
|
|
|
|
|
|
|
#include <map> |
|
|
|
|
#include <memory> |
|
|
|
|
#include <string> |
|
|
|
|
|
|
|
|
@ -22,7 +21,6 @@ const int UI_HEADER_HEIGHT = 420; |
|
|
|
|
|
|
|
|
|
const int UI_FREQ = 20; // Hz
|
|
|
|
|
const int BACKLIGHT_OFFROAD = 50; |
|
|
|
|
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; |
|
|
|
|
|
|
|
|
|
const float MIN_DRAW_DISTANCE = 10.0; |
|
|
|
|
const float MAX_DRAW_DISTANCE = 100.0; |
|
|
|
@ -47,59 +45,6 @@ constexpr vec3 default_face_kpts_3d[] = { |
|
|
|
|
{18.02, -49.14, 8.00}, {6.36, -51.20, 8.00}, {-5.98, -51.20, 8.00}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct Alert { |
|
|
|
|
QString text1; |
|
|
|
|
QString text2; |
|
|
|
|
QString type; |
|
|
|
|
cereal::ControlsState::AlertSize size; |
|
|
|
|
cereal::ControlsState::AlertStatus status; |
|
|
|
|
AudibleAlert sound; |
|
|
|
|
|
|
|
|
|
bool equal(const Alert &a2) { |
|
|
|
|
return text1 == a2.text1 && text2 == a2.text2 && type == a2.type && sound == a2.sound; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Alert get(const SubMaster &sm, uint64_t started_frame) { |
|
|
|
|
const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); |
|
|
|
|
const uint64_t controls_frame = sm.rcv_frame("controlsState"); |
|
|
|
|
|
|
|
|
|
Alert alert = {}; |
|
|
|
|
if (controls_frame >= started_frame) { // Don't get old alert.
|
|
|
|
|
alert = {cs.getAlertText1().cStr(), cs.getAlertText2().cStr(), |
|
|
|
|
cs.getAlertType().cStr(), cs.getAlertSize(), |
|
|
|
|
cs.getAlertStatus(), |
|
|
|
|
cs.getAlertSound()}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!sm.updated("controlsState") && (sm.frame - started_frame) > 5 * UI_FREQ) { |
|
|
|
|
const int CONTROLS_TIMEOUT = 5; |
|
|
|
|
const int controls_missing = (nanos_since_boot() - sm.rcv_time("controlsState")) / 1e9; |
|
|
|
|
|
|
|
|
|
// Handle controls timeout
|
|
|
|
|
if (controls_frame < started_frame) { |
|
|
|
|
// car is started, but controlsState hasn't been seen at all
|
|
|
|
|
alert = {"openpilot Unavailable", "Waiting for controls to start", |
|
|
|
|
"controlsWaiting", cereal::ControlsState::AlertSize::MID, |
|
|
|
|
cereal::ControlsState::AlertStatus::NORMAL, |
|
|
|
|
AudibleAlert::NONE}; |
|
|
|
|
} 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) { |
|
|
|
|
alert = {"TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", |
|
|
|
|
"controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, |
|
|
|
|
cereal::ControlsState::AlertStatus::CRITICAL, |
|
|
|
|
AudibleAlert::WARNING_IMMEDIATE}; |
|
|
|
|
} else { |
|
|
|
|
alert = {"Controls Unresponsive", "Reboot Device", |
|
|
|
|
"controlsUnresponsivePermanent", cereal::ControlsState::AlertSize::MID, |
|
|
|
|
cereal::ControlsState::AlertStatus::NORMAL, |
|
|
|
|
AudibleAlert::NONE}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return alert; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
typedef enum UIStatus { |
|
|
|
|
STATUS_DISENGAGED, |
|
|
|
@ -123,11 +68,6 @@ const QColor bg_colors [] = { |
|
|
|
|
[STATUS_ENGAGED] = QColor(0x17, 0x86, 0x44, 0xf1), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static std::map<cereal::ControlsState::AlertStatus, QColor> alert_colors = { |
|
|
|
|
{cereal::ControlsState::AlertStatus::NORMAL, QColor(0x15, 0x15, 0x15, 0xf1)}, |
|
|
|
|
{cereal::ControlsState::AlertStatus::USER_PROMPT, QColor(0xDA, 0x6F, 0x25, 0xf1)}, |
|
|
|
|
{cereal::ControlsState::AlertStatus::CRITICAL, QColor(0xC9, 0x22, 0x31, 0xf1)}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
typedef struct UIScene { |
|
|
|
|
bool calibration_valid = false; |
|
|
|
|