|
|
@ -27,6 +27,10 @@ |
|
|
|
#define COLOR_YELLOW nvgRGBA(218, 202, 37, 255) |
|
|
|
#define COLOR_YELLOW nvgRGBA(218, 202, 37, 255) |
|
|
|
#define COLOR_RED nvgRGBA(201, 34, 49, 255) |
|
|
|
#define COLOR_RED nvgRGBA(201, 34, 49, 255) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int bdr_s = 30; |
|
|
|
|
|
|
|
const int header_h = 420; |
|
|
|
|
|
|
|
const int footer_h = 280; |
|
|
|
|
|
|
|
|
|
|
|
const int UI_FREQ = 20; // Hz
|
|
|
|
const int UI_FREQ = 20; // Hz
|
|
|
|
|
|
|
|
|
|
|
|
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; |
|
|
|
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; |
|
|
@ -47,7 +51,7 @@ typedef struct Rect { |
|
|
|
} |
|
|
|
} |
|
|
|
} Rect; |
|
|
|
} Rect; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct Alert { |
|
|
|
struct Alert { |
|
|
|
QString text1; |
|
|
|
QString text1; |
|
|
|
QString text2; |
|
|
|
QString text2; |
|
|
|
QString type; |
|
|
|
QString type; |
|
|
@ -56,38 +60,31 @@ typedef struct Alert { |
|
|
|
bool equal(const Alert &a2) { |
|
|
|
bool equal(const Alert &a2) { |
|
|
|
return text1 == a2.text1 && text2 == a2.text2 && type == a2.type; |
|
|
|
return text1 == a2.text1 && text2 == a2.text2 && type == a2.type; |
|
|
|
} |
|
|
|
} |
|
|
|
} Alert; |
|
|
|
|
|
|
|
|
|
|
|
static std::optional<Alert> get(const SubMaster &sm, uint64_t started_frame) { |
|
|
|
const Alert CONTROLS_WAITING_ALERT = {"openpilot Unavailable", "Waiting for controls to start", |
|
|
|
if (sm.updated("controlsState")) { |
|
|
|
"controlsWaiting", cereal::ControlsState::AlertSize::MID, |
|
|
|
const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); |
|
|
|
AudibleAlert::NONE}; |
|
|
|
return Alert{cs.getAlertText1().cStr(), cs.getAlertText2().cStr(), |
|
|
|
|
|
|
|
cs.getAlertType().cStr(), cs.getAlertSize(), |
|
|
|
const Alert CONTROLS_UNRESPONSIVE_ALERT = {"TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", |
|
|
|
cs.getAlertSound()}; |
|
|
|
"controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, |
|
|
|
} else if ((sm.frame - started_frame) > 5 * UI_FREQ) { |
|
|
|
AudibleAlert::CHIME_WARNING_REPEAT}; |
|
|
|
const int CONTROLS_TIMEOUT = 5; |
|
|
|
inline std::optional<Alert> get_alert(const SubMaster &sm, uint64_t started_frame) { |
|
|
|
// Handle controls timeout
|
|
|
|
const int CONTROLS_TIMEOUT = 5; |
|
|
|
if (sm.rcv_frame("controlsState") < started_frame) { |
|
|
|
|
|
|
|
// car is started, but controlsState hasn't been seen at all
|
|
|
|
if (sm.updated("controlsState")) { |
|
|
|
return Alert{"openpilot Unavailable", "Waiting for controls to start", |
|
|
|
const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); |
|
|
|
"controlsWaiting", cereal::ControlsState::AlertSize::MID, |
|
|
|
return Alert{cs.getAlertText1().cStr(), cs.getAlertText2().cStr(), cs.getAlertType().cStr(), |
|
|
|
AudibleAlert::NONE}; |
|
|
|
cs.getAlertSize(), cs.getAlertSound()}; |
|
|
|
} else if ((nanos_since_boot() - sm.rcv_time("controlsState")) / 1e9 > CONTROLS_TIMEOUT) { |
|
|
|
} else if ((sm.frame - started_frame) > 5 * UI_FREQ) { |
|
|
|
// car is started, but controls is lagging or died
|
|
|
|
// Handle controls timeout
|
|
|
|
return Alert{"TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", |
|
|
|
if (sm.rcv_frame("controlsState") < started_frame) { |
|
|
|
"controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, |
|
|
|
// car is started, but controlsState hasn't been seen at all
|
|
|
|
AudibleAlert::CHIME_WARNING_REPEAT}; |
|
|
|
return CONTROLS_WAITING_ALERT; |
|
|
|
} |
|
|
|
} else if ((nanos_since_boot() - sm.rcv_time("controlsState")) / 1e9 > CONTROLS_TIMEOUT) { |
|
|
|
|
|
|
|
// car is started, but controls is lagging or died
|
|
|
|
|
|
|
|
return CONTROLS_UNRESPONSIVE_ALERT; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return std::nullopt; |
|
|
|
} |
|
|
|
} |
|
|
|
return std::nullopt; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int bdr_s = 30; |
|
|
|
|
|
|
|
const int header_h = 420; |
|
|
|
|
|
|
|
const int footer_h = 280; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum UIStatus { |
|
|
|
typedef enum UIStatus { |
|
|
|
STATUS_DISENGAGED, |
|
|
|
STATUS_DISENGAGED, |
|
|
|