wip
This commit is contained in:
1090
selfdrive/frogpilot/ui/qt/offroad/control_settings.cc
Normal file
1090
selfdrive/frogpilot/ui/qt/offroad/control_settings.cc
Normal file
File diff suppressed because it is too large
Load Diff
73
selfdrive/frogpilot/ui/qt/offroad/control_settings.h
Normal file
73
selfdrive/frogpilot/ui/qt/offroad/control_settings.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.h"
|
||||
#include "selfdrive/ui/qt/offroad/settings.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
class FrogPilotControlsPanel : public FrogPilotListWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FrogPilotControlsPanel(SettingsWindow *parent);
|
||||
|
||||
signals:
|
||||
void openParentToggle();
|
||||
void openSubParentToggle();
|
||||
|
||||
private:
|
||||
void hideSubToggles();
|
||||
void hideToggles();
|
||||
void showEvent(QShowEvent *event, const UIState &s);
|
||||
void updateCarToggles();
|
||||
void updateMetric();
|
||||
void updateState(const UIState &s);
|
||||
void updateToggles();
|
||||
|
||||
ButtonControl *deleteModelBtn;
|
||||
ButtonControl *downloadModelBtn;
|
||||
ButtonControl *selectModelBtn;
|
||||
ButtonControl *slcPriorityButton;
|
||||
|
||||
FrogPilotDualParamControl *aggressiveProfile;
|
||||
FrogPilotDualParamControl *conditionalSpeedsImperial;
|
||||
FrogPilotDualParamControl *conditionalSpeedsMetric;
|
||||
FrogPilotDualParamControl *relaxedProfile;
|
||||
FrogPilotDualParamControl *standardProfile;
|
||||
FrogPilotDualParamControl *trafficProfile;
|
||||
|
||||
std::set<QString> aolKeys = {"AlwaysOnLateralMain", "HideAOLStatusBar", "PauseAOLOnBrake"};
|
||||
std::set<QString> conditionalExperimentalKeys = {"CECurves", "CECurvesLead", "CENavigation", "CESignal", "CESlowerLead", "CEStopLights", "HideCEMStatusBar"};
|
||||
std::set<QString> deviceManagementKeys = {"DeviceShutdown", "HigherBitrate", "IncreaseThermalLimits", "LowVoltageShutdown", "NoLogging", "NoUploads", "OfflineMode"};
|
||||
std::set<QString> experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaTap"};
|
||||
std::set<QString> laneChangeKeys = {"LaneChangeTime", "LaneDetectionWidth", "OneLaneChange"};
|
||||
std::set<QString> lateralTuneKeys = {"ForceAutoTune", "NNFF", "NNFFLite", "SteerRatio", "TacoTune", "TurnDesires"};
|
||||
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "AggressiveAcceleration", "DecelerationProfile", "LeadDetectionThreshold", "SmoothBraking", "StoppingDistance", "TrafficMode"};
|
||||
std::set<QString> mtscKeys = {"DisableMTSCSmoothing", "MTSCAggressiveness", "MTSCCurvatureCheck"};
|
||||
std::set<QString> qolKeys = {"CustomCruise", "CustomCruiseLong", "DisableOnroadUploads", "OnroadDistanceButton", "PauseLateralSpeed", "ReverseCruise", "SetSpeedOffset"};
|
||||
std::set<QString> speedLimitControllerKeys = {"SLCControls", "SLCQOL", "SLCVisuals"};
|
||||
std::set<QString> speedLimitControllerControlsKeys = {"Offset1", "Offset2", "Offset3", "Offset4", "SLCFallback", "SLCOverride", "SLCPriority"};
|
||||
std::set<QString> speedLimitControllerQOLKeys = {"ForceMPHDashboard", "SetSpeedLimit", "SLCConfirmation", "SLCLookaheadHigher", "SLCLookaheadLower"};
|
||||
std::set<QString> speedLimitControllerVisualsKeys = {"ShowSLCOffset", "SpeedLimitChangedAlert", "UseVienna"};
|
||||
std::set<QString> tuningKeys = {"kiV1", "kiV2", "kiV3", "kiV4", "kpV1", "kpV2", "kpV3", "kpV4"};
|
||||
std::set<QString> visionTurnControlKeys = {"CurveSensitivity", "DisableVTSCSmoothing", "TurnAggressiveness"};
|
||||
|
||||
std::map<std::string, ParamControl*> toggles;
|
||||
|
||||
Params params;
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
|
||||
bool hasAutoTune;
|
||||
bool hasCommaNNFFSupport;
|
||||
bool hasNNFFLog;
|
||||
bool hasOpenpilotLongitudinal;
|
||||
bool hasPCMCruise;
|
||||
bool hasDashSpeedLimits;
|
||||
bool isMetric = params.getBool("IsMetric");
|
||||
bool isRelease;
|
||||
bool isToyota;
|
||||
bool started;
|
||||
|
||||
float steerRatioStock;
|
||||
};
|
||||
302
selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc
Normal file
302
selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.cc
Normal file
@@ -0,0 +1,302 @@
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h"
|
||||
|
||||
QStringList getCarNames(const QString &carMake) {
|
||||
QMap<QString, QString> makeMap;
|
||||
makeMap["acura"] = "honda";
|
||||
makeMap["audi"] = "volkswagen";
|
||||
makeMap["buick"] = "gm";
|
||||
makeMap["cadillac"] = "gm";
|
||||
makeMap["chevrolet"] = "gm";
|
||||
makeMap["chrysler"] = "chrysler";
|
||||
makeMap["dodge"] = "chrysler";
|
||||
makeMap["ford"] = "ford";
|
||||
makeMap["gm"] = "gm";
|
||||
makeMap["gmc"] = "gm";
|
||||
makeMap["genesis"] = "hyundai";
|
||||
makeMap["honda"] = "honda";
|
||||
makeMap["hyundai"] = "hyundai";
|
||||
makeMap["infiniti"] = "nissan";
|
||||
makeMap["jeep"] = "chrysler";
|
||||
makeMap["kia"] = "hyundai";
|
||||
makeMap["lexus"] = "toyota";
|
||||
makeMap["lincoln"] = "ford";
|
||||
makeMap["man"] = "volkswagen";
|
||||
makeMap["mazda"] = "mazda";
|
||||
makeMap["nissan"] = "nissan";
|
||||
makeMap["ram"] = "chrysler";
|
||||
makeMap["seat"] = "volkswagen";
|
||||
makeMap["škoda"] = "volkswagen";
|
||||
makeMap["subaru"] = "subaru";
|
||||
makeMap["tesla"] = "tesla";
|
||||
makeMap["toyota"] = "toyota";
|
||||
makeMap["volkswagen"] = "volkswagen";
|
||||
|
||||
QString dirPath = "../car";
|
||||
QDir dir(dirPath);
|
||||
QString targetFolder = makeMap.value(carMake, carMake);
|
||||
QStringList names;
|
||||
|
||||
QString filePath = dir.absoluteFilePath(targetFolder + "/values.py");
|
||||
QFile file(filePath);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&file);
|
||||
QRegularExpression regex(R"delimiter(\w+\s*=\s*\w+PlatformConfig\(\s*"([^"]+)",)delimiter");
|
||||
QRegularExpressionMatchIterator it = regex.globalMatch(in.readAll());
|
||||
while (it.hasNext()) {
|
||||
QRegularExpressionMatch match = it.next();
|
||||
names << match.captured(1);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
std::sort(names.begin(), names.end());
|
||||
return names;
|
||||
}
|
||||
|
||||
FrogPilotVehiclesPanel::FrogPilotVehiclesPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
|
||||
selectMakeButton = new ButtonControl(tr("Select Make"), tr("SELECT"));
|
||||
QObject::connect(selectMakeButton, &ButtonControl::clicked, [this]() {
|
||||
QStringList makes = {
|
||||
"Acura", "Audi", "BMW", "Buick", "Cadillac", "Chevrolet", "Chrysler", "Dodge", "Ford", "GM", "GMC",
|
||||
"Genesis", "Honda", "Hyundai", "Infiniti", "Jeep", "Kia", "Lexus", "Lincoln", "MAN", "Mazda",
|
||||
"Mercedes", "Nissan", "Ram", "SEAT", "Škoda", "Subaru", "Tesla", "Toyota", "Volkswagen", "Volvo",
|
||||
};
|
||||
|
||||
QString newMakeSelection = MultiOptionDialog::getSelection(tr("Select a Make"), makes, "", this);
|
||||
if (!newMakeSelection.isEmpty()) {
|
||||
carMake = newMakeSelection;
|
||||
params.putNonBlocking("CarMake", carMake.toStdString());
|
||||
selectMakeButton->setValue(newMakeSelection);
|
||||
setModels();
|
||||
}
|
||||
});
|
||||
addItem(selectMakeButton);
|
||||
|
||||
selectModelButton = new ButtonControl(tr("Select Model"), tr("SELECT"));
|
||||
QString modelSelection = QString::fromStdString(params.get("CarModel"));
|
||||
QObject::connect(selectModelButton, &ButtonControl::clicked, [this]() {
|
||||
QString newModelSelection = MultiOptionDialog::getSelection(tr("Select a Model"), models, "", this);
|
||||
if (!newModelSelection.isEmpty()) {
|
||||
params.putNonBlocking("CarModel", newModelSelection.toStdString());
|
||||
selectModelButton->setValue(newModelSelection);
|
||||
}
|
||||
});
|
||||
selectModelButton->setValue(modelSelection);
|
||||
addItem(selectModelButton);
|
||||
selectModelButton->setVisible(false);
|
||||
|
||||
ParamControl *forceFingerprint = new ParamControl("ForceFingerprint", tr("Disable Automatic Fingerprint Detection"), tr("Forces the selected fingerprint and prevents it from ever changing."), "", this);
|
||||
addItem(forceFingerprint);
|
||||
|
||||
bool disableOpenpilotLongState = params.getBool("DisableOpenpilotLongitudinal");
|
||||
disableOpenpilotLong = new ToggleControl(tr("Disable openpilot Longitudinal Control"), tr("Disable openpilot longitudinal control and use stock ACC instead."), "", disableOpenpilotLongState);
|
||||
QObject::connect(disableOpenpilotLong, &ToggleControl::toggleFlipped, [=](bool state) {
|
||||
if (state) {
|
||||
if (FrogPilotConfirmationDialog::yesorno(tr("Are you sure you want to completely disable openpilot longitudinal control?"), this)) {
|
||||
params.putBool("DisableOpenpilotLongitudinal", state);
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle(tr("Reboot required to take effect."), tr("Reboot Now"), this)) {
|
||||
Hardware::reboot();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
params.putBool("DisableOpenpilotLongitudinal", state);
|
||||
}
|
||||
updateCarToggles();
|
||||
});
|
||||
addItem(disableOpenpilotLong);
|
||||
|
||||
std::vector<std::tuple<QString, QString, QString, QString>> vehicleToggles {
|
||||
{"EVTable", tr("EV Lookup Tables"), tr("Smoothen out the gas and brake controls for EV vehicles."), ""},
|
||||
{"LongPitch", tr("Long Pitch Compensation"), tr("Smoothen out the gas and pedal controls."), ""},
|
||||
{"GasRegenCmd", tr("Truck Tune"), tr("Increase the acceleration and smoothen out the brake control when coming to a stop. For use on Silverado/Sierra only."), ""},
|
||||
|
||||
{"CrosstrekTorque", tr("Subaru Crosstrek Torque Increase"), tr("Increases the maximum allowed torque for the Subaru Crosstrek."), ""},
|
||||
|
||||
{"ToyotaDoors", tr("Automatically Lock/Unlock Doors"), tr("Automatically lock the doors when in drive and unlock when in park."), ""},
|
||||
{"LongitudinalTune", tr("Longitudinal Tune"), tr("Use a custom Toyota longitudinal tune.\n\nCydia = More focused on TSS-P vehicles but works for all Toyotas\n\nDragonPilot = Focused on TSS2 vehicles\n\nFrogPilot = Takes the best of both worlds with some personal tweaks focused around FrogsGoMoo's 2019 Lexus ES 350"), ""},
|
||||
{"SNGHack", tr("Stop and Go Hack"), tr("Enable the 'Stop and Go' hack for vehicles without stock stop and go functionality."), ""},
|
||||
};
|
||||
|
||||
for (const auto &[param, title, desc, icon] : vehicleToggles) {
|
||||
ParamControl *toggle;
|
||||
|
||||
if (param == "LongitudinalTune") {
|
||||
std::vector<std::pair<QString, QString>> tuneOptions{
|
||||
{"StockTune", tr("Stock")},
|
||||
{"CydiaTune", tr("Cydia")},
|
||||
{"DragonPilotTune", tr("DragonPilot")},
|
||||
{"FrogsGoMooTune", tr("FrogPilot")},
|
||||
};
|
||||
toggle = new FrogPilotButtonsParamControl(param, title, desc, icon, tuneOptions);
|
||||
|
||||
QObject::connect(static_cast<FrogPilotButtonsParamControl*>(toggle), &FrogPilotButtonsParamControl::buttonClicked, [this]() {
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle(tr("Reboot required to take effect."), tr("Reboot Now"), this)) {
|
||||
Hardware::soft_reboot();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else if (param == "ToyotaDoors") {
|
||||
std::vector<QString> lockToggles{"LockDoors", "UnlockDoors"};
|
||||
std::vector<QString> lockToggleNames{tr("Lock"), tr("Unlock")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, lockToggles, lockToggleNames);
|
||||
|
||||
} else {
|
||||
toggle = new ParamControl(param, title, desc, icon, this);
|
||||
}
|
||||
|
||||
toggle->setVisible(false);
|
||||
addItem(toggle);
|
||||
toggles[param.toStdString()] = toggle;
|
||||
|
||||
QObject::connect(toggle, &ToggleControl::toggleFlipped, [this]() {
|
||||
updateToggles();
|
||||
});
|
||||
|
||||
QObject::connect(toggle, &AbstractControl::showDescriptionEvent, [this]() {
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
std::set<QString> rebootKeys = {"CrosstrekTorque", "GasRegenCmd"};
|
||||
for (const QString &key : rebootKeys) {
|
||||
QObject::connect(toggles[key.toStdString().c_str()], &ToggleControl::toggleFlipped, [this]() {
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle(tr("Reboot required to take effect."), tr("Reboot Now"), this)) {
|
||||
Hardware::soft_reboot();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, [this](bool offroad) {
|
||||
std::thread([this]() {
|
||||
while (carMake.isEmpty()) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
carMake = QString::fromStdString(params.get("CarMake"));
|
||||
}
|
||||
setModels();
|
||||
updateCarToggles();
|
||||
}).detach();
|
||||
});
|
||||
|
||||
QObject::connect(uiState(), &UIState::uiUpdate, this, &FrogPilotVehiclesPanel::updateState);
|
||||
|
||||
carMake = QString::fromStdString(params.get("CarMake"));
|
||||
if (!carMake.isEmpty()) {
|
||||
setModels();
|
||||
}
|
||||
}
|
||||
|
||||
void FrogPilotVehiclesPanel::updateState(const UIState &s) {
|
||||
if (!isVisible()) return;
|
||||
|
||||
started = s.scene.started;
|
||||
}
|
||||
|
||||
void FrogPilotVehiclesPanel::updateToggles() {
|
||||
std::thread([this]() {
|
||||
paramsMemory.putBool("FrogPilotTogglesUpdated", true);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
paramsMemory.putBool("FrogPilotTogglesUpdated", false);
|
||||
}).detach();
|
||||
}
|
||||
|
||||
void FrogPilotVehiclesPanel::updateCarToggles() {
|
||||
std::set<std::string> evCars = {
|
||||
"CHEVROLET BOLT EUV 2022",
|
||||
"CHEVROLET BOLT EV NO ACC",
|
||||
"CHEVROLET VOLT NO ACC",
|
||||
"CHEVROLET VOLT PREMIER 2017",
|
||||
};
|
||||
|
||||
auto carParams = params.get("CarParamsPersistent");
|
||||
if (!carParams.empty()) {
|
||||
AlignedBuffer aligned_buf;
|
||||
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(carParams.data(), carParams.size()));
|
||||
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
|
||||
|
||||
auto carFingerprint = CP.getCarFingerprint();
|
||||
|
||||
hasExperimentalOpenpilotLongitudinal = CP.getExperimentalLongitudinalAvailable();
|
||||
hasOpenpilotLongitudinal = CP.getOpenpilotLongitudinalControl();
|
||||
hasSNG = CP.getMinEnableSpeed() <= 0;
|
||||
isEVCar = evCars.count(carFingerprint) > 0;
|
||||
isGMTruck = carFingerprint == "CHEVROLET SILVERADO 1500 2020";
|
||||
isImpreza = carFingerprint == "SUBARU IMPREZA LIMITED 2019";
|
||||
} else {
|
||||
hasExperimentalOpenpilotLongitudinal = false;
|
||||
hasOpenpilotLongitudinal = true;
|
||||
hasSNG = false;
|
||||
isEVCar = true;
|
||||
isGMTruck = true;
|
||||
isImpreza = true;
|
||||
}
|
||||
|
||||
hideToggles();
|
||||
}
|
||||
|
||||
void FrogPilotVehiclesPanel::setModels() {
|
||||
models = getCarNames(carMake.toLower());
|
||||
hideToggles();
|
||||
}
|
||||
|
||||
void FrogPilotVehiclesPanel::hideToggles() {
|
||||
disableOpenpilotLong->setVisible(hasOpenpilotLongitudinal && !hasExperimentalOpenpilotLongitudinal && !params.getBool("HideDisableOpenpilotLongitudinal"));
|
||||
|
||||
selectMakeButton->setValue(carMake);
|
||||
selectModelButton->setVisible(!carMake.isEmpty());
|
||||
|
||||
bool gm = carMake == "Buick" || carMake == "Cadillac" || carMake == "Chevrolet" || carMake == "GM" || carMake == "GMC";
|
||||
bool subaru = carMake == "Subaru";
|
||||
bool toyota = carMake == "Lexus" || carMake == "Toyota";
|
||||
|
||||
std::set<QString> evCarKeys = {"EVTable"};
|
||||
std::set<QString> gmTruckKeys = {"GasRegenCmd"};
|
||||
std::set<QString> imprezaKeys = {"CrosstrekTorque"};
|
||||
std::set<QString> longitudinalKeys = {"EVTable", "GasRegenCmd", "LongitudinalTune", "LongPitch", "SNGHack"};
|
||||
std::set<QString> sngKeys = {"SNGHack"};
|
||||
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
if (toggle) {
|
||||
toggle->setVisible(false);
|
||||
|
||||
if ((!hasOpenpilotLongitudinal || params.getBool("DisableOpenpilotLongitudinal")) && longitudinalKeys.find(key.c_str()) != longitudinalKeys.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasSNG && sngKeys.find(key.c_str()) != sngKeys.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isEVCar && evCarKeys.find(key.c_str()) != evCarKeys.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isGMTruck && gmTruckKeys.find(key.c_str()) != gmTruckKeys.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isImpreza && imprezaKeys.find(key.c_str()) != imprezaKeys.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gm) {
|
||||
toggle->setVisible(gmKeys.find(key.c_str()) != gmKeys.end());
|
||||
} else if (subaru) {
|
||||
toggle->setVisible(subaruKeys.find(key.c_str()) != subaruKeys.end());
|
||||
} else if (toyota) {
|
||||
toggle->setVisible(toyotaKeys.find(key.c_str()) != toyotaKeys.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
48
selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h
Normal file
48
selfdrive/frogpilot/ui/qt/offroad/vehicle_settings.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.h"
|
||||
#include "selfdrive/ui/qt/offroad/settings.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
class FrogPilotVehiclesPanel : public FrogPilotListWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FrogPilotVehiclesPanel(SettingsWindow *parent);
|
||||
|
||||
private:
|
||||
void hideToggles();
|
||||
void setModels();
|
||||
void updateCarToggles();
|
||||
void updateState(const UIState &s);
|
||||
void updateToggles();
|
||||
|
||||
ButtonControl *selectMakeButton;
|
||||
ButtonControl *selectModelButton;
|
||||
|
||||
ToggleControl *disableOpenpilotLong;
|
||||
|
||||
QString carMake;
|
||||
QStringList models;
|
||||
|
||||
std::set<QString> gmKeys = {"EVTable", "GasRegenCmd", "LongPitch"};
|
||||
std::set<QString> subaruKeys = {"CrosstrekTorque"};
|
||||
std::set<QString> toyotaKeys = {"LongitudinalTune", "SNGHack", "ToyotaDoors"};
|
||||
|
||||
std::map<std::string, ParamControl*> toggles;
|
||||
|
||||
Params params;
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
|
||||
bool hasExperimentalOpenpilotLongitudinal;
|
||||
bool hasOpenpilotLongitudinal;
|
||||
bool hasSNG;
|
||||
bool isEVCar;
|
||||
bool isGMTruck;
|
||||
bool isImpreza;
|
||||
bool started;
|
||||
};
|
||||
394
selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc
Normal file
394
selfdrive/frogpilot/ui/qt/offroad/visual_settings.cc
Normal file
@@ -0,0 +1,394 @@
|
||||
#include "selfdrive/frogpilot/ui/qt/offroad/visual_settings.h"
|
||||
|
||||
FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
|
||||
std::string branch = params.get("GitBranch");
|
||||
isRelease = branch == "FrogPilot";
|
||||
|
||||
const std::vector<std::tuple<QString, QString, QString, QString>> visualToggles {
|
||||
{"AlertVolumeControl", tr("Alert Volume Controller"), tr("Control the volume level for each individual sound in openpilot."), "../frogpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"DisengageVolume", tr("Disengage Volume"), tr("Related alerts:\n\nAdaptive Cruise Disabled\nParking Brake Engaged\nBrake Pedal Pressed\nSpeed too Low"), ""},
|
||||
{"EngageVolume", tr("Engage Volume"), tr("Related alerts:\n\nNNFF Torque Controller loaded\nopenpilot engaged"), ""},
|
||||
{"PromptVolume", tr("Prompt Volume"), tr("Related alerts:\n\nCar Detected in Blindspot\nSpeed too Low\nSteer Unavailable Below 'X'\nTake Control, Turn Exceeds Steering Limit"), ""},
|
||||
{"PromptDistractedVolume", tr("Prompt Distracted Volume"), tr("Related alerts:\n\nPay Attention, Driver Distracted\nTouch Steering Wheel, Driver Unresponsive"), ""},
|
||||
{"RefuseVolume", tr("Refuse Volume"), tr("Related alerts:\n\nopenpilot Unavailable"), ""},
|
||||
{"WarningSoftVolume", tr("Warning Soft Volume"), tr("Related alerts:\n\nBRAKE!, Risk of Collision\nTAKE CONTROL IMMEDIATELY"), ""},
|
||||
{"WarningImmediateVolume", tr("Warning Immediate Volume"), tr("Related alerts:\n\nDISENGAGE IMMEDIATELY, Driver Distracted\nDISENGAGE IMMEDIATELY, Driver Unresponsive"), ""},
|
||||
|
||||
{"CustomAlerts", tr("Custom Alerts"), tr("Enable custom alerts for openpilot events."), "../frogpilot/assets/toggle_icons/icon_green_light.png"},
|
||||
{"GreenLightAlert", tr("Green Light Alert"), tr("Get an alert when a traffic light changes from red to green."), ""},
|
||||
{"LeadDepartingAlert", tr("Lead Departing Alert"), tr("Get an alert when the lead vehicle starts departing when at a standstill."), ""},
|
||||
{"LoudBlindspotAlert", tr("Loud Blindspot Alert"), tr("Enable a louder alert for when a vehicle is detected in the blindspot when attempting to change lanes."), ""},
|
||||
|
||||
{"CustomUI", tr("Custom Onroad UI"), tr("Customize the Onroad UI."), "../assets/offroad/icon_road.png"},
|
||||
{"Compass", tr("Compass"), tr("Add a compass to the onroad UI."), ""},
|
||||
{"DeveloperUI", tr("Developer UI"), tr("Get various detailed information of what openpilot is doing behind the scenes."), ""},
|
||||
{"FPSCounter", tr("FPS Counter"), tr("Display the 'Frames Per Second' (FPS) of your onroad UI for monitoring system performance."), ""},
|
||||
{"LeadInfo", tr("Lead Info and Logics"), tr("Get detailed information about the vehicle ahead, including speed and distance, and the logic behind your following distance."), ""},
|
||||
{"CustomPaths", tr("Paths"), tr("Show your projected acceleration on the driving path, detected adjacent lanes, or when a vehicle is detected in your blindspot."), ""},
|
||||
{"PedalsOnUI", tr("Pedals Being Pressed"), tr("Display the brake and gas pedals on the onroad UI below the steering wheel icon."), ""},
|
||||
{"RoadNameUI", tr("Road Name"), tr("Display the current road's name at the bottom of the screen. Sourced from OpenStreetMap."), ""},
|
||||
{"WheelIcon", tr("Steering Wheel Icon"), tr("Replace the default steering wheel icon with a custom icon."), ""},
|
||||
|
||||
{"CustomTheme", tr("Custom Themes"), tr("Enable the ability to use custom themes."), "../frogpilot/assets/wheel_images/frog.png"},
|
||||
{"CustomColors", tr("Color Theme"), tr("Switch out the standard openpilot color scheme with themed colors.\n\nWant to submit your own color scheme? Post it in the 'feature-request' channel in the FrogPilot Discord!"), ""},
|
||||
{"CustomIcons", tr("Icon Pack"), tr("Switch out the standard openpilot icons with a set of themed icons.\n\nWant to submit your own icon pack? Post it in the 'feature-request' channel in the FrogPilot Discord!"), ""},
|
||||
{"CustomSignals", tr("Turn Signals"), tr("Add themed animation for your turn signals.\n\nWant to submit your own turn signal animation? Post it in the 'feature-request' channel in the FrogPilot Discord!"), ""},
|
||||
{"CustomSounds", tr("Sound Pack"), tr("Switch out the standard openpilot sounds with a set of themed sounds.\n\nWant to submit your own sound pack? Post it in the 'feature-request' channel in the FrogPilot Discord!"), ""},
|
||||
{"HolidayThemes", tr("Holiday Themes"), tr("The openpilot theme changes according to the current/upcoming holiday. Minor holidays last a day, while major holidays (Easter, Christmas, Halloween, etc.) last a week."), ""},
|
||||
{"RandomEvents", tr("Random Events"), tr("Enjoy a bit of unpredictability with random events that can occur during certain driving conditions. This is purely cosmetic and has no impact on driving controls!"), ""},
|
||||
|
||||
{"ModelUI", tr("Model UI"), tr("Customize the model visualizations on the screen."), "../assets/offroad/icon_calibration.png"},
|
||||
{"DynamicPathWidth", tr("Dynamic Path Width"), tr("Have the path width dynamically adjust based on the current engagement state of openpilot."), ""},
|
||||
{"HideLeadMarker", tr("Hide Lead Marker"), tr("Hide the lead marker from the onroad UI."), ""},
|
||||
{"LaneLinesWidth", tr("Lane Lines"), tr("Adjust the visual thickness of lane lines on your display.\n\nDefault matches the MUTCD average of 4 inches."), ""},
|
||||
{"PathEdgeWidth", tr("Path Edges"), tr("Adjust the width of the path edges shown on your UI to represent different driving modes and statuses.\n\nDefault is 20% of the total path.\n\nBlue = Navigation\nLight Blue = 'Always On Lateral'\nGreen = Default\nOrange = 'Experimental Mode'\nRed = 'Traffic Mode'\nYellow = 'Conditional Experimental Mode' Overriden"), ""},
|
||||
{"PathWidth", tr("Path Width"), tr("Customize the width of the driving path shown on your UI.\n\nDefault matches the width of a 2019 Lexus ES 350."), ""},
|
||||
{"RoadEdgesWidth", tr("Road Edges"), tr("Adjust the visual thickness of road edges on your display.\n\nDefault is 1/2 of the MUTCD average lane line width of 4 inches."), ""},
|
||||
{"UnlimitedLength", tr("'Unlimited' Road UI Length"), tr("Extend the display of the path, lane lines, and road edges out as far as the model can see."), ""},
|
||||
|
||||
{"QOLVisuals", tr("Quality of Life"), tr("Miscellaneous quality of life changes to improve your overall openpilot experience."), "../frogpilot/assets/toggle_icons/quality_of_life.png"},
|
||||
{"BigMap", tr("Big Map"), tr("Increase the size of the map in the onroad UI."), ""},
|
||||
{"CameraView", tr("Camera View"), tr("Choose your preferred camera view for the onroad UI. This is purely a visual change and doesn't impact how openpilot drives."), ""},
|
||||
{"DriverCamera", tr("Driver Camera On Reverse"), tr("Show the driver camera feed when in reverse."), ""},
|
||||
{"HideSpeed", tr("Hide Speed"), tr("Hide the speed indicator in the onroad UI. Additional toggle allows it to be hidden/shown via tapping the speed itself."), ""},
|
||||
{"MapStyle", tr("Map Style"), tr("Select a map style to use with navigation."), ""},
|
||||
{"NumericalTemp", tr("Numerical Temperature Gauge"), tr("Replace the 'GOOD', 'OK', and 'HIGH' temperature statuses with a numerical temperature gauge based on the highest temperature between the memory, CPU, and GPU."), ""},
|
||||
{"WheelSpeed", tr("Use Wheel Speed"), tr("Use the wheel speed instead of the cluster speed in the onroad UI."), ""},
|
||||
|
||||
{"ScreenManagement", tr("Screen Management"), tr("Manage your screen's brightness, timeout settings, and hide onroad UI elements."), "../frogpilot/assets/toggle_icons/icon_light.png"},
|
||||
{"HideUIElements", tr("Hide UI Elements"), tr("Hide the selected UI elements from the onroad screen."), ""},
|
||||
{"ScreenBrightness", tr("Screen Brightness"), tr("Customize your screen brightness when offroad."), ""},
|
||||
{"ScreenBrightnessOnroad", tr("Screen Brightness (Onroad)"), tr("Customize your screen brightness when onroad."), ""},
|
||||
{"ScreenRecorder", tr("Screen Recorder"), tr("Enable the ability to record the screen while onroad."), ""},
|
||||
{"ScreenTimeout", tr("Screen Timeout"), tr("Customize how long it takes for your screen to turn off."), ""},
|
||||
{"ScreenTimeoutOnroad", tr("Screen Timeout (Onroad)"), tr("Customize how long it takes for your screen to turn off when onroad."), ""},
|
||||
{"StandbyMode", tr("Standby Mode"), tr("Turn the screen off after your screen times out when onroad, but wake it back up when engagement state changes or important alerts are triggered."), ""},
|
||||
};
|
||||
|
||||
for (const auto &[param, title, desc, icon] : visualToggles) {
|
||||
ParamControl *toggle;
|
||||
|
||||
if (param == "AlertVolumeControl") {
|
||||
FrogPilotParamManageControl *alertVolumeControlToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(alertVolumeControlToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
openParentToggle();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(alertVolumeControlKeys.find(key.c_str()) != alertVolumeControlKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = alertVolumeControlToggle;
|
||||
} else if (alertVolumeControlKeys.find(param) != alertVolumeControlKeys.end()) {
|
||||
if (param == "WarningImmediateVolume") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 25, 100, std::map<int, QString>(), this, false, "%");
|
||||
} else {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, "%");
|
||||
}
|
||||
|
||||
} else if (param == "CustomAlerts") {
|
||||
FrogPilotParamManageControl *customAlertsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(customAlertsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
openParentToggle();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
std::set<QString> modifiedCustomAlertsKeys = customAlertsKeys;
|
||||
|
||||
if (!hasBSM) {
|
||||
modifiedCustomAlertsKeys.erase("LoudBlindspotAlert");
|
||||
}
|
||||
|
||||
toggle->setVisible(modifiedCustomAlertsKeys.find(key.c_str()) != modifiedCustomAlertsKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = customAlertsToggle;
|
||||
|
||||
} else if (param == "CustomTheme") {
|
||||
FrogPilotParamManageControl *customThemeToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(customThemeToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
openParentToggle();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(customThemeKeys.find(key.c_str()) != customThemeKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = customThemeToggle;
|
||||
} else if (param == "CustomColors" || param == "CustomIcons" || param == "CustomSignals" || param == "CustomSounds") {
|
||||
std::vector<QString> themeOptions{tr("Stock"), tr("Frog"), tr("Tesla"), tr("Stalin")};
|
||||
FrogPilotButtonParamControl *themeSelection = new FrogPilotButtonParamControl(param, title, desc, icon, themeOptions);
|
||||
toggle = themeSelection;
|
||||
|
||||
if (param == "CustomSounds") {
|
||||
QObject::connect(static_cast<FrogPilotButtonParamControl*>(toggle), &FrogPilotButtonParamControl::buttonClicked, [this](int id) {
|
||||
if (id == 1) {
|
||||
if (FrogPilotConfirmationDialog::yesorno(tr("Do you want to enable the bonus 'Goat' sound effect?"), this)) {
|
||||
params.putBoolNonBlocking("GoatScream", true);
|
||||
} else {
|
||||
params.putBoolNonBlocking("GoatScream", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} else if (param == "CustomUI") {
|
||||
FrogPilotParamManageControl *customUIToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(customUIToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
openParentToggle();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
std::set<QString> modifiedCustomOnroadUIKeys = customOnroadUIKeys;
|
||||
|
||||
if (!hasOpenpilotLongitudinal && !hasAutoTune || isRelease) {
|
||||
modifiedCustomOnroadUIKeys.erase("DeveloperUI");
|
||||
}
|
||||
|
||||
if (!hasOpenpilotLongitudinal || !isRelease) {
|
||||
modifiedCustomOnroadUIKeys.erase("LeadInfo");
|
||||
}
|
||||
|
||||
toggle->setVisible(modifiedCustomOnroadUIKeys.find(key.c_str()) != modifiedCustomOnroadUIKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = customUIToggle;
|
||||
} else if (param == "DeveloperUI") {
|
||||
std::vector<QString> developerUIToggles{"LeadInfo", "ShowTuning", "ShowJerk", "UseSI"};
|
||||
std::vector<QString> developerUIToggleNames{tr("Lead Info"), tr("Live Tuning"), tr("Jerk"), tr("Use SI")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, developerUIToggles, developerUIToggleNames);
|
||||
} else if (param == "LeadInfo") {
|
||||
std::vector<QString> leadInfoToggles{"UseSI"};
|
||||
std::vector<QString> leadInfoToggleNames{tr("Use SI Values")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, leadInfoToggles, leadInfoToggleNames);
|
||||
} else if (param == "CustomPaths") {
|
||||
std::vector<QString> pathToggles{"AccelerationPath", "AdjacentPath", "BlindSpotPath", "AdjacentPathMetrics"};
|
||||
std::vector<QString> pathToggleNames{tr("Acceleration"), tr("Adjacent"), tr("Blind Spot"), tr("Metrics")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, pathToggles, pathToggleNames);
|
||||
} else if (param == "WheelIcon") {
|
||||
std::vector<QString> wheelToggles{"RotatingWheel"};
|
||||
std::vector<QString> wheelToggleNames{"Live Rotation"};
|
||||
std::map<int, QString> steeringWheelLabels = {{-1, tr("None")}, {0, tr("Stock")}, {1, tr("Lexus")}, {2, tr("Toyota")}, {3, tr("Frog")}, {4, tr("Rocket")}, {5, tr("Hyundai")}, {6, tr("Stalin")}};
|
||||
toggle = new FrogPilotParamValueToggleControl(param, title, desc, icon, -1, 6, steeringWheelLabels, this, true, "", 1, 1, wheelToggles, wheelToggleNames);
|
||||
|
||||
} else if (param == "ModelUI") {
|
||||
FrogPilotParamManageControl *modelUIToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(modelUIToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
openParentToggle();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
std::set<QString> modifiedModelUIKeysKeys = modelUIKeys;
|
||||
|
||||
if (!hasOpenpilotLongitudinal) {
|
||||
modifiedModelUIKeysKeys.erase("HideLeadMarker");
|
||||
}
|
||||
|
||||
toggle->setVisible(modifiedModelUIKeysKeys.find(key.c_str()) != modifiedModelUIKeysKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = modelUIToggle;
|
||||
} else if (param == "LaneLinesWidth" || param == "RoadEdgesWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 24, std::map<int, QString>(), this, false, tr(" inches"));
|
||||
} else if (param == "PathEdgeWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, tr("%"));
|
||||
} else if (param == "PathWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, tr(" feet"), 10);
|
||||
|
||||
} else if (param == "QOLVisuals") {
|
||||
FrogPilotParamManageControl *qolToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(qolToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
openParentToggle();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(qolKeys.find(key.c_str()) != qolKeys.end());
|
||||
}
|
||||
mapStyleButton->setVisible(true);
|
||||
});
|
||||
toggle = qolToggle;
|
||||
} else if (param == "CameraView") {
|
||||
std::vector<QString> cameraOptions{tr("Auto"), tr("Driver"), tr("Standard"), tr("Wide")};
|
||||
FrogPilotButtonParamControl *preferredCamera = new FrogPilotButtonParamControl(param, title, desc, icon, cameraOptions);
|
||||
toggle = preferredCamera;
|
||||
} else if (param == "BigMap") {
|
||||
std::vector<QString> mapToggles{"FullMap"};
|
||||
std::vector<QString> mapToggleNames{tr("Full Map")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, mapToggles, mapToggleNames);
|
||||
} else if (param == "HideSpeed") {
|
||||
std::vector<QString> hideSpeedToggles{"HideSpeedUI"};
|
||||
std::vector<QString> hideSpeedToggleNames{tr("Control Via UI")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, hideSpeedToggles, hideSpeedToggleNames);
|
||||
} else if (param == "MapStyle") {
|
||||
QMap<int, QString> styleMap = {
|
||||
{0, tr("Stock openpilot")},
|
||||
{1, tr("Mapbox Streets")},
|
||||
{2, tr("Mapbox Outdoors")},
|
||||
{3, tr("Mapbox Light")},
|
||||
{4, tr("Mapbox Dark")},
|
||||
{5, tr("Mapbox Satellite")},
|
||||
{6, tr("Mapbox Satellite Streets")},
|
||||
{7, tr("Mapbox Navigation Day")},
|
||||
{8, tr("Mapbox Navigation Night")},
|
||||
{9, tr("Mapbox Traffic Night")},
|
||||
{10, tr("mike854's (Satellite hybrid)")},
|
||||
};
|
||||
|
||||
QStringList styles = styleMap.values();
|
||||
|
||||
mapStyleButton = new ButtonControl(title, tr("SELECT"), desc);
|
||||
QObject::connect(mapStyleButton, &ButtonControl::clicked, this, [this, styleMap]() {
|
||||
QStringList styles = styleMap.values();
|
||||
QString selection = MultiOptionDialog::getSelection(tr("Select a map style"), styles, "", this);
|
||||
if (!selection.isEmpty()) {
|
||||
int selectedStyle = styleMap.key(selection);
|
||||
params.putInt("MapStyle", selectedStyle);
|
||||
mapStyleButton->setValue(selection);
|
||||
updateToggles();
|
||||
}
|
||||
});
|
||||
|
||||
int currentStyle = params.getInt("MapStyle");
|
||||
mapStyleButton->setValue(styleMap[currentStyle]);
|
||||
|
||||
addItem(mapStyleButton);
|
||||
} else if (param == "NumericalTemp") {
|
||||
std::vector<QString> temperatureToggles{"Fahrenheit"};
|
||||
std::vector<QString> temperatureToggleNames{tr("Fahrenheit")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, temperatureToggles, temperatureToggleNames);
|
||||
|
||||
} else if (param == "ScreenManagement") {
|
||||
FrogPilotParamManageControl *screenToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(screenToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
openParentToggle();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(screenKeys.find(key.c_str()) != screenKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = screenToggle;
|
||||
} else if (param == "HideUIElements") {
|
||||
std::vector<QString> uiElementsToggles{"HideAlerts", "HideMapIcon", "HideMaxSpeed"};
|
||||
std::vector<QString> uiElementsToggleNames{tr("Alerts"), tr("Map Icon"), tr("Max Speed")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, uiElementsToggles, uiElementsToggleNames);
|
||||
} else if (param == "ScreenBrightness" || param == "ScreenBrightnessOnroad") {
|
||||
std::map<int, QString> brightnessLabels;
|
||||
for (int i = 0; i <= 101; ++i) {
|
||||
brightnessLabels[i] = i == 0 ? tr("Screen Off") : i == 101 ? tr("Auto") : QString::number(i) + "%";
|
||||
}
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 101, brightnessLabels, this, false);
|
||||
} else if (param == "ScreenTimeout" || param == "ScreenTimeoutOnroad") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 5, 60, std::map<int, QString>(), this, false, tr(" seconds"));
|
||||
|
||||
} else {
|
||||
toggle = new ParamControl(param, title, desc, icon, this);
|
||||
}
|
||||
|
||||
addItem(toggle);
|
||||
toggles[param.toStdString()] = toggle;
|
||||
|
||||
QObject::connect(toggle, &ToggleControl::toggleFlipped, [this]() {
|
||||
updateToggles();
|
||||
});
|
||||
|
||||
QObject::connect(static_cast<FrogPilotButtonParamControl*>(toggle), &FrogPilotButtonParamControl::buttonClicked, [this]() {
|
||||
updateToggles();
|
||||
});
|
||||
|
||||
QObject::connect(static_cast<FrogPilotParamValueControl*>(toggle), &FrogPilotParamValueControl::valueChanged, [this]() {
|
||||
updateToggles();
|
||||
});
|
||||
|
||||
QObject::connect(toggle, &AbstractControl::showDescriptionEvent, [this]() {
|
||||
update();
|
||||
});
|
||||
|
||||
QObject::connect(static_cast<FrogPilotParamManageControl*>(toggle), &FrogPilotParamManageControl::manageButtonClicked, [this]() {
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
QObject::connect(parent, &SettingsWindow::closeParentToggle, this, &FrogPilotVisualsPanel::hideToggles);
|
||||
QObject::connect(parent, &SettingsWindow::updateMetric, this, &FrogPilotVisualsPanel::updateMetric);
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &FrogPilotVisualsPanel::updateCarToggles);
|
||||
QObject::connect(uiState(), &UIState::uiUpdate, this, &FrogPilotVisualsPanel::updateState);
|
||||
|
||||
updateMetric();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::showEvent(QShowEvent *event) {
|
||||
hasOpenpilotLongitudinal = hasOpenpilotLongitudinal && !params.getBool("DisableOpenpilotLongitudinal");
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::updateState(const UIState &s) {
|
||||
if (!isVisible()) return;
|
||||
|
||||
started = s.scene.started;
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::updateToggles() {
|
||||
std::thread([this]() {
|
||||
paramsMemory.putBool("FrogPilotTogglesUpdated", true);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
paramsMemory.putBool("FrogPilotTogglesUpdated", false);
|
||||
}).detach();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::updateCarToggles() {
|
||||
auto carParams = params.get("CarParamsPersistent");
|
||||
if (!carParams.empty()) {
|
||||
AlignedBuffer aligned_buf;
|
||||
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(carParams.data(), carParams.size()));
|
||||
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
|
||||
auto carName = CP.getCarName();
|
||||
|
||||
hasAutoTune = (carName == "hyundai" || carName == "toyota") && CP.getLateralTuning().which() == cereal::CarParams::LateralTuning::TORQUE;
|
||||
hasBSM = CP.getEnableBsm();
|
||||
hasOpenpilotLongitudinal = CP.getOpenpilotLongitudinalControl() && !params.getBool("DisableOpenpilotLongitudinal");
|
||||
} else {
|
||||
hasBSM = true;
|
||||
hasOpenpilotLongitudinal = true;
|
||||
}
|
||||
|
||||
hideToggles();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::updateMetric() {
|
||||
bool previousIsMetric = isMetric;
|
||||
isMetric = params.getBool("IsMetric");
|
||||
|
||||
if (isMetric != previousIsMetric) {
|
||||
double distanceConversion = isMetric ? INCH_TO_CM : CM_TO_INCH;
|
||||
double speedConversion = isMetric ? FOOT_TO_METER : METER_TO_FOOT;
|
||||
params.putIntNonBlocking("LaneLinesWidth", std::nearbyint(params.getInt("LaneLinesWidth") * distanceConversion));
|
||||
params.putIntNonBlocking("RoadEdgesWidth", std::nearbyint(params.getInt("RoadEdgesWidth") * distanceConversion));
|
||||
params.putIntNonBlocking("PathWidth", std::nearbyint(params.getInt("PathWidth") * speedConversion));
|
||||
}
|
||||
|
||||
FrogPilotParamValueControl *laneLinesWidthToggle = static_cast<FrogPilotParamValueControl*>(toggles["LaneLinesWidth"]);
|
||||
FrogPilotParamValueControl *roadEdgesWidthToggle = static_cast<FrogPilotParamValueControl*>(toggles["RoadEdgesWidth"]);
|
||||
FrogPilotParamValueControl *pathWidthToggle = static_cast<FrogPilotParamValueControl*>(toggles["PathWidth"]);
|
||||
|
||||
if (isMetric) {
|
||||
laneLinesWidthToggle->setDescription(tr("Customize the lane line width.\n\nDefault matches the Vienna average of 10 centimeters."));
|
||||
roadEdgesWidthToggle->setDescription(tr("Customize the road edges width.\n\nDefault is 1/2 of the Vienna average lane line width of 10 centimeters."));
|
||||
|
||||
laneLinesWidthToggle->updateControl(0, 60, tr(" centimeters"));
|
||||
roadEdgesWidthToggle->updateControl(0, 60, tr(" centimeters"));
|
||||
pathWidthToggle->updateControl(0, 30, tr(" meters"), 10);
|
||||
} else {
|
||||
laneLinesWidthToggle->setDescription(tr("Customize the lane line width.\n\nDefault matches the MUTCD average of 4 inches."));
|
||||
roadEdgesWidthToggle->setDescription(tr("Customize the road edges width.\n\nDefault is 1/2 of the MUTCD average lane line width of 4 inches."));
|
||||
|
||||
laneLinesWidthToggle->updateControl(0, 24, tr(" inches"));
|
||||
roadEdgesWidthToggle->updateControl(0, 24, tr(" inches"));
|
||||
pathWidthToggle->updateControl(0, 100, tr(" feet"), 10);
|
||||
}
|
||||
|
||||
laneLinesWidthToggle->refresh();
|
||||
roadEdgesWidthToggle->refresh();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::hideToggles() {
|
||||
mapStyleButton->setVisible(false);
|
||||
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
bool subToggles = alertVolumeControlKeys.find(key.c_str()) != alertVolumeControlKeys.end() ||
|
||||
customAlertsKeys.find(key.c_str()) != customAlertsKeys.end() ||
|
||||
customOnroadUIKeys.find(key.c_str()) != customOnroadUIKeys.end() ||
|
||||
customThemeKeys.find(key.c_str()) != customThemeKeys.end() ||
|
||||
modelUIKeys.find(key.c_str()) != modelUIKeys.end() ||
|
||||
qolKeys.find(key.c_str()) != qolKeys.end() ||
|
||||
screenKeys.find(key.c_str()) != screenKeys.end();
|
||||
toggle->setVisible(!subToggles);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
47
selfdrive/frogpilot/ui/qt/offroad/visual_settings.h
Normal file
47
selfdrive/frogpilot/ui/qt/offroad/visual_settings.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/qt/widgets/frogpilot_controls.h"
|
||||
#include "selfdrive/ui/qt/offroad/settings.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
class FrogPilotVisualsPanel : public FrogPilotListWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FrogPilotVisualsPanel(SettingsWindow *parent);
|
||||
|
||||
signals:
|
||||
void openParentToggle();
|
||||
|
||||
private:
|
||||
void hideToggles();
|
||||
void showEvent(QShowEvent *event);
|
||||
void updateCarToggles();
|
||||
void updateMetric();
|
||||
void updateState(const UIState &s);
|
||||
void updateToggles();
|
||||
|
||||
ButtonControl *mapStyleButton;
|
||||
|
||||
std::set<QString> alertVolumeControlKeys = {"DisengageVolume", "EngageVolume", "PromptDistractedVolume", "PromptVolume", "RefuseVolume", "WarningImmediateVolume", "WarningSoftVolume"};
|
||||
std::set<QString> customAlertsKeys = {"GreenLightAlert", "LeadDepartingAlert", "LoudBlindspotAlert"};
|
||||
std::set<QString> customOnroadUIKeys = {"Compass", "CustomPaths", "DeveloperUI", "FPSCounter", "LeadInfo", "PedalsOnUI", "RoadNameUI", "WheelIcon"};
|
||||
std::set<QString> customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds", "HolidayThemes", "RandomEvents"};
|
||||
std::set<QString> modelUIKeys = {"DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"};
|
||||
std::set<QString> qolKeys = {"BigMap", "CameraView", "DriverCamera", "FullMap", "HideSpeed", "MapStyle", "NumericalTemp", "WheelSpeed"};
|
||||
std::set<QString> screenKeys = {"HideUIElements", "ScreenBrightness", "ScreenBrightnessOnroad", "ScreenRecorder", "ScreenTimeout", "ScreenTimeoutOnroad", "StandbyMode"};
|
||||
|
||||
std::map<std::string, ParamControl*> toggles;
|
||||
|
||||
Params params;
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
|
||||
bool hasAutoTune;
|
||||
bool hasBSM;
|
||||
bool hasOpenpilotLongitudinal;
|
||||
bool isMetric = params.getBool("IsMetric");
|
||||
bool isRelease;
|
||||
bool started;
|
||||
};
|
||||
Reference in New Issue
Block a user