Controls - Conditional Experimental Mode - UI functions
This commit is contained in:
parent
89d28689ba
commit
28fb8de134
@ -171,7 +171,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
|||||||
|
|
||||||
int margin = 40;
|
int margin = 40;
|
||||||
int radius = 30;
|
int radius = 30;
|
||||||
int offset = scene.show_aol_status_bar ? 25 : 0;
|
int offset = scene.show_aol_status_bar || scene.show_cem_status_bar ? 25 : 0;
|
||||||
if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
||||||
margin = 0;
|
margin = 0;
|
||||||
radius = 0;
|
radius = 0;
|
||||||
@ -544,7 +544,7 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
|
|||||||
// base icon
|
// base icon
|
||||||
int offset = UI_BORDER_SIZE + btn_size / 2;
|
int offset = UI_BORDER_SIZE + btn_size / 2;
|
||||||
int x = rightHandDM ? width() - offset : offset;
|
int x = rightHandDM ? width() - offset : offset;
|
||||||
offset += showAlwaysOnLateralStatusBar ? 25 : 0;
|
offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar ? 25 : 0;
|
||||||
int y = height() - offset;
|
int y = height() - offset;
|
||||||
float opacity = dmActive ? 0.65 : 0.2;
|
float opacity = dmActive ? 0.65 : 0.2;
|
||||||
drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity);
|
drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity);
|
||||||
@ -752,13 +752,16 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets() {
|
|||||||
alwaysOnLateralActive = scene.always_on_lateral_active;
|
alwaysOnLateralActive = scene.always_on_lateral_active;
|
||||||
showAlwaysOnLateralStatusBar = scene.show_aol_status_bar;
|
showAlwaysOnLateralStatusBar = scene.show_aol_status_bar;
|
||||||
|
|
||||||
|
conditionalStatus = scene.conditional_status;
|
||||||
|
showConditionalExperimentalStatusBar = scene.show_cem_status_bar;
|
||||||
|
|
||||||
experimentalMode = scene.experimental_mode;
|
experimentalMode = scene.experimental_mode;
|
||||||
|
|
||||||
mapOpen = scene.map_open;
|
mapOpen = scene.map_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p) {
|
void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p) {
|
||||||
if (showAlwaysOnLateralStatusBar) {
|
if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar) {
|
||||||
drawStatusBar(p);
|
drawStatusBar(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,8 +792,30 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
|||||||
p.setOpacity(1.0);
|
p.setOpacity(1.0);
|
||||||
p.drawRoundedRect(statusBarRect, 30, 30);
|
p.drawRoundedRect(statusBarRect, 30, 30);
|
||||||
|
|
||||||
|
std::map<int, QString> conditionalStatusMap = {
|
||||||
|
{0, tr("Conditional Experimental Mode ready")},
|
||||||
|
{1, tr("Conditional Experimental overridden")},
|
||||||
|
{2, tr("Experimental Mode manually activated")},
|
||||||
|
{3, tr("Conditional Experimental overridden")},
|
||||||
|
{4, tr("Experimental Mode manually activated")},
|
||||||
|
{5, tr("Conditional Experimental overridden")},
|
||||||
|
{6, tr("Experimental Mode manually activated")},
|
||||||
|
{7, tr("Experimental Mode activated for") + (mapOpen ? tr(" intersection") : tr(" upcoming intersection"))},
|
||||||
|
{8, tr("Experimental Mode activated for") + (mapOpen ? tr(" turn") : tr(" upcoming turn"))},
|
||||||
|
{9, tr("Experimental Mode activated due to") + (mapOpen ? tr(" SLC") : tr(" no speed limit set"))},
|
||||||
|
{10, tr("Experimental Mode activated due to") + (mapOpen ? tr(" speed") : tr(" speed being less than ") + QString::number(scene.conditional_speed_lead) + (is_metric ? tr(" kph") : tr(" mph")))},
|
||||||
|
{11, tr("Experimental Mode activated due to") + (mapOpen ? tr(" speed") : tr(" speed being less than ") + QString::number(scene.conditional_speed) + (is_metric ? tr(" kph") : tr(" mph")))},
|
||||||
|
{12, tr("Experimental Mode activated for stopped lead")},
|
||||||
|
{13, tr("Experimental Mode activated for slower lead")},
|
||||||
|
{14, tr("Experimental Mode activated for turn") + (mapOpen ? "" : tr(" / lane change"))},
|
||||||
|
{15, tr("Experimental Mode activated for curve")},
|
||||||
|
{16, tr("Experimental Mode activated for stop") + (mapOpen ? "" : tr(" sign / stop light"))},
|
||||||
|
};
|
||||||
|
|
||||||
if (alwaysOnLateralActive && showAlwaysOnLateralStatusBar) {
|
if (alwaysOnLateralActive && showAlwaysOnLateralStatusBar) {
|
||||||
newStatus = tr("Always On Lateral active") + (mapOpen ? "" : tr(". Press the \"Cruise Control\" button to disable"));
|
newStatus = tr("Always On Lateral active") + (mapOpen ? "" : tr(". Press the \"Cruise Control\" button to disable"));
|
||||||
|
} else if (showConditionalExperimentalStatusBar) {
|
||||||
|
newStatus = conditionalStatusMap[status != STATUS_DISENGAGED ? conditionalStatus : 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStatus != lastShownStatus) {
|
if (newStatus != lastShownStatus) {
|
||||||
|
@ -122,12 +122,14 @@ private:
|
|||||||
bool experimentalMode;
|
bool experimentalMode;
|
||||||
bool mapOpen;
|
bool mapOpen;
|
||||||
bool showAlwaysOnLateralStatusBar;
|
bool showAlwaysOnLateralStatusBar;
|
||||||
|
bool showConditionalExperimentalStatusBar;
|
||||||
|
|
||||||
float accelerationConversion;
|
float accelerationConversion;
|
||||||
float distanceConversion;
|
float distanceConversion;
|
||||||
float speedConversion;
|
float speedConversion;
|
||||||
|
|
||||||
int alertSize;
|
int alertSize;
|
||||||
|
int conditionalStatus;
|
||||||
|
|
||||||
QString accelerationUnit;
|
QString accelerationUnit;
|
||||||
QString leadDistanceUnit;
|
QString leadDistanceUnit;
|
||||||
|
@ -263,6 +263,11 @@ void ui_update_frogpilot_params(UIState *s) {
|
|||||||
|
|
||||||
bool always_on_lateral = params.getBool("AlwaysOnLateral");
|
bool always_on_lateral = params.getBool("AlwaysOnLateral");
|
||||||
scene.show_aol_status_bar = always_on_lateral && !params.getBool("HideAOLStatusBar");
|
scene.show_aol_status_bar = always_on_lateral && !params.getBool("HideAOLStatusBar");
|
||||||
|
|
||||||
|
scene.conditional_experimental = scene.longitudinal_control && params.getBool("ConditionalExperimental");
|
||||||
|
scene.conditional_speed = scene.conditional_experimental ? params.getInt("CESpeed") : 0;
|
||||||
|
scene.conditional_speed_lead = scene.conditional_experimental ? params.getInt("CESpeedLead") : 0;
|
||||||
|
scene.show_cem_status_bar = scene.conditional_experimental && !params.getBool("HideCEMStatusBar");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIState::updateStatus() {
|
void UIState::updateStatus() {
|
||||||
@ -332,6 +337,7 @@ void UIState::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FrogPilot live variables that need to be constantly checked
|
// FrogPilot live variables that need to be constantly checked
|
||||||
|
scene.conditional_status = scene.conditional_experimental && scene.enabled ? paramsMemory.getInt("CEStatus") : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIState::setPrimeType(PrimeType type) {
|
void UIState::setPrimeType(PrimeType type) {
|
||||||
|
@ -183,6 +183,7 @@ typedef struct UIScene {
|
|||||||
|
|
||||||
// FrogPilot variables
|
// FrogPilot variables
|
||||||
bool always_on_lateral_active;
|
bool always_on_lateral_active;
|
||||||
|
bool conditional_experimental;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool experimental_mode;
|
bool experimental_mode;
|
||||||
bool map_open;
|
bool map_open;
|
||||||
@ -190,9 +191,13 @@ typedef struct UIScene {
|
|||||||
bool parked;
|
bool parked;
|
||||||
bool right_hand_drive;
|
bool right_hand_drive;
|
||||||
bool show_aol_status_bar;
|
bool show_aol_status_bar;
|
||||||
|
bool show_cem_status_bar;
|
||||||
bool tethering_enabled;
|
bool tethering_enabled;
|
||||||
|
|
||||||
int alert_size;
|
int alert_size;
|
||||||
|
int conditional_speed;
|
||||||
|
int conditional_speed_lead;
|
||||||
|
int conditional_status;
|
||||||
|
|
||||||
} UIScene;
|
} UIScene;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user