Model switcher

Added model selector to swap between several different models on the fly.
This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent 46b0b80f47
commit ae99774cf3
14 changed files with 111 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
{"AggressiveAcceleration", "Aggressive Acceleration With Lead", "Increase acceleration aggressiveness when following a lead vehicle from a stop.", ""},
{"StoppingDistance", "Increased Stopping Distance", "Increase the stopping distance for a more comfortable stop.", ""},
{"Model", "Model Selector", "Choose your preferred openpilot model.", "../assets/offroad/icon_calibration.png"},
{"MTSCEnabled", "Map Turn Speed Control", "Slow down for anticipated curves detected by your downloaded maps.", "../frogpilot/assets/toggle_icons/icon_speed_map.png"},
};
@@ -176,6 +177,28 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil
} else if (param == "StoppingDistance") {
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 10, std::map<int, QString>(), this, false, " feet");
} else if (param == "Model") {
modelSelectorButton = new FrogPilotButtonIconControl(title, tr("SELECT"), desc, icon);
QStringList models = {"New Delhi (Default)", "Blue Diamond V1", "Blue Diamond V2", "Farmville", "New Lemon Pie"};
QObject::connect(modelSelectorButton, &FrogPilotButtonIconControl::clicked, this, [this, models]() {
int currentModel = params.getInt("Model");
QString currentModelLabel = models[currentModel];
QString selection = MultiOptionDialog::getSelection(tr("Select a driving model"), models, currentModelLabel, this);
if (!selection.isEmpty()) {
int selectedModel = models.indexOf(selection);
params.putInt("Model", selectedModel);
params.remove("CalibrationParams");
params.remove("LiveTorqueParameters");
modelSelectorButton->setValue(selection);
if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) {
Hardware::reboot();
}
}
});
modelSelectorButton->setValue(models[params.getInt("Model")]);
addItem(modelSelectorButton);
} else {
toggle = new ParamControl(param, title, desc, icon, this);
}
@@ -262,6 +285,7 @@ void FrogPilotControlsPanel::parentToggleClicked() {
aggressiveProfile->setVisible(false);
conditionalSpeedsImperial->setVisible(false);
conditionalSpeedsMetric->setVisible(false);
modelSelectorButton->setVisible(false);
standardProfile->setVisible(false);
relaxedProfile->setVisible(false);
@@ -272,6 +296,7 @@ void FrogPilotControlsPanel::hideSubToggles() {
aggressiveProfile->setVisible(false);
conditionalSpeedsImperial->setVisible(false);
conditionalSpeedsMetric->setVisible(false);
modelSelectorButton->setVisible(true);
standardProfile->setVisible(false);
relaxedProfile->setVisible(false);