|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <map> |
|
|
|
#include <map> |
|
|
|
#include <memory> |
|
|
|
#include <memory> |
|
|
|
|
|
|
|
#include <optional> |
|
|
|
#include <string> |
|
|
|
#include <string> |
|
|
|
|
|
|
|
|
|
|
|
#include <QObject> |
|
|
|
#include <QObject> |
|
|
@ -26,6 +27,8 @@ |
|
|
|
#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 UI_FREQ = 20; // Hz
|
|
|
|
|
|
|
|
|
|
|
|
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; |
|
|
|
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: this is also hardcoded in common/transformations/camera.py
|
|
|
|
// TODO: this is also hardcoded in common/transformations/camera.py
|
|
|
@ -62,14 +65,30 @@ const Alert CONTROLS_WAITING_ALERT = {"openpilot Unavailable", "Waiting for cont |
|
|
|
const Alert CONTROLS_UNRESPONSIVE_ALERT = {"TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", |
|
|
|
const Alert CONTROLS_UNRESPONSIVE_ALERT = {"TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", |
|
|
|
"controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, |
|
|
|
"controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, |
|
|
|
AudibleAlert::CHIME_WARNING_REPEAT}; |
|
|
|
AudibleAlert::CHIME_WARNING_REPEAT}; |
|
|
|
const int CONTROLS_TIMEOUT = 5; |
|
|
|
inline std::optional<Alert> get_alert(const SubMaster &sm, uint64_t started_frame) { |
|
|
|
|
|
|
|
const int CONTROLS_TIMEOUT = 5; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sm.updated("controlsState")) { |
|
|
|
|
|
|
|
const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); |
|
|
|
|
|
|
|
return Alert{cs.getAlertText1().cStr(), cs.getAlertText2().cStr(), cs.getAlertType().cStr(), |
|
|
|
|
|
|
|
cs.getAlertSize(), cs.getAlertSound()}; |
|
|
|
|
|
|
|
} else if ((sm.frame - started_frame) > 5 * UI_FREQ) { |
|
|
|
|
|
|
|
// Handle controls timeout
|
|
|
|
|
|
|
|
if (sm.rcv_frame("controlsState") < started_frame) { |
|
|
|
|
|
|
|
// car is started, but controlsState hasn't been seen at all
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const int bdr_s = 30; |
|
|
|
const int bdr_s = 30; |
|
|
|
const int header_h = 420; |
|
|
|
const int header_h = 420; |
|
|
|
const int footer_h = 280; |
|
|
|
const int footer_h = 280; |
|
|
|
|
|
|
|
|
|
|
|
const int UI_FREQ = 20; // Hz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum UIStatus { |
|
|
|
typedef enum UIStatus { |
|
|
|
STATUS_DISENGAGED, |
|
|
|
STATUS_DISENGAGED, |
|
|
|
STATUS_ENGAGED, |
|
|
|
STATUS_ENGAGED, |
|
|
|