mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-10 18:23:44 +08:00
Controls - Conditional Experimental Mode
Automatically switches to 'Experimental Mode' under predefined conditions.
This commit is contained in:
@@ -181,7 +181,13 @@ void TogglesPanel::updateToggles() {
|
||||
op_long_toggle->setVisible(CP.getExperimentalLongitudinalAvailable() && !is_release);
|
||||
if (hasLongitudinalControl(CP)) {
|
||||
// normal description and toggle
|
||||
experimental_mode_toggle->setEnabled(true);
|
||||
bool conditional_experimental = params.getBool("ConditionalExperimental");
|
||||
if (conditional_experimental) {
|
||||
params.putBool("ExperimentalMode", true);
|
||||
params.putBool("ExperimentalModeConfirmed", true);
|
||||
experimental_mode_toggle->refresh();
|
||||
}
|
||||
experimental_mode_toggle->setEnabled(!conditional_experimental);
|
||||
experimental_mode_toggle->setDescription(e2e_description);
|
||||
long_personality_setting->setEnabled(true);
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,7 @@ void OnroadAlerts::updateState(const UIState &s) {
|
||||
const UIScene &scene = s.scene;
|
||||
|
||||
showAOLStatusBar = scene.show_aol_status_bar;
|
||||
showCEMStatusBar = scene.show_cem_status_bar;
|
||||
}
|
||||
|
||||
void OnroadAlerts::clear() {
|
||||
@@ -72,7 +73,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
|
||||
int margin = 40;
|
||||
int radius = 30;
|
||||
int offset = showAOLStatusBar ? 25 : 0;
|
||||
int offset = showAOLStatusBar || showCEMStatusBar ? 25 : 0;
|
||||
if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
||||
margin = 0;
|
||||
radius = 0;
|
||||
|
||||
@@ -42,4 +42,5 @@ protected:
|
||||
|
||||
// FrogPilot variables
|
||||
bool showAOLStatusBar;
|
||||
bool showCEMStatusBar;
|
||||
};
|
||||
|
||||
@@ -287,7 +287,7 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
|
||||
if (rightHandDM && map_settings_btn->isEnabled()) {
|
||||
x -= 250;
|
||||
}
|
||||
offset += showAlwaysOnLateralStatusBar ? 25 : 0;
|
||||
offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar ? 25 : 0;
|
||||
int y = height() - offset;
|
||||
float opacity = dmActive ? 0.65 : 0.2;
|
||||
drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity);
|
||||
@@ -497,10 +497,15 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &painter, const UISce
|
||||
|
||||
alwaysOnLateralActive = scene.always_on_lateral_active;
|
||||
showAlwaysOnLateralStatusBar = scene.show_aol_status_bar;
|
||||
if (showAlwaysOnLateralStatusBar) {
|
||||
if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar) {
|
||||
drawStatusBar(painter);
|
||||
}
|
||||
|
||||
conditionalSpeed = scene.conditional_speed;
|
||||
conditionalSpeedLead = scene.conditional_speed_lead;
|
||||
conditionalStatus = scene.conditional_status;
|
||||
showConditionalExperimentalStatusBar = scene.show_cem_status_bar;
|
||||
|
||||
experimentalMode = scene.experimental_mode;
|
||||
|
||||
mapOpen = scene.map_open;
|
||||
@@ -531,8 +536,23 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
||||
p.setOpacity(1.0);
|
||||
p.drawRoundedRect(statusBarRect, 30, 30);
|
||||
|
||||
std::map<int, QString> conditionalStatusMap = {
|
||||
{0, tr("Conditional Experimental Mode ready")},
|
||||
{7, tr("Experimental Mode activated for") + (mapOpen ? tr(" low speed") : tr(" speed being less than ") + QString::number(conditionalSpeedLead) + (is_metric ? tr("kph") : tr("mph")))},
|
||||
{8, tr("Experimental Mode activated for") + (mapOpen ? tr(" low speed") : tr(" speed being less than ") + QString::number(conditionalSpeed) + (is_metric ? tr("kph") : tr("mph")))},
|
||||
{9, tr("Experimental Mode activated for turn") + (mapOpen ? "" : tr(" / lane change"))},
|
||||
{10, tr("Experimental Mode activated for intersection")},
|
||||
{11, tr("Experimental Mode activated for upcoming turn")},
|
||||
{12, tr("Experimental Mode activated for curve")},
|
||||
{13, tr("Experimental Mode activated for stopped lead")},
|
||||
{14, tr("Experimental Mode activated for slower lead")},
|
||||
{15, tr("Experimental Mode activated for stop light") + (mapOpen ? tr("") : tr(" or stop sign"))},
|
||||
};
|
||||
|
||||
if (alwaysOnLateralActive && showAlwaysOnLateralStatusBar) {
|
||||
newStatus = tr("Always On Lateral active") + (mapOpen ? "" : tr(". Press the \"Cruise Control\" button to disable"));
|
||||
} else if (showConditionalExperimentalStatusBar) {
|
||||
newStatus = conditionalStatusMap.at(conditionalStatus);
|
||||
}
|
||||
|
||||
if (newStatus != lastShownStatus) {
|
||||
|
||||
@@ -56,12 +56,16 @@ private:
|
||||
bool experimentalMode;
|
||||
bool mapOpen;
|
||||
bool showAlwaysOnLateralStatusBar;
|
||||
bool showConditionalExperimentalStatusBar;
|
||||
|
||||
float accelerationConversion;
|
||||
float distanceConversion;
|
||||
float speedConversion;
|
||||
|
||||
int alertSize;
|
||||
int conditionalSpeed;
|
||||
int conditionalSpeedLead;
|
||||
int conditionalStatus;
|
||||
|
||||
QString accelerationUnit;
|
||||
QString leadDistanceUnit;
|
||||
|
||||
@@ -273,6 +273,11 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) {
|
||||
bool always_on_lateral = params.getBool("AlwaysOnLateral");
|
||||
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");
|
||||
|
||||
scene.tethering_config = params.getInt("TetheringEnabled");
|
||||
if (scene.tethering_config == 2) {
|
||||
WifiManager(s).setTetheringEnabled(true);
|
||||
@@ -358,6 +363,7 @@ void UIState::update() {
|
||||
}
|
||||
|
||||
// FrogPilot variables that need to be constantly updated
|
||||
scene.conditional_status = scene.conditional_experimental && scene.enabled ? paramsMemory.getInt("CEStatus") : 0;
|
||||
}
|
||||
|
||||
void UIState::setPrimeType(PrimeType type) {
|
||||
|
||||
@@ -119,6 +119,7 @@ typedef struct UIScene {
|
||||
|
||||
// FrogPilot variables
|
||||
bool always_on_lateral_active;
|
||||
bool conditional_experimental;
|
||||
bool enabled;
|
||||
bool experimental_mode;
|
||||
bool map_open;
|
||||
@@ -126,9 +127,13 @@ typedef struct UIScene {
|
||||
bool parked;
|
||||
bool right_hand_drive;
|
||||
bool show_aol_status_bar;
|
||||
bool show_cem_status_bar;
|
||||
bool tethering_enabled;
|
||||
|
||||
int alert_size;
|
||||
int conditional_speed;
|
||||
int conditional_speed_lead;
|
||||
int conditional_status;
|
||||
int tethering_config;
|
||||
|
||||
} UIScene;
|
||||
|
||||
Reference in New Issue
Block a user