Compile FrogPilot
This commit is contained in:
@@ -1,729 +0,0 @@
|
||||
#include "selfdrive/frogpilot/ui/control_settings.h"
|
||||
|
||||
FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
|
||||
const std::vector<std::tuple<QString, QString, QString, QString>> controlToggles {
|
||||
{"AdjustablePersonalities", "Adjustable Personalities", "Use the 'Distance' button on the steering wheel or the onroad UI to switch between openpilot's driving personalities.\n\n1 bar = Aggressive\n2 bars = Standard\n3 bars = Relaxed", "../frogpilot/assets/toggle_icons/icon_distance.png"},
|
||||
|
||||
{"AlwaysOnLateral", "Always on Lateral", "Maintain openpilot lateral control when the brake or gas pedals are used.\n\nDeactivation occurs only through the 'Cruise Control' button.", "../frogpilot/assets/toggle_icons/icon_always_on_lateral.png"},
|
||||
{"AlwaysOnLateralMain", "Enable On Cruise Main", "Enable 'Always On Lateral' by simply turning on 'Cruise Control'.", ""},
|
||||
{"HideAOLStatusBar", "Hide the Status Bar", "Don't use the status bar for 'Always On Lateral'.", ""},
|
||||
|
||||
{"ConditionalExperimental", "Conditional Experimental Mode", "Automatically switches to 'Experimental Mode' under predefined conditions.", "../frogpilot/assets/toggle_icons/icon_conditional.png"},
|
||||
{"CECurves", "Curve Detected Ahead", "Switch to 'Experimental Mode' when a curve is detected.", ""},
|
||||
{"CENavigation", "Navigation Based", "Switch to 'Experimental Mode' based on navigation data. (i.e. Intersections, stop signs, etc.)", ""},
|
||||
{"CESlowerLead", "Slower Lead Detected Ahead", "Switch to 'Experimental Mode' when a slower lead vehicle is detected ahead.", ""},
|
||||
{"CEStopLights", "Stop Lights and Stop Signs", "Switch to 'Experimental Mode' when a stop light or stop sign is detected.", ""},
|
||||
{"CESignal", "Turn Signal When Below Highway Speeds", "Switch to 'Experimental Mode' when using turn signals below highway speeds to help assit with turns.", ""},
|
||||
{"HideCEMStatusBar", "Hide the Status Bar", "Don't use the status bar for 'Conditional Experimental Mode'.", ""},
|
||||
|
||||
{"CustomPersonalities", "Custom Driving Personalities", "Customize the driving personality profiles to your driving style.", "../frogpilot/assets/toggle_icons/icon_custom.png"},
|
||||
{"DeviceShutdown", "Device Shutdown Timer", "Configure the timer for automatic device shutdown when offroad conserving energy and preventing battery drain.", "../frogpilot/assets/toggle_icons/icon_time.png"},
|
||||
|
||||
{"ExperimentalModeActivation", "Experimental Mode Activation", "Toggle Experimental Mode with either buttons on ethe steering wheel or the screen.\n\nOverrides 'Conditional Experimental Mode'.", "../assets/img_experimental_white.svg"},
|
||||
{"ExperimentalModeViaLKAS", "Double Clicking the LKAS Button", "Enable/disable 'Experimental Mode' by double clicking the 'LKAS' button on your steering wheel.", ""},
|
||||
{"ExperimentalModeViaScreen", "Double Taping the Onroad UI", "Enable/disable 'Experimental Mode' by double taping the onroad UI within a 0.5 second time frame.", ""},
|
||||
{"ExperimentalModeViaDistance", "Long Pressing the Distance Button", "Enable/disable 'Experimental Mode' by holding down the 'distance' button on your steering wheel for 0.5 seconds.", ""},
|
||||
|
||||
{"FireTheBabysitter", "Fire the Babysitter", "Deactivate some of openpilot's 'Babysitter' protocols for more user autonomy.", "../frogpilot/assets/toggle_icons/icon_babysitter.png"},
|
||||
{"MuteOverheated", "Bypass Thermal Safety Limits", "Allow the device to run at any temperature even above comma's recommended thermal limits.", ""},
|
||||
{"NoLogging", "Disable Logging", "Turn off all data tracking to enhance privacy or reduce thermal load.\n\nWARNING: This action will prevent drive recording and data cannot be recovered!", ""},
|
||||
{"NoUploads", "Disable Uploads", "Turn off all data uploads to comma's servers.\n\nWARNING: This action will prevent your drives from appearing on comma connect which may impact debugging and support!", ""},
|
||||
{"OfflineMode", "Offline Mode", "Allow the device to be offline indefinitely.", ""},
|
||||
|
||||
{"LateralTune", "Lateral Tuning", "Modify openpilot's steering behavior.", "../frogpilot/assets/toggle_icons/icon_lateral_tune.png"},
|
||||
{"ForceAutoTune", "Force Auto Tune", "Forces comma's auto lateral tuning for unsupported vehicles.", ""},
|
||||
{"NNFF", "NNFF - Neural Network Feedforward", "Use Twilsonco's Neural Network Feedforward for enhanced precision in lateral control.", ""},
|
||||
{"SteerRatio", steerRatioStock != 0 ? QString("Steer Ratio (Default: %1)").arg(steerRatioStock, 0, 'f', 2) : "Steer Ratio", "Set a custom steer ratio for your vehicle controls.", ""},
|
||||
{"UseLateralJerk", "Use Lateral Jerk", "Include steer torque necessary to achieve desired steer rate (lateral jerk).", ""},
|
||||
|
||||
{"LongitudinalTune", "Longitudinal Tuning", "Modify openpilot's acceleration and braking behavior.", "../frogpilot/assets/toggle_icons/icon_longitudinal_tune.png"},
|
||||
{"AccelerationProfile", "Acceleration Profile", "Change the acceleration rate to be either sporty or eco-friendly.", ""},
|
||||
{"DecelerationProfile", "Deceleration Profile", "Change the deceleration rate to be either sporty or eco-friendly.", ""},
|
||||
{"AggressiveAcceleration", "Aggressive Acceleration With Lead", "Increase acceleration aggressiveness when following a lead vehicle from a stop.", ""},
|
||||
{"StoppingDistance", "Increase Stop Distance Behind Lead", "Increase the stopping distance for a more comfortable stop from lead vehicles.", ""},
|
||||
{"LeadDetectionThreshold", "Lead Detection Threshold", "Increase or decrease the lead detection threshold to either detect leads sooner, or increase model confidence.", ""},
|
||||
{"SmoothBraking", "Smoother Braking Behind Lead", "Smoothen out the braking behavior when approaching slower vehicles.", ""},
|
||||
{"TrafficMode", "Traffic Mode", "Hold down the 'distance' button for 2.5 seconds to enable more aggressive driving behavior catered towards stop and go traffic.", ""},
|
||||
|
||||
{"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"},
|
||||
{"DisableMTSCSmoothing", "Disable MTSC UI Smoothing", "Disables the smoothing for the requested speed in the onroad UI.", ""},
|
||||
{"MTSCCurvatureCheck", "Model Curvature Detection Failsafe", "Only trigger MTSC when the model detects a curve in the road. Purely used as a failsafe to prevent false positives. Leave this off if you never experience false positives.", ""},
|
||||
{"MTSCLimit", "Speed Change Hard Cap", "Set a hard cap for MTSC. If MTSC requests a speed decrease greater than this value, it ignores the requested speed from MTSC. Purely used as a failsafe to prevent false positives. Leave this off if you never experience false positives.", ""},
|
||||
{"MTSCAggressiveness", "Turn Speed Aggressiveness", "Set turn speed aggressiveness. Higher values result in faster turns, lower values yield gentler turns.\n\nA change of +- 1% results in the velocity being raised or lowered by about 1 mph.", ""},
|
||||
|
||||
{"NudgelessLaneChange", "Nudgeless Lane Change", "Enable lane changes without manual steering input.", "../frogpilot/assets/toggle_icons/icon_lane.png"},
|
||||
{"LaneChangeTime", "Lane Change Timer", "Specify a delay before executing a nudgeless lane change.", ""},
|
||||
{"LaneDetection", "Lane Detection", "Block nudgeless lane changes when a lane isn't detected.", ""},
|
||||
{"LaneDetectionWidth", "Lane Detection Threshold", "Set the required lane width to be qualified as a lane.", ""},
|
||||
{"OneLaneChange", "One Lane Change Per Signal", "Limit to one nudgeless lane change per turn signal activation.", ""},
|
||||
|
||||
{"QOLControls", "Quality of Life", "Miscellaneous quality of life changes to improve your overall openpilot experience.", "../frogpilot/assets/toggle_icons/quality_of_life.png"},
|
||||
{"DisableOnroadUploads", "Disable Onroad Uploads", "Prevent large data uploads when onroad.", ""},
|
||||
{"HigherBitrate", "Higher Bitrate Recording", "Increases the quality of the footage uploaded to comma connect.", ""},
|
||||
{"NavChill", "Navigate on Chill Mode", "Allows cars without longitudinal support to navigate. Allows navigation without experimental mode.", ""},
|
||||
{"PauseLateralOnSignal", "Pause Lateral On Turn Signal Below", "Temporarily disable lateral control during turn signal use below the set speed.", ""},
|
||||
{"ReverseCruise", "Reverse Cruise Increase", "Reverses the 'long press' functionality when increasing the max set speed. Useful to increase the max speed quickly.", ""},
|
||||
{"SetSpeedOffset", "Set Speed Offset", "Set an offset for your desired set speed.", ""},
|
||||
|
||||
{"SpeedLimitController", "Speed Limit Controller", "Automatically adjust vehicle speed to match speed limits using 'Open Street Map's, 'Navigate On openpilot', or your car's dashboard (TSS2 Toyotas only).", "../assets/offroad/icon_speed_limit.png"},
|
||||
{"SLCControls", "Controls Settings", "Manage settings for the controls.", ""},
|
||||
{"Offset1", "Speed Limit Offset (0-34 mph)", "Speed limit offset for speed limits between 0-34 mph.", ""},
|
||||
{"Offset2", "Speed Limit Offset (35-54 mph)", "Speed limit offset for speed limits between 35-54 mph.", ""},
|
||||
{"Offset3", "Speed Limit Offset (55-64 mph)", "Speed limit offset for speed limits between 55-64 mph.", ""},
|
||||
{"Offset4", "Speed Limit Offset (65-99 mph)", "Speed limit offset for speed limits between 65-99 mph.", ""},
|
||||
{"SLCFallback", "Fallback Method", "Choose your fallback method for when there are no speed limits currently being obtained from Navigation, OSM, and the car's dashboard.", ""},
|
||||
{"SLCOverride", "Override Method", "Choose your preferred method to override the current speed limit.", ""},
|
||||
{"SLCPriority", "Priority Order", "Determine the priority order for what speed limits to use.", ""},
|
||||
{"SLCQOL", "Quality of Life Settings", "Manage quality of life settings.", ""},
|
||||
{"SLCConfirmation", "Confirm New Speed Limits", "Don't automatically start using the new speed limit until it's been manually confirmed first.", ""},
|
||||
{"ForceMPHDashboard", "Force MPH From Dashboard Readings", "Force MPH readings from the dashboard. Only use this if you live in an area where the speed limits from your dashboard are in KPH but you use MPH.", ""},
|
||||
{"SetSpeedLimit", "Use Current Speed Limit As Set Speed", "Sets your max speed to the current speed limit if one is populated when you initially enable openpilot.", ""},
|
||||
{"SLCVisuals", "Visuals Settings", "Manage visual settings.", ""},
|
||||
{"ShowSLCOffset", "Show Speed Limit Offset", "Show the speed limit offset seperated from the speed limit in the onroad UI when using 'Speed Limit Controller'.", ""},
|
||||
{"UseVienna", "Use Vienna Speed Limit Signs", "Use the Vienna (EU) speed limit style signs as opposed to MUTCD (US).", ""},
|
||||
|
||||
{"TurnDesires", "Use Turn Desires", "Use turn desires for enhanced precision in turns below the minimum lane change speed.", "../assets/navigation/direction_continue_right.png"},
|
||||
|
||||
{"VisionTurnControl", "Vision Turn Speed Controller", "Slow down for detected road curvature for smoother curve handling.", "../frogpilot/assets/toggle_icons/icon_vtc.png"},
|
||||
{"DisableVTSCSmoothing", "Disable VTSC UI Smoothing", "Disables the smoothing for the requested speed in the onroad UI.", ""},
|
||||
{"CurveSensitivity", "Curve Detection Sensitivity", "Set curve detection sensitivity. Higher values prompt earlier responses, lower values lead to smoother but later reactions.", ""},
|
||||
{"TurnAggressiveness", "Turn Speed Aggressiveness", "Set turn speed aggressiveness. Higher values result in faster turns, lower values yield gentler turns.", ""},
|
||||
};
|
||||
|
||||
for (const auto &[param, title, desc, icon] : controlToggles) {
|
||||
ParamControl *toggle;
|
||||
|
||||
if (param == "AdjustablePersonalities") {
|
||||
std::vector<QString> adjustablePersonalitiesToggles{"PersonalitiesViaWheel", "PersonalitiesViaScreen"};
|
||||
std::vector<QString> adjustablePersonalitiesNames{tr("Distance Button"), tr("Screen")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, adjustablePersonalitiesToggles, adjustablePersonalitiesNames);
|
||||
|
||||
} else if (param == "AlwaysOnLateral") {
|
||||
FrogPilotParamManageControl *aolToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(aolToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(aolKeys.find(key.c_str()) != aolKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = aolToggle;
|
||||
|
||||
} else if (param == "ConditionalExperimental") {
|
||||
FrogPilotParamManageControl *conditionalExperimentalToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(conditionalExperimentalToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
conditionalSpeedsImperial->setVisible(!isMetric);
|
||||
conditionalSpeedsMetric->setVisible(isMetric);
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(conditionalExperimentalKeys.find(key.c_str()) != conditionalExperimentalKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = conditionalExperimentalToggle;
|
||||
} else if (param == "CECurves") {
|
||||
FrogPilotParamValueControl *CESpeedImperial = new FrogPilotParamValueControl("CESpeed", "Below", "Switch to 'Experimental Mode' below this speed in absence of a lead vehicle.", "", 0, 99,
|
||||
std::map<int, QString>(), this, false, " mph");
|
||||
FrogPilotParamValueControl *CESpeedLeadImperial = new FrogPilotParamValueControl("CESpeedLead", " w/Lead", "Switch to 'Experimental Mode' below this speed when following a lead vehicle.", "", 0, 99,
|
||||
std::map<int, QString>(), this, false, " mph");
|
||||
conditionalSpeedsImperial = new FrogPilotDualParamControl(CESpeedImperial, CESpeedLeadImperial, this);
|
||||
addItem(conditionalSpeedsImperial);
|
||||
|
||||
FrogPilotParamValueControl *CESpeedMetric = new FrogPilotParamValueControl("CESpeed", "Below", "Switch to 'Experimental Mode' below this speed in absence of a lead vehicle.", "", 0, 150,
|
||||
std::map<int, QString>(), this, false, " kph");
|
||||
FrogPilotParamValueControl *CESpeedLeadMetric = new FrogPilotParamValueControl("CESpeedLead", " w/Lead", "Switch to 'Experimental Mode' below this speed when following a lead vehicle.", "", 0, 150,
|
||||
std::map<int, QString>(), this, false, " kph");
|
||||
conditionalSpeedsMetric = new FrogPilotDualParamControl(CESpeedMetric, CESpeedLeadMetric, this);
|
||||
addItem(conditionalSpeedsMetric);
|
||||
|
||||
std::vector<QString> curveToggles{"CECurvesLead"};
|
||||
std::vector<QString> curveToggleNames{tr("With Lead")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, curveToggles, curveToggleNames);
|
||||
} else if (param == "CENavigation") {
|
||||
std::vector<QString> navigationToggles{"CENavigationIntersections", "CENavigationTurns", "CENavigationLead"};
|
||||
std::vector<QString> navigationToggleNames{tr("Intersections"), tr("Turns"), tr("With Lead")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, navigationToggles, navigationToggleNames);
|
||||
} else if (param == "CEStopLights") {
|
||||
std::vector<QString> stopLightToggles{"CEStopLightsLead"};
|
||||
std::vector<QString> stopLightToggleNames{tr("With Lead")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, stopLightToggles, stopLightToggleNames);
|
||||
|
||||
} else if (param == "CustomPersonalities") {
|
||||
FrogPilotParamManageControl *customPersonalitiesToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(customPersonalitiesToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(false);
|
||||
}
|
||||
aggressiveProfile->setVisible(true);
|
||||
standardProfile->setVisible(true);
|
||||
relaxedProfile->setVisible(true);
|
||||
});
|
||||
toggle = customPersonalitiesToggle;
|
||||
|
||||
FrogPilotParamValueControl *aggressiveFollow = new FrogPilotParamValueControl("AggressiveFollow", "Follow",
|
||||
"Set the 'Aggressive' personality' following distance. "
|
||||
"Represents seconds to follow behind the lead vehicle.\n\nStock: 1.25 seconds.",
|
||||
"../frogpilot/assets/other_images/aggressive.png",
|
||||
1, 5, std::map<int, QString>(), this, false, " sec", 1, 0.01);
|
||||
FrogPilotParamValueControl *aggressiveJerk = new FrogPilotParamValueControl("AggressiveJerk", " Jerk",
|
||||
"Configure brake/gas pedal responsiveness for the 'Aggressive' personality. "
|
||||
"Higher jerk value = smoother rides.\nLower jerk value = faster response.\n\nStock: 0.5.",
|
||||
"",
|
||||
0.01, 5, std::map<int, QString>(), this, false, "", 1, 0.01);
|
||||
aggressiveProfile = new FrogPilotDualParamControl(aggressiveFollow, aggressiveJerk, this, true);
|
||||
addItem(aggressiveProfile);
|
||||
|
||||
FrogPilotParamValueControl *standardFollow = new FrogPilotParamValueControl("StandardFollow", "Follow",
|
||||
"Set the 'Standard' personality following distance. "
|
||||
"Represents seconds to follow behind the lead vehicle.\n\nStock: 1.45 seconds.",
|
||||
"../frogpilot/assets/other_images/standard.png",
|
||||
1, 5, std::map<int, QString>(), this, false, " sec", 1, 0.01);
|
||||
FrogPilotParamValueControl *standardJerk = new FrogPilotParamValueControl("StandardJerk", " Jerk",
|
||||
"Adjust brake/gas pedal responsiveness for the 'Standard' personality. "
|
||||
"Higher jerk value = smoother rides.\nLower jerk value = faster response.\n\nStock: 1.0.",
|
||||
"",
|
||||
0.01, 5, std::map<int, QString>(), this, false, "", 1, 0.01);
|
||||
standardProfile = new FrogPilotDualParamControl(standardFollow, standardJerk, this, true);
|
||||
addItem(standardProfile);
|
||||
|
||||
FrogPilotParamValueControl *relaxedFollow = new FrogPilotParamValueControl("RelaxedFollow", "Follow",
|
||||
"Set the 'Relaxed' personality following distance. "
|
||||
"Represents seconds to follow behind the lead vehicle.\n\nStock: 1.75 seconds.",
|
||||
"../frogpilot/assets/other_images/relaxed.png",
|
||||
1, 5, std::map<int, QString>(), this, false, " sec", 1, 0.01);
|
||||
FrogPilotParamValueControl *relaxedJerk = new FrogPilotParamValueControl("RelaxedJerk", " Jerk",
|
||||
"Set brake/gas pedal responsiveness for the 'Relaxed' personality. "
|
||||
"Higher jerk value = smoother rides.\nLower jerk value = faster response.\n\nStock: 1.0.",
|
||||
"",
|
||||
0.01, 5, std::map<int, QString>(), this, false, "", 1, 0.01);
|
||||
relaxedProfile = new FrogPilotDualParamControl(relaxedFollow, relaxedJerk, this, true);
|
||||
addItem(relaxedProfile);
|
||||
|
||||
} else if (param == "DeviceShutdown") {
|
||||
std::map<int, QString> shutdownLabels;
|
||||
for (int i = 0; i <= 33; ++i) {
|
||||
shutdownLabels[i] = i == 0 ? "Instant" : i <= 3 ? QString::number(i * 15) + " mins" : QString::number(i - 3) + (i == 4 ? " hour" : " hours");
|
||||
}
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 33, shutdownLabels, this, false);
|
||||
|
||||
} else if (param == "ExperimentalModeActivation") {
|
||||
FrogPilotParamManageControl *experimentalModeActivationToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(experimentalModeActivationToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(experimentalModeActivationKeys.find(key.c_str()) != experimentalModeActivationKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = experimentalModeActivationToggle;
|
||||
|
||||
} else if (param == "FireTheBabysitter") {
|
||||
FrogPilotParamManageControl *fireTheBabysitterToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(fireTheBabysitterToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(fireTheBabysitterKeys.find(key.c_str()) != fireTheBabysitterKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = fireTheBabysitterToggle;
|
||||
|
||||
} else if (param == "LateralTune") {
|
||||
FrogPilotParamManageControl *lateralTuneToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(lateralTuneToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(lateralTuneKeys.find(key.c_str()) != lateralTuneKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = lateralTuneToggle;
|
||||
} else if (param == "SteerRatio") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, steerRatioStock * 0.75, steerRatioStock * 1.25, std::map<int, QString>(), this, false, "", 1, 0.01);
|
||||
|
||||
} else if (param == "LongitudinalTune") {
|
||||
FrogPilotParamManageControl *longitudinalTuneToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(longitudinalTuneToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(longitudinalTuneKeys.find(key.c_str()) != longitudinalTuneKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = longitudinalTuneToggle;
|
||||
} else if (param == "AccelerationProfile") {
|
||||
std::vector<QString> profileOptions{tr("Standard"), tr("Eco"), tr("Sport"), tr("Sport+")};
|
||||
FrogPilotButtonParamControl *profileSelection = new FrogPilotButtonParamControl(param, title, desc, icon, profileOptions);
|
||||
toggle = profileSelection;
|
||||
|
||||
QObject::connect(static_cast<FrogPilotButtonParamControl*>(toggle), &FrogPilotButtonParamControl::buttonClicked, [this](int id) {
|
||||
if (id == 3) {
|
||||
FrogPilotConfirmationDialog::toggleAlert("WARNING: This maxes out openpilot's acceleration from 2.0 m/s to 4.0 m/s and may cause oscillations when accelerating!",
|
||||
"I understand the risks.", this);
|
||||
}
|
||||
});
|
||||
} else if (param == "DecelerationProfile") {
|
||||
std::vector<QString> profileOptions{tr("Standard"), tr("Eco"), tr("Sport")};
|
||||
FrogPilotButtonParamControl *profileSelection = new FrogPilotButtonParamControl(param, title, desc, icon, profileOptions);
|
||||
toggle = profileSelection;
|
||||
} else if (param == "StoppingDistance") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 10, std::map<int, QString>(), this, false, " feet");
|
||||
} else if (param == "LeadDetectionThreshold") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 1, 100, std::map<int, QString>(), this, false, "%");
|
||||
|
||||
} else if (param == "Model") {
|
||||
modelSelectorButton = new FrogPilotButtonIconControl(title, tr("SELECT"), desc, icon);
|
||||
QStringList models = {"los-angeles", "certified-herbalist", "duck-amigo", "recertified-herbalist"};
|
||||
QStringList modelLabels = {"Los Angeles (Default)", "Certified Herbalist", "Duck Amigo", "Recertified Herbalist"};
|
||||
QObject::connect(modelSelectorButton, &FrogPilotButtonIconControl::clicked, this, [this, models, modelLabels]() {
|
||||
QString selection = MultiOptionDialog::getSelection(tr("Select a driving model"), modelLabels, "", this);
|
||||
|
||||
if (!selection.isEmpty()) {
|
||||
int selectedModelIndex = modelLabels.indexOf(selection);
|
||||
QString selectedModelValue = models[selectedModelIndex];
|
||||
params.put("Model", selectedModelValue.toStdString());
|
||||
modelSelectorButton->setValue(selection);
|
||||
if (FrogPilotConfirmationDialog::yesorno("Do you want to start with a fresh calibration for the newly selected model?", this)) {
|
||||
params.remove("CalibrationParams");
|
||||
params.remove("LiveTorqueParameters");
|
||||
}
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) {
|
||||
Hardware::soft_reboot();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
int initialModelIndex = models.indexOf(QString::fromStdString(params.get("Model")));
|
||||
QString initialModelLabel = modelLabels[initialModelIndex];
|
||||
modelSelectorButton->setValue(initialModelLabel);
|
||||
addItem(modelSelectorButton);
|
||||
|
||||
} else if (param == "MTSCEnabled") {
|
||||
FrogPilotParamManageControl *mtscToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(mtscToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(mtscKeys.find(key.c_str()) != mtscKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = mtscToggle;
|
||||
} else if (param == "MTSCAggressiveness") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 1, 200, std::map<int, QString>(), this, false, "%");
|
||||
} else if (param == "MTSCLimit") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 99, std::map<int, QString>(), this, false, " mph");
|
||||
|
||||
} else if (param == "QOLControls") {
|
||||
FrogPilotParamManageControl *qolToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(qolToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(qolKeys.find(key.c_str()) != qolKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = qolToggle;
|
||||
} else if (param == "PauseLateralOnSignal") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 99, std::map<int, QString>(), this, false, " mph");
|
||||
} else if (param == "ReverseCruise") {
|
||||
std::vector<QString> reverseCruiseToggles{"ReverseCruiseUI"};
|
||||
std::vector<QString> reverseCruiseNames{tr("Control Via UI")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, reverseCruiseToggles, reverseCruiseNames);
|
||||
} else if (param == "SetSpeedOffset") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 99, std::map<int, QString>(), this, false, " mph");
|
||||
|
||||
} else if (param == "NudgelessLaneChange") {
|
||||
FrogPilotParamManageControl *laneChangeToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(laneChangeToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(laneChangeKeys.find(key.c_str()) != laneChangeKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = laneChangeToggle;
|
||||
} else if (param == "LaneChangeTime") {
|
||||
std::map<int, QString> laneChangeTimeLabels;
|
||||
for (int i = 0; i <= 10; ++i) {
|
||||
laneChangeTimeLabels[i] = i == 0 ? "Instant" : QString::number(i / 2.0) + " seconds";
|
||||
}
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 10, laneChangeTimeLabels, this, false);
|
||||
} else if (param == "LaneDetectionWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, " feet", 10);
|
||||
|
||||
} else if (param == "SpeedLimitController") {
|
||||
FrogPilotParamManageControl *speedLimitControllerToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(speedLimitControllerToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(speedLimitControllerKeys.find(key.c_str()) != speedLimitControllerKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = speedLimitControllerToggle;
|
||||
} else if (param == "SLCControls") {
|
||||
FrogPilotParamManageControl *manageSLCControlsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this, true);
|
||||
QObject::connect(manageSLCControlsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(speedLimitControllerControlsKeys.find(key.c_str()) != speedLimitControllerControlsKeys.end());
|
||||
subParentToggleClicked();
|
||||
}
|
||||
slcPriorityButton->setVisible(true);
|
||||
});
|
||||
toggle = manageSLCControlsToggle;
|
||||
} else if (param == "SLCQOL") {
|
||||
FrogPilotParamManageControl *manageSLCQOLToggle = new FrogPilotParamManageControl(param, title, desc, icon, this, true);
|
||||
QObject::connect(manageSLCQOLToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(speedLimitControllerQOLKeys.find(key.c_str()) != speedLimitControllerQOLKeys.end());
|
||||
subParentToggleClicked();
|
||||
}
|
||||
});
|
||||
toggle = manageSLCQOLToggle;
|
||||
} else if (param == "SLCConfirmation") {
|
||||
std::vector<QString> slcConfirmationToggles{"SLCConfirmationLower", "SLCConfirmationHigher"};
|
||||
std::vector<QString> slcConfirmationNames{tr("Lower Limits"), tr("Higher Limits")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, slcConfirmationToggles, slcConfirmationNames);
|
||||
} else if (param == "SLCVisuals") {
|
||||
FrogPilotParamManageControl *manageSLCVisualsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this, true);
|
||||
QObject::connect(manageSLCVisualsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(speedLimitControllerVisualsKeys.find(key.c_str()) != speedLimitControllerVisualsKeys.end());
|
||||
subParentToggleClicked();
|
||||
}
|
||||
});
|
||||
toggle = manageSLCVisualsToggle;
|
||||
} else if (param == "Offset1" || param == "Offset2" || param == "Offset3" || param == "Offset4") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, -99, 99, std::map<int, QString>(), this, false, " mph");
|
||||
} else if (param == "ShowSLCOffset") {
|
||||
std::vector<QString> slcOffsetToggles{"ShowSLCOffsetUI"};
|
||||
std::vector<QString> slcOffsetToggleNames{tr("Control Via UI")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, slcOffsetToggles, slcOffsetToggleNames);
|
||||
} else if (param == "SLCFallback") {
|
||||
std::vector<QString> fallbackOptions{tr("Set Speed"), tr("Experimental Mode"), tr("Previous Limit")};
|
||||
FrogPilotButtonParamControl *fallbackSelection = new FrogPilotButtonParamControl(param, title, desc, icon, fallbackOptions);
|
||||
toggle = fallbackSelection;
|
||||
} else if (param == "SLCOverride") {
|
||||
std::vector<QString> overrideOptions{tr("None"), tr("Manual Set Speed"), tr("Set Speed")};
|
||||
FrogPilotButtonParamControl *overrideSelection = new FrogPilotButtonParamControl(param, title, desc, icon, overrideOptions);
|
||||
toggle = overrideSelection;
|
||||
} else if (param == "SLCPriority") {
|
||||
slcPriorityButton = new ButtonControl(title, tr("SELECT"), desc);
|
||||
QStringList primaryPriorities = {"None", "Dashboard", "Navigation", "Offline Maps", "Highest", "Lowest"};
|
||||
QStringList secondaryTertiaryPriorities = {"None", "Dashboard", "Navigation", "Offline Maps"};
|
||||
QStringList priorityPrompts = {tr("Select your primary priority"), tr("Select your secondary priority"), tr("Select your tertiary priority")};
|
||||
|
||||
QObject::connect(slcPriorityButton, &ButtonControl::clicked, this, [this, primaryPriorities, secondaryTertiaryPriorities, priorityPrompts]() {
|
||||
QStringList availablePriorities = primaryPriorities;
|
||||
QStringList selectedPriorities;
|
||||
for (int i = 1; i <= 3; ++i) {
|
||||
QStringList currentPriorities = (i == 1) ? availablePriorities : secondaryTertiaryPriorities;
|
||||
|
||||
for (const QString &selectedPriority : selectedPriorities) {
|
||||
currentPriorities.removeAll(selectedPriority);
|
||||
}
|
||||
|
||||
QString priorityKey = QString("SLCPriority%1").arg(i);
|
||||
QString selection = MultiOptionDialog::getSelection(priorityPrompts[i - 1], currentPriorities, "", this);
|
||||
if (!selection.isEmpty()) {
|
||||
params.put(priorityKey.toStdString(), selection.toStdString());
|
||||
selectedPriorities.append(selection);
|
||||
|
||||
if (i == 1 && (selection == "Highest" || selection == "Lowest" || selection == "None")) {
|
||||
for (int j = i + 1; j <= 3; ++j) {
|
||||
QString remainingPriorityKeys = QString("SLCPriority%1").arg(j);
|
||||
params.putInt(remainingPriorityKeys.toStdString(), 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
updateToggles();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
selectedPriorities.removeAll("None");
|
||||
slcPriorityButton->setValue(selectedPriorities.join(", "));
|
||||
});
|
||||
|
||||
QStringList initialPriorities;
|
||||
for (int i = 1; i <= 3; ++i) {
|
||||
QString priorityKey = QString("SLCPriority%1").arg(i);
|
||||
std::string priorityValue = params.get(priorityKey.toStdString());
|
||||
QString priorityString = QString::fromStdString(priorityValue);
|
||||
if (!priorityString.isEmpty() && primaryPriorities.contains(priorityString) && priorityString != "None") {
|
||||
initialPriorities.append(priorityString);
|
||||
}
|
||||
}
|
||||
slcPriorityButton->setValue(initialPriorities.join(", "));
|
||||
addItem(slcPriorityButton);
|
||||
|
||||
} else if (param == "VisionTurnControl") {
|
||||
FrogPilotParamManageControl *visionTurnControlToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(visionTurnControlToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(visionTurnControlKeys.find(key.c_str()) != visionTurnControlKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = visionTurnControlToggle;
|
||||
} else if (param == "CurveSensitivity" || param == "TurnAggressiveness") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 1, 200, std::map<int, QString>(), this, false, "%");
|
||||
|
||||
} 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, [this]() {
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
QObject::connect(toggles["AlwaysOnLateralMain"], &ToggleControl::toggleFlipped, [this]() {
|
||||
if (params.getBool("AlwaysOnLateralMain")) {
|
||||
FrogPilotConfirmationDialog::toggleAlert(
|
||||
"WARNING: This isn't guaranteed to work, so if you run into any issues, please report it in the FrogPilot Discord!",
|
||||
"I understand the risks.", this);
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(toggles["MuteOverheated"], &ToggleControl::toggleFlipped, [this]() {
|
||||
if (params.getBool("MuteOverheated")) {
|
||||
FrogPilotConfirmationDialog::toggleAlert(
|
||||
"WARNING: This MAY cause premature wear or damage by running the device over comma's recommended temperature limits!",
|
||||
"I understand the risks.", this);
|
||||
}
|
||||
});
|
||||
|
||||
std::set<std::string> rebootKeys = {"AlwaysOnLateral", "HigherBitrate", "NNFF", "UseLateralJerk"};
|
||||
for (const std::string &key : rebootKeys) {
|
||||
QObject::connect(toggles[key], &ToggleControl::toggleFlipped, [this, key]() {
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) {
|
||||
Hardware::soft_reboot();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QObject::connect(device(), &Device::interactiveTimeout, this, &FrogPilotControlsPanel::hideSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::closeParentToggle, this, &FrogPilotControlsPanel::hideSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::closeSubParentToggle, this, &FrogPilotControlsPanel::hideSubSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::updateMetric, this, &FrogPilotControlsPanel::updateMetric);
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &FrogPilotControlsPanel::updateCarToggles);
|
||||
QObject::connect(uiState(), &UIState::uiUpdate, this, &FrogPilotControlsPanel::updateState);
|
||||
|
||||
hideSubToggles();
|
||||
updateMetric();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::updateState(const UIState &s) {
|
||||
started = s.scene.started;
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::updateToggles() {
|
||||
std::thread([this]() {
|
||||
paramsMemory.putBool("FrogPilotTogglesUpdated", true);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
paramsMemory.putBool("FrogPilotTogglesUpdated", false);
|
||||
}).detach();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::updateCarToggles() {
|
||||
steerRatioStock = params.getFloat("SteerRatioStock");
|
||||
|
||||
if (steerRatioStock == 0.0) {
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setInterval(1000);
|
||||
connect(timer, &QTimer::timeout, this, [this, timer]() {
|
||||
steerRatioStock = params.getFloat("SteerRatioStock");
|
||||
if (steerRatioStock != 0.0) {
|
||||
timer->stop();
|
||||
timer->deleteLater();
|
||||
|
||||
FrogPilotParamValueControl *steerRatioToggle = static_cast<FrogPilotParamValueControl*>(toggles["SteerRatio"]);
|
||||
steerRatioToggle->setTitle(QString("Steer Ratio (Default: %1)").arg(steerRatioStock, 0, 'f', 2));
|
||||
steerRatioToggle->updateControl(steerRatioStock * 0.75, steerRatioStock * 1.25, "", 0.01);
|
||||
steerRatioToggle->refresh();
|
||||
}
|
||||
});
|
||||
timer->start();
|
||||
} else {
|
||||
FrogPilotParamValueControl *steerRatioToggle = static_cast<FrogPilotParamValueControl*>(toggles["SteerRatio"]);
|
||||
steerRatioToggle->setTitle(QString("Steer Ratio (Default: %1)").arg(steerRatioStock, 0, 'f', 2));
|
||||
steerRatioToggle->updateControl(steerRatioStock * 0.75, steerRatioStock * 1.25, "", 0.01);
|
||||
steerRatioToggle->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::updateMetric() {
|
||||
bool previousIsMetric = isMetric;
|
||||
isMetric = params.getBool("IsMetric");
|
||||
|
||||
if (isMetric != previousIsMetric) {
|
||||
double distanceConversion = isMetric ? FOOT_TO_METER : METER_TO_FOOT;
|
||||
double speedConversion = isMetric ? MILE_TO_KM : KM_TO_MILE;
|
||||
params.putIntNonBlocking("CESpeed", std::nearbyint(params.getInt("CESpeed") * speedConversion));
|
||||
params.putIntNonBlocking("CESpeedLead", std::nearbyint(params.getInt("CESpeedLead") * speedConversion));
|
||||
params.putIntNonBlocking("LaneDetectionWidth", std::nearbyint(params.getInt("LaneDetectionWidth") * distanceConversion));
|
||||
params.putIntNonBlocking("MTSCLimit", std::nearbyint(params.getInt("MTSCLimit") * speedConversion));
|
||||
params.putIntNonBlocking("Offset1", std::nearbyint(params.getInt("Offset1") * speedConversion));
|
||||
params.putIntNonBlocking("Offset2", std::nearbyint(params.getInt("Offset2") * speedConversion));
|
||||
params.putIntNonBlocking("Offset3", std::nearbyint(params.getInt("Offset3") * speedConversion));
|
||||
params.putIntNonBlocking("Offset4", std::nearbyint(params.getInt("Offset4") * speedConversion));
|
||||
params.putIntNonBlocking("PauseLateralOnSignal", std::nearbyint(params.getInt("PauseLateralOnSignal") * speedConversion));
|
||||
params.putIntNonBlocking("SetSpeedOffset", std::nearbyint(params.getInt("SetSpeedOffset") * speedConversion));
|
||||
params.putIntNonBlocking("StoppingDistance", std::nearbyint(params.getInt("StoppingDistance") * distanceConversion));
|
||||
}
|
||||
|
||||
FrogPilotParamValueControl *laneWidthToggle = static_cast<FrogPilotParamValueControl*>(toggles["LaneDetectionWidth"]);
|
||||
FrogPilotParamValueControl *mtscLimitToggle = static_cast<FrogPilotParamValueControl*>(toggles["MTSCLimit"]);
|
||||
FrogPilotParamValueControl *offset1Toggle = static_cast<FrogPilotParamValueControl*>(toggles["Offset1"]);
|
||||
FrogPilotParamValueControl *offset2Toggle = static_cast<FrogPilotParamValueControl*>(toggles["Offset2"]);
|
||||
FrogPilotParamValueControl *offset3Toggle = static_cast<FrogPilotParamValueControl*>(toggles["Offset3"]);
|
||||
FrogPilotParamValueControl *offset4Toggle = static_cast<FrogPilotParamValueControl*>(toggles["Offset4"]);
|
||||
FrogPilotParamValueControl *pauseLateralToggle = static_cast<FrogPilotParamValueControl*>(toggles["PauseLateralOnSignal"]);
|
||||
FrogPilotParamValueControl *setSpeedOffsetToggle = static_cast<FrogPilotParamValueControl*>(toggles["SetSpeedOffset"]);
|
||||
FrogPilotParamValueControl *stoppingDistanceToggle = static_cast<FrogPilotParamValueControl*>(toggles["StoppingDistance"]);
|
||||
|
||||
if (isMetric) {
|
||||
offset1Toggle->setTitle("Speed Limit Offset (0-34 kph)");
|
||||
offset2Toggle->setTitle("Speed Limit Offset (35-54 kph)");
|
||||
offset3Toggle->setTitle("Speed Limit Offset (55-64 kph)");
|
||||
offset4Toggle->setTitle("Speed Limit Offset (65-99 kph)");
|
||||
|
||||
offset1Toggle->setDescription("Set speed limit offset for limits between 0-34 kph.");
|
||||
offset2Toggle->setDescription("Set speed limit offset for limits between 35-54 kph.");
|
||||
offset3Toggle->setDescription("Set speed limit offset for limits between 55-64 kph.");
|
||||
offset4Toggle->setDescription("Set speed limit offset for limits between 65-99 kph.");
|
||||
|
||||
laneWidthToggle->updateControl(0, 30, " meters", 10);
|
||||
|
||||
mtscLimitToggle->updateControl(0, 99, " kph");
|
||||
|
||||
offset1Toggle->updateControl(-99, 99, " kph");
|
||||
offset2Toggle->updateControl(-99, 99, " kph");
|
||||
offset3Toggle->updateControl(-99, 99, " kph");
|
||||
offset4Toggle->updateControl(-99, 99, " kph");
|
||||
|
||||
pauseLateralToggle->updateControl(0, 150, " kph");
|
||||
setSpeedOffsetToggle->updateControl(0, 150, " kph");
|
||||
|
||||
stoppingDistanceToggle->updateControl(0, 5, " meters");
|
||||
} else {
|
||||
offset1Toggle->setTitle("Speed Limit Offset (0-34 mph)");
|
||||
offset2Toggle->setTitle("Speed Limit Offset (35-54 mph)");
|
||||
offset3Toggle->setTitle("Speed Limit Offset (55-64 mph)");
|
||||
offset4Toggle->setTitle("Speed Limit Offset (65-99 mph)");
|
||||
|
||||
offset1Toggle->setDescription("Set speed limit offset for limits between 0-34 mph.");
|
||||
offset2Toggle->setDescription("Set speed limit offset for limits between 35-54 mph.");
|
||||
offset3Toggle->setDescription("Set speed limit offset for limits between 55-64 mph.");
|
||||
offset4Toggle->setDescription("Set speed limit offset for limits between 65-99 mph.");
|
||||
|
||||
laneWidthToggle->updateControl(0, 100, " feet", 10);
|
||||
|
||||
mtscLimitToggle->updateControl(0, 99, " mph");
|
||||
|
||||
offset1Toggle->updateControl(-99, 99, " mph");
|
||||
offset2Toggle->updateControl(-99, 99, " mph");
|
||||
offset3Toggle->updateControl(-99, 99, " mph");
|
||||
offset4Toggle->updateControl(-99, 99, " mph");
|
||||
|
||||
pauseLateralToggle->updateControl(0, 99, " mph");
|
||||
setSpeedOffsetToggle->updateControl(0, 99, " mph");
|
||||
|
||||
stoppingDistanceToggle->updateControl(0, 10, " feet");
|
||||
}
|
||||
|
||||
laneWidthToggle->refresh();
|
||||
mtscLimitToggle->refresh();
|
||||
offset1Toggle->refresh();
|
||||
offset2Toggle->refresh();
|
||||
offset3Toggle->refresh();
|
||||
offset4Toggle->refresh();
|
||||
pauseLateralToggle->refresh();
|
||||
setSpeedOffsetToggle->refresh();
|
||||
stoppingDistanceToggle->refresh();
|
||||
|
||||
previousIsMetric = isMetric;
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::parentToggleClicked() {
|
||||
aggressiveProfile->setVisible(false);
|
||||
conditionalSpeedsImperial->setVisible(false);
|
||||
conditionalSpeedsMetric->setVisible(false);
|
||||
modelSelectorButton->setVisible(false);
|
||||
slcPriorityButton->setVisible(false);
|
||||
standardProfile->setVisible(false);
|
||||
relaxedProfile->setVisible(false);
|
||||
|
||||
openParentToggle();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::subParentToggleClicked() {
|
||||
openSubParentToggle();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::hideSubToggles() {
|
||||
aggressiveProfile->setVisible(false);
|
||||
conditionalSpeedsImperial->setVisible(false);
|
||||
conditionalSpeedsMetric->setVisible(false);
|
||||
modelSelectorButton->setVisible(true);
|
||||
slcPriorityButton->setVisible(false);
|
||||
standardProfile->setVisible(false);
|
||||
relaxedProfile->setVisible(false);
|
||||
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
bool subToggles = aolKeys.find(key.c_str()) != aolKeys.end() ||
|
||||
conditionalExperimentalKeys.find(key.c_str()) != conditionalExperimentalKeys.end() ||
|
||||
experimentalModeActivationKeys.find(key.c_str()) != experimentalModeActivationKeys.end() ||
|
||||
fireTheBabysitterKeys.find(key.c_str()) != fireTheBabysitterKeys.end() ||
|
||||
laneChangeKeys.find(key.c_str()) != laneChangeKeys.end() ||
|
||||
lateralTuneKeys.find(key.c_str()) != lateralTuneKeys.end() ||
|
||||
longitudinalTuneKeys.find(key.c_str()) != longitudinalTuneKeys.end() ||
|
||||
mtscKeys.find(key.c_str()) != mtscKeys.end() ||
|
||||
qolKeys.find(key.c_str()) != qolKeys.end() ||
|
||||
speedLimitControllerKeys.find(key.c_str()) != speedLimitControllerKeys.end() ||
|
||||
speedLimitControllerControlsKeys.find(key.c_str()) != speedLimitControllerControlsKeys.end() ||
|
||||
speedLimitControllerQOLKeys.find(key.c_str()) != speedLimitControllerQOLKeys.end() ||
|
||||
speedLimitControllerVisualsKeys.find(key.c_str()) != speedLimitControllerVisualsKeys.end() ||
|
||||
visionTurnControlKeys.find(key.c_str()) != visionTurnControlKeys.end();
|
||||
toggle->setVisible(!subToggles);
|
||||
}
|
||||
|
||||
closeParentToggle();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::hideSubSubToggles() {
|
||||
slcPriorityButton->setVisible(false);
|
||||
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
bool isVisible = speedLimitControllerKeys.find(key.c_str()) != speedLimitControllerKeys.end();
|
||||
toggle->setVisible(isVisible);
|
||||
}
|
||||
|
||||
closeSubParentToggle();
|
||||
update();
|
||||
}
|
||||
|
||||
void FrogPilotControlsPanel::hideEvent(QHideEvent *event) {
|
||||
hideSubToggles();
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/frogpilot_ui_functions.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 closeParentToggle();
|
||||
void closeSubParentToggle();
|
||||
void openParentToggle();
|
||||
void openSubParentToggle();
|
||||
|
||||
private:
|
||||
void hideEvent(QHideEvent *event);
|
||||
void hideSubSubToggles();
|
||||
void hideSubToggles();
|
||||
void parentToggleClicked();
|
||||
void subParentToggleClicked();
|
||||
void updateCarToggles();
|
||||
void updateMetric();
|
||||
void updateState(const UIState &s);
|
||||
void updateToggles();
|
||||
|
||||
ButtonControl *slcPriorityButton;
|
||||
|
||||
FrogPilotButtonIconControl *modelSelectorButton;
|
||||
|
||||
FrogPilotDualParamControl *aggressiveProfile;
|
||||
FrogPilotDualParamControl *conditionalSpeedsImperial;
|
||||
FrogPilotDualParamControl *conditionalSpeedsMetric;
|
||||
FrogPilotDualParamControl *standardProfile;
|
||||
FrogPilotDualParamControl *relaxedProfile;
|
||||
|
||||
std::set<QString> aolKeys = {"AlwaysOnLateralMain", "HideAOLStatusBar"};
|
||||
std::set<QString> conditionalExperimentalKeys = {"CECurves", "CECurvesLead", "CESlowerLead", "CENavigation", "CEStopLights", "CESignal", "HideCEMStatusBar"};
|
||||
std::set<QString> experimentalModeActivationKeys = {"ExperimentalModeViaDistance", "ExperimentalModeViaLKAS", "ExperimentalModeViaScreen"};
|
||||
std::set<QString> fireTheBabysitterKeys = {"NoLogging", "MuteOverheated", "NoUploads", "OfflineMode"};
|
||||
std::set<QString> laneChangeKeys = {"LaneChangeTime", "LaneDetection", "LaneDetectionWidth", "OneLaneChange"};
|
||||
std::set<QString> lateralTuneKeys = {"ForceAutoTune", "NNFF", "SteerRatio", "UseLateralJerk"};
|
||||
std::set<QString> longitudinalTuneKeys = {"AccelerationProfile", "DecelerationProfile", "AggressiveAcceleration", "LeadDetectionThreshold", "SmoothBraking", "StoppingDistance", "TrafficMode"};
|
||||
std::set<QString> mtscKeys = {"DisableMTSCSmoothing", "MTSCAggressiveness", "MTSCCurvatureCheck", "MTSCLimit"};
|
||||
std::set<QString> qolKeys = {"DisableOnroadUploads", "HigherBitrate", "NavChill", "PauseLateralOnSignal", "ReverseCruise", "SetSpeedOffset"};
|
||||
std::set<QString> speedLimitControllerKeys = {"SLCControls", "SLCQOL", "SLCVisuals"};
|
||||
std::set<QString> speedLimitControllerControlsKeys = {"Offset1", "Offset2", "Offset3", "Offset4", "SLCFallback", "SLCOverride", "SLCPriority"};
|
||||
std::set<QString> speedLimitControllerQOLKeys = {"SLCConfirmation", "ForceMPHDashboard", "SetSpeedLimit"};
|
||||
std::set<QString> speedLimitControllerVisualsKeys = {"ShowSLCOffset", "UseVienna"};
|
||||
std::set<QString> visionTurnControlKeys = {"DisableVTSCSmoothing", "CurveSensitivity", "TurnAggressiveness"};
|
||||
|
||||
std::map<std::string, ParamControl*> toggles;
|
||||
|
||||
Params params;
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
|
||||
bool isMetric = params.getBool("IsMetric");
|
||||
bool started = false;
|
||||
|
||||
float steerRatioStock = params.getFloat("SteerRatioStock");
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
#include <filesystem>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/frogpilot_ui_functions.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
bool FrogPilotConfirmationDialog::toggle(const QString &prompt_text, const QString &confirm_text, QWidget *parent) {
|
||||
ConfirmationDialog d = ConfirmationDialog(prompt_text, confirm_text, tr("Reboot Later"), false, parent);
|
||||
return d.exec();
|
||||
}
|
||||
|
||||
bool FrogPilotConfirmationDialog::toggleAlert(const QString &prompt_text, const QString &button_text, QWidget *parent) {
|
||||
ConfirmationDialog d = ConfirmationDialog(prompt_text, button_text, "", false, parent);
|
||||
return d.exec();
|
||||
}
|
||||
|
||||
bool FrogPilotConfirmationDialog::yesorno(const QString &prompt_text, QWidget *parent) {
|
||||
ConfirmationDialog d = ConfirmationDialog(prompt_text, tr("Yes"), tr("No"), false, parent);
|
||||
return d.exec();
|
||||
}
|
||||
|
||||
FrogPilotButtonIconControl::FrogPilotButtonIconControl(const QString &title, const QString &text, const QString &desc, const QString &icon, QWidget *parent) : AbstractControl(title, desc, icon, parent) {
|
||||
btn.setText(text);
|
||||
btn.setStyleSheet(R"(
|
||||
QPushButton {
|
||||
padding: 0;
|
||||
border-radius: 50px;
|
||||
font-size: 35px;
|
||||
font-weight: 500;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #33E4E4E4;
|
||||
}
|
||||
)");
|
||||
btn.setFixedSize(250, 100);
|
||||
QObject::connect(&btn, &QPushButton::clicked, this, &FrogPilotButtonIconControl::clicked);
|
||||
hlayout->addWidget(&btn);
|
||||
}
|
||||
@@ -1,745 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
|
||||
class FrogPilotConfirmationDialog : public ConfirmationDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FrogPilotConfirmationDialog(const QString &prompt_text, const QString &confirm_text,
|
||||
const QString &cancel_text, const bool rich, QWidget* parent);
|
||||
static bool toggle(const QString &prompt_text, const QString &confirm_text, QWidget *parent);
|
||||
static bool toggleAlert(const QString &prompt_text, const QString &button_text, QWidget *parent);
|
||||
static bool yesorno(const QString &prompt_text, QWidget *parent);
|
||||
};
|
||||
|
||||
class FrogPilotListWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FrogPilotListWidget(QWidget *parent = 0) : QWidget(parent), outer_layout(this) {
|
||||
outer_layout.setMargin(0);
|
||||
outer_layout.setSpacing(0);
|
||||
outer_layout.addLayout(&inner_layout);
|
||||
inner_layout.setMargin(0);
|
||||
inner_layout.setSpacing(25); // default spacing is 25
|
||||
outer_layout.addStretch();
|
||||
}
|
||||
inline void addItem(QWidget *w) { inner_layout.addWidget(w); }
|
||||
inline void addItem(QLayout *layout) { inner_layout.addLayout(layout); }
|
||||
inline void setSpacing(int spacing) { inner_layout.setSpacing(spacing); }
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *) override {
|
||||
QPainter p(this);
|
||||
p.setPen(Qt::gray);
|
||||
|
||||
int visibleWidgetCount = 0;
|
||||
std::vector<QRect> visibleRects;
|
||||
|
||||
for (int i = 0; i < inner_layout.count(); ++i) {
|
||||
QWidget *widget = inner_layout.itemAt(i)->widget();
|
||||
if (widget && widget->isVisible()) {
|
||||
visibleWidgetCount++;
|
||||
visibleRects.push_back(inner_layout.itemAt(i)->geometry());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < visibleWidgetCount - 1; ++i) {
|
||||
int bottom = visibleRects[i].bottom() + inner_layout.spacing() / 2;
|
||||
p.drawLine(visibleRects[i].left() + 40, bottom, visibleRects[i].right() - 40, bottom);
|
||||
}
|
||||
}
|
||||
QVBoxLayout outer_layout;
|
||||
QVBoxLayout inner_layout;
|
||||
};
|
||||
|
||||
class FrogPilotDualParamControl : public QFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FrogPilotDualParamControl(ParamControl *control1, ParamControl *control2, QWidget *parent = nullptr, bool split=false)
|
||||
: QFrame(parent) {
|
||||
QHBoxLayout *hlayout = new QHBoxLayout(this);
|
||||
|
||||
control1->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
control1->setMaximumWidth(split ? 850 : 700);
|
||||
|
||||
control2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
control2->setMaximumWidth(split ? 700 : 850);
|
||||
|
||||
hlayout->addWidget(control1);
|
||||
hlayout->addWidget(control2);
|
||||
}
|
||||
};
|
||||
|
||||
class FrogPilotButtonControl : public AbstractControl {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FrogPilotButtonControl(const QString &title, const QString &text, const QString &desc = "", QWidget *parent = nullptr);
|
||||
inline void setText(const QString &text) { btn.setText(text); }
|
||||
inline QString text() const { return btn.text(); }
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
public slots:
|
||||
void setEnabled(bool enabled) { btn.setEnabled(enabled); }
|
||||
|
||||
private:
|
||||
QPushButton btn;
|
||||
};
|
||||
|
||||
class FrogPilotButtonIconControl : public AbstractControl {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FrogPilotButtonIconControl(const QString &title, const QString &text, const QString &desc = "", const QString &icon = "", QWidget *parent = nullptr);
|
||||
inline void setText(const QString &text) { btn.setText(text); }
|
||||
inline QString text() const { return btn.text(); }
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
public slots:
|
||||
void setEnabled(bool enabled) { btn.setEnabled(enabled); }
|
||||
|
||||
private:
|
||||
QPushButton btn;
|
||||
};
|
||||
|
||||
class FrogPilotButtonParamControl : public ParamControl {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FrogPilotButtonParamControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon,
|
||||
const std::vector<QString> &button_texts, const int minimum_button_width = 225)
|
||||
: ParamControl(param, title, desc, icon) {
|
||||
const QString style = R"(
|
||||
QPushButton {
|
||||
border-radius: 50px;
|
||||
font-size: 40px;
|
||||
font-weight: 500;
|
||||
height:100px;
|
||||
padding: 0 25 0 25;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
QPushButton:checked:enabled {
|
||||
background-color: #33Ab4C;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #33E4E4E4;
|
||||
}
|
||||
)";
|
||||
|
||||
key = param.toStdString();
|
||||
int value = atoi(params.get(key).c_str());
|
||||
|
||||
button_group = new QButtonGroup(this);
|
||||
button_group->setExclusive(true);
|
||||
for (size_t i = 0; i < button_texts.size(); i++) {
|
||||
QPushButton *button = new QPushButton(button_texts[i], this);
|
||||
button->setCheckable(true);
|
||||
button->setChecked(i == value);
|
||||
button->setStyleSheet(style);
|
||||
button->setMinimumWidth(minimum_button_width);
|
||||
hlayout->addWidget(button);
|
||||
button_group->addButton(button, i);
|
||||
}
|
||||
|
||||
QObject::connect(button_group, QOverload<int, bool>::of(&QButtonGroup::buttonToggled), [=](int id, bool checked) {
|
||||
if (checked) {
|
||||
params.put(key, std::to_string(id));
|
||||
refresh();
|
||||
emit buttonClicked(id);
|
||||
}
|
||||
});
|
||||
|
||||
toggle.hide();
|
||||
}
|
||||
|
||||
void setEnabled(bool enable) {
|
||||
for (auto btn : button_group->buttons()) {
|
||||
btn->setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonClicked(int id);
|
||||
|
||||
private:
|
||||
std::string key;
|
||||
Params params;
|
||||
QButtonGroup *button_group;
|
||||
};
|
||||
|
||||
class FrogPilotButtonsControl : public ParamControl {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FrogPilotButtonsControl(const QString &title, const QString &desc, const QString &icon,
|
||||
const std::vector<QString> &button_texts, const int minimum_button_width = 225)
|
||||
: ParamControl("", title, desc, icon) {
|
||||
const QString style = R"(
|
||||
QPushButton {
|
||||
border-radius: 50px;
|
||||
font-size: 40px;
|
||||
font-weight: 500;
|
||||
height: 100px;
|
||||
padding: 0 25px 0 25px;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #33Ab4C;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #33E4E4E4;
|
||||
}
|
||||
)";
|
||||
|
||||
button_group = new QButtonGroup(this);
|
||||
|
||||
for (size_t i = 0; i < button_texts.size(); i++) {
|
||||
QPushButton *button = new QPushButton(button_texts[i], this);
|
||||
button->setStyleSheet(style);
|
||||
button->setMinimumWidth(minimum_button_width);
|
||||
hlayout->addWidget(button);
|
||||
button_group->addButton(button, static_cast<int>(i));
|
||||
|
||||
connect(button, &QPushButton::clicked, this, [this, i]() {
|
||||
emit buttonClicked(static_cast<int>(i));
|
||||
});
|
||||
}
|
||||
|
||||
toggle.hide();
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonClicked(int id);
|
||||
|
||||
private:
|
||||
QButtonGroup *button_group;
|
||||
};
|
||||
|
||||
class FrogPilotButtonsParamControl : public ParamControl {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FrogPilotButtonsParamControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon,
|
||||
const std::vector<std::pair<QString, QString>> &button_params)
|
||||
: ParamControl(param, title, desc, icon) {
|
||||
const QString style = R"(
|
||||
QPushButton {
|
||||
border-radius: 50px;
|
||||
font-size: 40px;
|
||||
font-weight: 500;
|
||||
height:100px;
|
||||
padding: 0 25 0 25;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
QPushButton:checked:enabled {
|
||||
background-color: #33Ab4C;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #33E4E4E4;
|
||||
}
|
||||
)";
|
||||
|
||||
button_group = new QButtonGroup(this);
|
||||
button_group->setExclusive(true);
|
||||
|
||||
for (const auto ¶m_pair : button_params) {
|
||||
const QString ¶m_toggle = param_pair.first;
|
||||
const QString &button_text = param_pair.second;
|
||||
|
||||
QPushButton *button = new QPushButton(button_text, this);
|
||||
button->setCheckable(true);
|
||||
|
||||
bool value = params.getBool(param_toggle.toStdString());
|
||||
button->setChecked(value);
|
||||
button->setStyleSheet(style);
|
||||
button->setMinimumWidth(225);
|
||||
hlayout->addWidget(button);
|
||||
|
||||
QObject::connect(button, &QPushButton::toggled, this, [=](bool checked) {
|
||||
if (checked) {
|
||||
for (const auto &inner_param_pair : button_params) {
|
||||
const QString &inner_param = inner_param_pair.first;
|
||||
params.putBool(inner_param.toStdString(), inner_param == param_toggle);
|
||||
}
|
||||
refresh();
|
||||
emit buttonClicked();
|
||||
}
|
||||
});
|
||||
|
||||
button_group->addButton(button);
|
||||
}
|
||||
|
||||
toggle.hide();
|
||||
}
|
||||
|
||||
void setEnabled(bool enable) {
|
||||
for (auto btn : button_group->buttons()) {
|
||||
btn->setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonClicked();
|
||||
|
||||
private:
|
||||
Params params;
|
||||
QButtonGroup *button_group;
|
||||
};
|
||||
|
||||
class FrogPilotParamManageControl : public ParamControl {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FrogPilotParamManageControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon, QWidget *parent = nullptr, bool hideToggle = false)
|
||||
: ParamControl(param, title, desc, icon, parent),
|
||||
hideToggle(hideToggle),
|
||||
key(param.toStdString()),
|
||||
manageButton(new ButtonControl(tr(""), tr("MANAGE"), tr(""))) {
|
||||
hlayout->insertWidget(hlayout->indexOf(&toggle) - 1, manageButton);
|
||||
|
||||
connect(this, &ToggleControl::toggleFlipped, this, [this](bool state) {
|
||||
refresh();
|
||||
});
|
||||
|
||||
connect(manageButton, &ButtonControl::clicked, this, &FrogPilotParamManageControl::manageButtonClicked);
|
||||
|
||||
if (hideToggle) {
|
||||
toggle.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
ParamControl::refresh();
|
||||
manageButton->setVisible(params.getBool(key) || hideToggle);
|
||||
}
|
||||
|
||||
void showEvent(QShowEvent *event) override {
|
||||
ParamControl::showEvent(event);
|
||||
refresh();
|
||||
}
|
||||
|
||||
signals:
|
||||
void manageButtonClicked();
|
||||
|
||||
private:
|
||||
bool hideToggle;
|
||||
std::string key;
|
||||
Params params;
|
||||
ButtonControl *manageButton;
|
||||
};
|
||||
|
||||
class FrogPilotParamToggleControl : public ParamControl {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FrogPilotParamToggleControl(const QString ¶m, const QString &title, const QString &desc,
|
||||
const QString &icon, const std::vector<QString> &button_params,
|
||||
const std::vector<QString> &button_texts, QWidget *parent = nullptr,
|
||||
const int minimum_button_width = 225)
|
||||
: ParamControl(param, title, desc, icon, parent) {
|
||||
|
||||
key = param.toStdString();
|
||||
|
||||
connect(this, &ToggleControl::toggleFlipped, this, [this](bool state) {
|
||||
refreshButtons(state);
|
||||
});
|
||||
|
||||
const QString style = R"(
|
||||
QPushButton {
|
||||
border-radius: 50px;
|
||||
font-size: 40px;
|
||||
font-weight: 500;
|
||||
height:100px;
|
||||
padding: 0 25 0 25;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
QPushButton:checked:enabled {
|
||||
background-color: #33Ab4C;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #33E4E4E4;
|
||||
}
|
||||
)";
|
||||
|
||||
button_group = new QButtonGroup(this);
|
||||
button_group->setExclusive(false);
|
||||
this->button_params = button_params;
|
||||
|
||||
for (int i = 0; i < button_texts.size(); ++i) {
|
||||
QPushButton *button = new QPushButton(button_texts[i], this);
|
||||
button->setCheckable(true);
|
||||
button->setStyleSheet(style);
|
||||
button->setMinimumWidth(minimum_button_width);
|
||||
button_group->addButton(button, i);
|
||||
|
||||
connect(button, &QPushButton::clicked, [this, i](bool checked) {
|
||||
params.putBool(this->button_params[i].toStdString(), checked);
|
||||
button_group->button(i)->setChecked(checked);
|
||||
emit buttonClicked(checked);
|
||||
});
|
||||
|
||||
hlayout->insertWidget(hlayout->indexOf(&toggle) - 1, button);
|
||||
}
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
bool state = params.getBool(key);
|
||||
if (state != toggle.on) {
|
||||
toggle.togglePosition();
|
||||
}
|
||||
|
||||
refreshButtons(state);
|
||||
updateButtonStates();
|
||||
}
|
||||
|
||||
void refreshButtons(bool state) {
|
||||
for (QAbstractButton *button : button_group->buttons()) {
|
||||
button->setVisible(state);
|
||||
}
|
||||
}
|
||||
|
||||
void updateButtonStates() {
|
||||
for (int i = 0; i < button_group->buttons().size(); ++i) {
|
||||
bool checked = params.getBool(button_params[i].toStdString());
|
||||
QAbstractButton *button = button_group->button(i);
|
||||
if (button) {
|
||||
button->setChecked(checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showEvent(QShowEvent *event) override {
|
||||
refresh();
|
||||
QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonClicked(const bool checked);
|
||||
|
||||
private:
|
||||
std::string key;
|
||||
Params params;
|
||||
QButtonGroup *button_group;
|
||||
std::vector<QString> button_params;
|
||||
};
|
||||
|
||||
class FrogPilotParamValueControl : public ParamControl {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FrogPilotParamValueControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon,
|
||||
const float &minValue, const float &maxValue, const std::map<int, QString> &valueLabels,
|
||||
QWidget *parent = nullptr, const bool &loop = true, const QString &label = "",
|
||||
const float &division = 1.0f, const float &intervals = 1.0f)
|
||||
: ParamControl(param, title, desc, icon, parent),
|
||||
minValue(minValue), maxValue(maxValue), valueLabelMappings(valueLabels), loop(loop), labelText(label),
|
||||
division(division), previousValue(0.0f), value(0.0f) {
|
||||
key = param.toStdString();
|
||||
|
||||
valueLabel = new QLabel(this);
|
||||
hlayout->addWidget(valueLabel);
|
||||
|
||||
QPushButton *decrementButton = createButton("-", this);
|
||||
QPushButton *incrementButton = createButton("+", this);
|
||||
|
||||
hlayout->addWidget(decrementButton);
|
||||
hlayout->addWidget(incrementButton);
|
||||
|
||||
countdownTimer = new QTimer(this);
|
||||
countdownTimer->setInterval(150);
|
||||
countdownTimer->setSingleShot(true);
|
||||
|
||||
connect(countdownTimer, &QTimer::timeout, this, &FrogPilotParamValueControl::handleTimeout);
|
||||
|
||||
connect(decrementButton, &QPushButton::pressed, this, [=]() { updateValue(-intervals); });
|
||||
connect(incrementButton, &QPushButton::pressed, this, [=]() { updateValue(intervals); });
|
||||
|
||||
connect(decrementButton, &QPushButton::released, this, &FrogPilotParamValueControl::restartTimer);
|
||||
connect(incrementButton, &QPushButton::released, this, &FrogPilotParamValueControl::restartTimer);
|
||||
|
||||
toggle.hide();
|
||||
}
|
||||
|
||||
void restartTimer() {
|
||||
countdownTimer->stop();
|
||||
countdownTimer->start();
|
||||
}
|
||||
|
||||
void handleTimeout() {
|
||||
previousValue = value;
|
||||
}
|
||||
|
||||
void updateValue(float increment) {
|
||||
if (std::fabs(previousValue - value) > 5.0f && std::fmod(value, 5.0f) == 0.0f) {
|
||||
increment *= 5;
|
||||
}
|
||||
value += increment;
|
||||
|
||||
if (loop) {
|
||||
if (value < minValue) value = maxValue;
|
||||
else if (value > maxValue) value = minValue;
|
||||
} else {
|
||||
value = std::max(minValue, std::min(maxValue, value));
|
||||
}
|
||||
|
||||
params.putFloat(key, value);
|
||||
refresh();
|
||||
emit valueChanged(value);
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
value = params.getFloat(key);
|
||||
|
||||
QString text;
|
||||
auto it = valueLabelMappings.find(value);
|
||||
|
||||
if (division > 1.0f) {
|
||||
text = QString::number(value / division, 'g', division >= 10.0f ? 4 : 3);
|
||||
} else {
|
||||
if (it != valueLabelMappings.end()) {
|
||||
text = it->second;
|
||||
} else {
|
||||
text = QString::number(value, 'g', 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (!labelText.isEmpty()) {
|
||||
text += labelText;
|
||||
}
|
||||
|
||||
valueLabel->setText(text);
|
||||
valueLabel->setStyleSheet("QLabel { color: #E0E879; }");
|
||||
}
|
||||
|
||||
void updateControl(float newMinValue, float newMaxValue, const QString &newLabel, float newDivision = 1.0f) {
|
||||
minValue = newMinValue;
|
||||
maxValue = newMaxValue;
|
||||
labelText = newLabel;
|
||||
division = newDivision;
|
||||
}
|
||||
|
||||
void showEvent(QShowEvent *event) override {
|
||||
refresh();
|
||||
previousValue = value;
|
||||
}
|
||||
|
||||
signals:
|
||||
void valueChanged(float value);
|
||||
|
||||
private:
|
||||
bool loop;
|
||||
float division;
|
||||
float maxValue;
|
||||
float minValue;
|
||||
float previousValue;
|
||||
float value;
|
||||
QLabel *valueLabel;
|
||||
QString labelText;
|
||||
std::map<int, QString> valueLabelMappings;
|
||||
std::string key;
|
||||
Params params;
|
||||
QTimer *countdownTimer;
|
||||
|
||||
QPushButton *createButton(const QString &text, QWidget *parent) {
|
||||
QPushButton *button = new QPushButton(text, parent);
|
||||
button->setFixedSize(150, 100);
|
||||
button->setAutoRepeat(true);
|
||||
button->setAutoRepeatInterval(150);
|
||||
button->setAutoRepeatDelay(500);
|
||||
button->setStyleSheet(R"(
|
||||
QPushButton {
|
||||
border-radius: 50px;
|
||||
font-size: 50px;
|
||||
font-weight: 500;
|
||||
height: 100px;
|
||||
padding: 0 25 0 25;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
)");
|
||||
return button;
|
||||
}
|
||||
};
|
||||
|
||||
class FrogPilotParamValueToggleControl : public ParamControl {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FrogPilotParamValueToggleControl(const QString ¶m, const QString &title, const QString &desc, const QString &icon,
|
||||
const int &minValue, const int &maxValue, const std::map<int, QString> &valueLabels,
|
||||
QWidget *parent = nullptr, const bool &loop = true, const QString &label = "", const int &division = 1,
|
||||
const std::vector<QString> &button_params = std::vector<QString>(), const std::vector<QString> &button_texts = std::vector<QString>(),
|
||||
const int minimum_button_width = 225)
|
||||
: ParamControl(param, title, desc, icon, parent),
|
||||
minValue(minValue), maxValue(maxValue), valueLabelMappings(valueLabels), loop(loop), labelText(label), division(division) {
|
||||
key = param.toStdString();
|
||||
|
||||
const QString style = R"(
|
||||
QPushButton {
|
||||
border-radius: 50px;
|
||||
font-size: 40px;
|
||||
font-weight: 500;
|
||||
height:100px;
|
||||
padding: 0 25 0 25;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
QPushButton:checked:enabled {
|
||||
background-color: #33Ab4C;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #33E4E4E4;
|
||||
}
|
||||
)";
|
||||
|
||||
button_group = new QButtonGroup(this);
|
||||
button_group->setExclusive(false);
|
||||
|
||||
std::map<QString, bool> paramState;
|
||||
for (const QString &button_param : button_params) {
|
||||
paramState[button_param] = params.getBool(button_param.toStdString());
|
||||
}
|
||||
|
||||
for (int i = 0; i < button_texts.size(); ++i) {
|
||||
QPushButton *button = new QPushButton(button_texts[i], this);
|
||||
button->setCheckable(true);
|
||||
button->setChecked(paramState[button_params[i]]);
|
||||
button->setStyleSheet(style);
|
||||
button->setMinimumWidth(minimum_button_width);
|
||||
button_group->addButton(button, i);
|
||||
|
||||
connect(button, &QPushButton::clicked, [this, button_params, i](bool checked) {
|
||||
params.putBool(button_params[i].toStdString(), checked);
|
||||
button_group->button(i)->setChecked(checked);
|
||||
});
|
||||
|
||||
hlayout->addWidget(button);
|
||||
}
|
||||
|
||||
valueLabel = new QLabel(this);
|
||||
hlayout->addWidget(valueLabel);
|
||||
|
||||
QPushButton *decrementButton = createButton("-", this);
|
||||
QPushButton *incrementButton = createButton("+", this);
|
||||
|
||||
hlayout->addWidget(decrementButton);
|
||||
hlayout->addWidget(incrementButton);
|
||||
|
||||
connect(decrementButton, &QPushButton::clicked, this, [=]() {
|
||||
updateValue(-1);
|
||||
});
|
||||
|
||||
connect(incrementButton, &QPushButton::clicked, this, [=]() {
|
||||
updateValue(1);
|
||||
});
|
||||
|
||||
toggle.hide();
|
||||
}
|
||||
|
||||
void updateValue(int increment) {
|
||||
value = value + increment;
|
||||
|
||||
if (loop) {
|
||||
if (value < minValue) value = maxValue;
|
||||
else if (value > maxValue) value = minValue;
|
||||
} else {
|
||||
value = std::max(minValue, std::min(maxValue, value));
|
||||
}
|
||||
|
||||
params.putInt(key, value);
|
||||
refresh();
|
||||
emit valueChanged(value);
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
value = params.getInt(key);
|
||||
|
||||
QString text;
|
||||
auto it = valueLabelMappings.find(value);
|
||||
if (division > 1) {
|
||||
text = QString::number(value / (division * 1.0), 'g');
|
||||
} else {
|
||||
text = it != valueLabelMappings.end() ? it->second : QString::number(value);
|
||||
}
|
||||
if (!labelText.isEmpty()) {
|
||||
text += labelText;
|
||||
}
|
||||
valueLabel->setText(text);
|
||||
valueLabel->setStyleSheet("QLabel { color: #E0E879; }");
|
||||
}
|
||||
|
||||
void updateControl(int newMinValue, int newMaxValue, const QString &newLabel, int newDivision) {
|
||||
minValue = newMinValue;
|
||||
maxValue = newMaxValue;
|
||||
labelText = newLabel;
|
||||
division = newDivision;
|
||||
}
|
||||
|
||||
void showEvent(QShowEvent *event) override {
|
||||
refresh();
|
||||
}
|
||||
|
||||
signals:
|
||||
void valueChanged(int value);
|
||||
|
||||
private:
|
||||
bool loop;
|
||||
int division;
|
||||
int maxValue;
|
||||
int minValue;
|
||||
int value;
|
||||
QButtonGroup *button_group;
|
||||
QLabel *valueLabel;
|
||||
QString labelText;
|
||||
std::map<int, QString> valueLabelMappings;
|
||||
std::string key;
|
||||
Params params;
|
||||
|
||||
QPushButton *createButton(const QString &text, QWidget *parent) {
|
||||
QPushButton *button = new QPushButton(text, parent);
|
||||
button->setFixedSize(150, 100);
|
||||
button->setAutoRepeat(true);
|
||||
button->setAutoRepeatInterval(150);
|
||||
button->setAutoRepeatDelay(350);
|
||||
button->setStyleSheet(R"(
|
||||
QPushButton {
|
||||
border-radius: 50px;
|
||||
font-size: 50px;
|
||||
font-weight: 500;
|
||||
height: 100px;
|
||||
padding: 0 25 0 25;
|
||||
color: #E4E4E4;
|
||||
background-color: #393939;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #4a4a4a;
|
||||
}
|
||||
)");
|
||||
return button;
|
||||
}
|
||||
};
|
||||
@@ -1,233 +0,0 @@
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/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["subaru"] = "subaru";
|
||||
makeMap["tesla"] = "tesla";
|
||||
makeMap["toyota"] = "toyota";
|
||||
makeMap["volkswagen"] = "volkswagen";
|
||||
makeMap["skoda"] = "volkswagen";
|
||||
|
||||
QString dirPath = "../../selfdrive/car";
|
||||
QDir dir(dirPath);
|
||||
QString targetFolder = makeMap.value(carMake, carMake);
|
||||
QStringList names;
|
||||
|
||||
foreach (const QString &folder, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||
if (folder == targetFolder) {
|
||||
QFile file(dirPath + "/" + folder + "/values.py");
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QRegularExpression regex("class CAR\\(StrEnum\\):([\\s\\S]*?)(?=^\\w)", QRegularExpression::MultilineOption);
|
||||
QRegularExpressionMatch match = regex.match(QTextStream(&file).readAll());
|
||||
file.close();
|
||||
|
||||
if (match.hasMatch()) {
|
||||
QRegularExpression nameRegex("=\\s*\"([^\"]+)\"");
|
||||
QRegularExpressionMatchIterator it = nameRegex.globalMatch(match.captured(1));
|
||||
while (it.hasNext()) {
|
||||
names << it.next().captured(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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", "Subaru", "Tesla", "Toyota", "Volkswagen", "Volvo", "Škoda",
|
||||
};
|
||||
|
||||
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", "Disable Automatic Fingerprint Detection", "Forces the selected fingerprint and prevents it from ever changing.", "", this);
|
||||
addItem(forceFingerprint);
|
||||
|
||||
ParamControl *disableOpenpilotLong = new ParamControl("DisableOpenpilotLongitudinal", "Disable Openpilot Longitudinal Control", "Disables openpilot longitudinal control to use stock ACC.", "", this);
|
||||
addItem(disableOpenpilotLong);
|
||||
|
||||
QObject::connect(disableOpenpilotLong, &ToggleControl::toggleFlipped, [=]() {
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) {
|
||||
Hardware::reboot();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
std::vector<std::tuple<QString, QString, QString, QString>> vehicleToggles {
|
||||
{"EVTable", "EV Lookup Tables", "Smoothen out the gas and brake controls for EV vehicles.", ""},
|
||||
{"GasRegenCmd", "GM Truck Gas Tune", "Increase acceleration and smoothen brake to stop. For use on Silverado/Sierra only.", ""},
|
||||
{"LongPitch", "Long Pitch Compensation", "Reduce speed and acceleration error for greater passenger comfort and improved vehicle efficiency.", ""},
|
||||
{"LowerVolt", "Lower Volt Enable Speed", "Lower the Volt's minimum enable speed to enable openpilot at any speed.", ""},
|
||||
|
||||
{"CrosstrekTorque", "Subaru Crosstrek Torque Increase", "Increases the maximum allowed torque for the Subaru Crosstrek.", ""},
|
||||
|
||||
{"LockDoors", "Lock Doors In Drive", "Automatically lock the doors when in drive and unlock when in park.", ""},
|
||||
{"LongitudinalTune", "Longitudinal Tune", "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 my 2019 Lexus ES 350", ""},
|
||||
{"SNGHack", "Stop and Go Hack", "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's")},
|
||||
{"DragonPilotTune", tr("DragonPilot's")},
|
||||
{"FrogsGoMooTune", tr("FrogPilot's")},
|
||||
};
|
||||
toggle = new FrogPilotButtonsParamControl(param, title, desc, icon, tuneOptions);
|
||||
|
||||
QObject::connect(static_cast<FrogPilotButtonsParamControl*>(toggle), &FrogPilotButtonsParamControl::buttonClicked, [this]() {
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) {
|
||||
Hardware::soft_reboot();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} 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<std::string> rebootKeys = {"CrosstrekTorque", "GasRegenCmd", "LowerVolt"};
|
||||
for (const std::string &key : rebootKeys) {
|
||||
QObject::connect(toggles[key], &ToggleControl::toggleFlipped, [this]() {
|
||||
if (started) {
|
||||
if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) {
|
||||
Hardware::soft_reboot();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, [this](bool offroad) {
|
||||
if (!offroad) {
|
||||
std::thread([this]() {
|
||||
while (carMake.isEmpty()) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
carMake = QString::fromStdString(params.get("CarMake"));
|
||||
}
|
||||
setModels();
|
||||
}).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) {
|
||||
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::setModels() {
|
||||
models = getCarNames(carMake.toLower());
|
||||
setToggles();
|
||||
}
|
||||
|
||||
void FrogPilotVehiclesPanel::setToggles() {
|
||||
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";
|
||||
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
if (toggle) {
|
||||
toggle->setVisible(false);
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/frogpilot_ui_functions.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 setModels();
|
||||
void setToggles();
|
||||
void updateState(const UIState &s);
|
||||
void updateToggles();
|
||||
|
||||
ButtonControl *selectMakeButton;
|
||||
ButtonControl *selectModelButton;
|
||||
|
||||
QString carMake;
|
||||
QStringList models;
|
||||
|
||||
std::map<std::string, ParamControl*> toggles;
|
||||
|
||||
std::set<QString> gmKeys = {"EVTable", "GasRegenCmd", "LongPitch", "LowerVolt"};
|
||||
std::set<QString> subaruKeys = {"CrosstrekTorque"};
|
||||
std::set<QString> toyotaKeys = {"LockDoors", "LongitudinalTune", "SNGHack"};
|
||||
|
||||
Params params;
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
|
||||
bool started = false;
|
||||
};
|
||||
@@ -1,388 +0,0 @@
|
||||
#include "selfdrive/frogpilot/ui/visual_settings.h"
|
||||
|
||||
FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
|
||||
const std::vector<std::tuple<QString, QString, QString, QString>> visualToggles {
|
||||
{"CustomTheme", "Custom Themes", "Enable the ability to use custom themes.", "../frogpilot/assets/wheel_images/frog.png"},
|
||||
{"HolidayThemes", "Holiday Themes", "The openpilot theme changes according to the current/upcoming holiday. Minor holidays last a day, major holidays (Easter, Christmas, Halloween, etc.) last a week.", ""},
|
||||
{"CustomColors", "Color Theme", "Switch out the standard openpilot color scheme with a custom color scheme.\n\nWant to submit your own color scheme? Post it in the 'feature-request' channel in the FrogPilot Discord!", ""},
|
||||
{"CustomIcons", "Icon Pack", "Switch out the standard openpilot icons with a set of custom icons.\n\nWant to submit your own icon pack? Post it in the 'feature-request' channel in the FrogPilot Discord!", ""},
|
||||
{"CustomSignals", "Turn Signals", "Add custom animations for your turn signals for a personal touch!\n\nWant to submit your own turn signal animation? Post it in the 'feature-request' channel in the FrogPilot Discord!", ""},
|
||||
{"CustomSounds", "Sound Pack", "Switch out the standard openpilot sounds with a set of custom sounds.\n\nWant to submit your own sound pack? Post it in the 'feature-request' channel in the FrogPilot Discord!", ""},
|
||||
|
||||
{"AlertVolumeControl", "Alert Volume Control", "Control the volume level for each individual sound in openpilot.", "../frogpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"DisengageVolume", "Disengage Volume", "Related alerts:\n\nAdaptive Cruise Disabled\nParking Brake Engaged\nPedal Pressed\nSpeed too Low", ""},
|
||||
{"EngageVolume", "Engage Volume", "Related alerts:\n\nNNFF Torque Controller loaded", ""},
|
||||
{"PromptVolume", "Prompt Volume", "Related alerts:\n\nCar Detected in Blindspot\nLight turned green\nSpeed too Low\nSteer Unavailable Below 'X'\nTake Control, Turn Exceeds Steering Limit", ""},
|
||||
{"PromptDistractedVolume", "Prompt Distracted Volume", "Related alerts:\n\nPay Attention, Driver Distracted\nTouch Steering Wheel, Driver Unresponsive", ""},
|
||||
{"RefuseVolume", "Refuse Volume", "Related alerts:\n\nopenpilot Unavailable", ""},
|
||||
{"WarningSoftVolume", "Warning Soft Volume", "Related alerts:\n\nBRAKE!, Risk of Collision\nTAKE CONTROL IMMEDIATELY", ""},
|
||||
{"WarningImmediateVolume", "Warning Immediate Volume", "Related alerts:\n\nDISENGAGE IMMEDIATELY, Driver Distracted\nDISENGAGE IMMEDIATELY, Driver Unresponsive", ""},
|
||||
|
||||
{"CameraView", "Camera View", "Choose your preferred camera view for the onroad UI. This is a visual change only and doesn't impact openpilot.", "../frogpilot/assets/toggle_icons/icon_camera.png"},
|
||||
{"Compass", "Compass", "Add a compass to your onroad UI.", "../frogpilot/assets/toggle_icons/icon_compass.png"},
|
||||
|
||||
{"CustomAlerts", "Custom Alerts", "Enable custom alerts for various logic or situational changes.", "../frogpilot/assets/toggle_icons/icon_green_light.png"},
|
||||
{"GreenLightAlert", "Green Light Alert", "Get an alert when a traffic light changes from red to green.", ""},
|
||||
{"LeadDepartingAlert", "Lead Departing Alert", "Get an alert when your lead vehicle starts departing when you're at a standstill.", ""},
|
||||
{"LoudBlindspotAlert", "Loud Blindspot Alert", "Enable a louder alert for when a vehicle is detected in your blindspot when attempting to change lanes.", ""},
|
||||
{"SpeedLimitChangedAlert", "Speed Limit Changed Alert", "Trigger an alert whenever the current speed limit changes.", ""},
|
||||
|
||||
{"CustomUI", "Custom Onroad UI", "Customize the Onroad UI with some additional visual functions.", "../assets/offroad/icon_road.png"},
|
||||
{"AccelerationPath", "Acceleration Path", "Visualize the car's intended acceleration or deceleration with a color-coded path.", ""},
|
||||
{"AdjacentPath", "Adjacent Paths", "Display paths to the left and right of your car, visualizing where the model detects lanes.", ""},
|
||||
{"BlindSpotPath", "Blind Spot Path", "Visualize your blind spots with a red path when another vehicle is detected nearby.", ""},
|
||||
{"FPSCounter", "FPS Counter", "Display the Frames Per Second (FPS) of your onroad UI for monitoring system performance.", ""},
|
||||
{"LeadInfo", "Lead Info and Logics", "Get detailed information about the vehicle ahead, including speed and distance, and the logic behind your following distance.", ""},
|
||||
{"PedalsOnUI", "Pedals Being Pressed", "Display which pedals are being pressed on the onroad UI below the steering wheel icon.", ""},
|
||||
{"RoadNameUI", "Road Name", "See the name of the road you're on at the bottom of your screen. Sourced from OpenStreetMap.", ""},
|
||||
|
||||
{"DriverCamera", "Driver Camera On Reverse", "Show the driver's camera feed when you shift to reverse.", "../assets/img_driver_face_static.png"},
|
||||
|
||||
{"ModelUI", "Model UI", "Personalize how the model's visualizations appear on your screen.", "../assets/offroad/icon_calibration.png"},
|
||||
{"DynamicPathWidth", "Dynamic Path Width", "Have the path width dynamically adjust based on the current engagement state of openpilot.", ""},
|
||||
{"HideLeadMarker", "Hide Lead Marker", "Hide the lead marker from the onroad UI.", ""},
|
||||
{"LaneLinesWidth", "Lane Lines", "Adjust the visual thickness of lane lines on your display.\n\nDefault matches the MUTCD average of 4 inches.", ""},
|
||||
{"PathEdgeWidth", "Path Edges", "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 with 'FrogPilot Colors'\nLight Green = Default with stock colors\nOrange = Experimental Mode Active\nYellow = Conditional Overriden", ""},
|
||||
{"PathWidth", "Path Width", "Customize the width of the driving path shown on your UI.\n\nDefault matches the width of a 2019 Lexus ES 350.", ""},
|
||||
{"RoadEdgesWidth", "Road Edges", "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", "'Unlimited' Road UI Length", "Extend the display of the path, lane lines, and road edges as far as the system can detect, providing a more expansive view of the road ahead.", ""},
|
||||
|
||||
{"NumericalTemp", "Numerical Temperature Gauge", "Replace the 'GOOD', 'OK', and 'HIGH' temperature statuses with a numerical temperature gauge based on the highest temperature between the memory, CPU, and GPU.", "../frogpilot/assets/toggle_icons/icon_temperature.png"},
|
||||
|
||||
{"QOLVisuals", "Quality of Life", "Miscellaneous quality of life changes to improve your overall openpilot experience.", "../frogpilot/assets/toggle_icons/quality_of_life.png"},
|
||||
{"DriveStats", "Drive Stats In Home Screen", "Display your device's drive stats in the home screen.", ""},
|
||||
{"FullMap", "Full Sized Map", "Maximize the size of the map in the onroad UI.", ""},
|
||||
{"HideSpeed", "Hide Speed", "Hide the speed indicator in the onroad UI. Additional toggle allows it to be hidden/shown via tapping the speed itself.", ""},
|
||||
{"MapStyle", "Map Style", "Use a custom map style to be used for 'Navigate on openpilot'.", ""},
|
||||
{"WheelSpeed", "Use Wheel Speed", "Use the wheel speed metric as opposed to the artificial speed.", ""},
|
||||
|
||||
{"RandomEvents", "Random Events", "Enjoy a bit of unpredictability with random events that can occur during certain driving conditions.", "../frogpilot/assets/toggle_icons/icon_random.png"},
|
||||
|
||||
{"ScreenManagement", "Screen Management", "Manage your screen's brightness, timeout settings, and hide specific onroad UI elements.", "../frogpilot/assets/toggle_icons/icon_light.png"},
|
||||
{"HideUIElements", "Hide UI Elements", "Hide the selected UI elements from the onroad screen.", ""},
|
||||
{"ScreenBrightness", "Screen Brightness", "Customize your screen brightness when offroad.", ""},
|
||||
{"ScreenBrightnessOnroad", "Screen Brightness (Onroad)", "Customize your screen brightness when onroad.", ""},
|
||||
{"ScreenRecorder", "Screen Recorder", "Enable the screen recorder button to record the screen.", ""},
|
||||
{"ScreenTimeout", "Screen Timeout", "Customize how long it takes for your screen to turn off.", ""},
|
||||
{"ScreenTimeoutOnroad", "Screen Timeout (Onroad)", "Customize how long it takes for your screen to turn off after going onroad.", ""},
|
||||
{"StandbyMode", "Standby Mode", "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.", ""},
|
||||
|
||||
{"WheelIcon", "Steering Wheel Icon", "Replace the default steering wheel icon with a custom design, adding a unique touch to your interface.", "../assets/offroad/icon_openpilot.png"},
|
||||
};
|
||||
|
||||
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]() {
|
||||
parentToggleClicked();
|
||||
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 == "CameraView") {
|
||||
std::vector<QString> cameraOptions{tr("Auto"), tr("Standard"), tr("Wide"), tr("Driver")};
|
||||
FrogPilotButtonParamControl *preferredCamera = new FrogPilotButtonParamControl(param, title, desc, icon, cameraOptions);
|
||||
toggle = preferredCamera;
|
||||
|
||||
} else if (param == "CustomAlerts") {
|
||||
FrogPilotParamManageControl *customAlertsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(customAlertsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(customAlertsKeys .find(key.c_str()) != customAlertsKeys .end());
|
||||
}
|
||||
});
|
||||
toggle = customAlertsToggle;
|
||||
|
||||
} else if (param == "CustomTheme") {
|
||||
FrogPilotParamManageControl *customThemeToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(customThemeToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(customThemeKeys.find(key.c_str()) != customThemeKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = customThemeToggle;
|
||||
} else if (customThemeKeys.find(param) != customThemeKeys.end() && param != "HolidayThemes") {
|
||||
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("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]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(customOnroadUIKeys.find(key.c_str()) != customOnroadUIKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = customUIToggle;
|
||||
} 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 == "AdjacentPath") {
|
||||
std::vector<QString> adjacentPathToggles{"AdjacentPathMetrics"};
|
||||
std::vector<QString> adjacentPathToggleNames{tr("Display Metrics")};
|
||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, adjacentPathToggles, adjacentPathToggleNames);
|
||||
|
||||
} else if (param == "ModelUI") {
|
||||
FrogPilotParamManageControl *modelUIToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(modelUIToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(modelUIKeys.find(key.c_str()) != modelUIKeys.end());
|
||||
}
|
||||
});
|
||||
toggle = modelUIToggle;
|
||||
} else if (param == "LaneLinesWidth" || param == "RoadEdgesWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 24, std::map<int, QString>(), this, false, " inches");
|
||||
} else if (param == "PathEdgeWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, "%");
|
||||
} else if (param == "PathWidth") {
|
||||
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, " feet", 10);
|
||||
|
||||
} 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 == "QOLVisuals") {
|
||||
FrogPilotParamManageControl *qolToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(qolToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
toggle->setVisible(qolKeys.find(key.c_str()) != qolKeys.end());
|
||||
}
|
||||
mapStyleButton->setVisible(true);
|
||||
});
|
||||
toggle = qolToggle;
|
||||
} 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 == "ScreenManagement") {
|
||||
FrogPilotParamManageControl *screenToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||
QObject::connect(screenToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||
parentToggleClicked();
|
||||
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 ? "Screen Off" : i == 101 ? "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, " seconds");
|
||||
|
||||
} else if (param == "WheelIcon") {
|
||||
std::vector<QString> wheelToggles{"RotatingWheel"};
|
||||
std::vector<QString> wheelToggleNames{tr("Rotating")};
|
||||
std::map<int, QString> steeringWheelLabels = {{-1, "None"}, {0, "Stock"}, {1, "Lexus"}, {2, "Toyota"}, {3, "Frog"}, {4, "Rocket"}, {5, "Hyundai"}, {6, "Stalin"}};
|
||||
toggle = new FrogPilotParamValueToggleControl(param, title, desc, icon, -1, 6, steeringWheelLabels, this, true, "", 1, wheelToggles, wheelToggleNames);
|
||||
|
||||
} 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();
|
||||
});
|
||||
}
|
||||
|
||||
std::set<std::string> rebootKeys = {"DriveStats"};
|
||||
for (const std::string &key : rebootKeys) {
|
||||
QObject::connect(toggles[key], &ToggleControl::toggleFlipped, [this, key]() {
|
||||
if (started || key == "DriveStats") {
|
||||
if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) {
|
||||
Hardware::soft_reboot();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QObject::connect(device(), &Device::interactiveTimeout, this, &FrogPilotVisualsPanel::hideSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::closeParentToggle, this, &FrogPilotVisualsPanel::hideSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::closeSubParentToggle, this, &FrogPilotVisualsPanel::hideSubSubToggles);
|
||||
QObject::connect(parent, &SettingsWindow::updateMetric, this, &FrogPilotVisualsPanel::updateMetric);
|
||||
QObject::connect(uiState(), &UIState::uiUpdate, this, &FrogPilotVisualsPanel::updateState);
|
||||
|
||||
hideSubToggles();
|
||||
updateMetric();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::updateState(const UIState &s) {
|
||||
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::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("Customize the lane line width.\n\nDefault matches the Vienna average of 10 centimeters.");
|
||||
roadEdgesWidthToggle->setDescription("Customize the road edges width.\n\nDefault is 1/2 of the Vienna average lane line width of 10 centimeters.");
|
||||
|
||||
laneLinesWidthToggle->updateControl(0, 60, " centimeters");
|
||||
roadEdgesWidthToggle->updateControl(0, 60, " centimeters");
|
||||
pathWidthToggle->updateControl(0, 30, " meters", 10);
|
||||
} else {
|
||||
laneLinesWidthToggle->setDescription("Customize the lane line width.\n\nDefault matches the MUTCD average of 4 inches.");
|
||||
roadEdgesWidthToggle->setDescription("Customize the road edges width.\n\nDefault is 1/2 of the MUTCD average lane line width of 4 inches.");
|
||||
|
||||
laneLinesWidthToggle->updateControl(0, 24, " inches");
|
||||
roadEdgesWidthToggle->updateControl(0, 24, " inches");
|
||||
pathWidthToggle->updateControl(0, 100, " feet", 10);
|
||||
}
|
||||
|
||||
laneLinesWidthToggle->refresh();
|
||||
roadEdgesWidthToggle->refresh();
|
||||
|
||||
previousIsMetric = isMetric;
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::parentToggleClicked() {
|
||||
mapStyleButton->setVisible(false);
|
||||
|
||||
openParentToggle();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::subParentToggleClicked() {
|
||||
mapStyleButton->setVisible(false);
|
||||
|
||||
openSubParentToggle();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::hideSubToggles() {
|
||||
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);
|
||||
}
|
||||
|
||||
closeParentToggle();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::hideSubSubToggles() {
|
||||
for (auto &[key, toggle] : toggles) {
|
||||
bool isVisible = false;
|
||||
toggle->setVisible(isVisible);
|
||||
}
|
||||
|
||||
closeSubParentToggle();
|
||||
update();
|
||||
}
|
||||
|
||||
void FrogPilotVisualsPanel::hideEvent(QHideEvent *event) {
|
||||
hideSubToggles();
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "selfdrive/frogpilot/ui/frogpilot_ui_functions.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 closeParentToggle();
|
||||
void closeSubParentToggle();
|
||||
void openParentToggle();
|
||||
void openSubParentToggle();
|
||||
|
||||
private:
|
||||
void hideEvent(QHideEvent *event);
|
||||
void hideSubToggles();
|
||||
void hideSubSubToggles();
|
||||
void parentToggleClicked();
|
||||
void subParentToggleClicked();
|
||||
void updateMetric();
|
||||
void updateState(const UIState &s);
|
||||
void updateToggles();
|
||||
|
||||
ButtonControl *mapStyleButton;
|
||||
|
||||
std::set<QString> alertVolumeControlKeys = {"EngageVolume", "DisengageVolume", "RefuseVolume", "PromptVolume", "PromptDistractedVolume", "WarningSoftVolume", "WarningImmediateVolume"};
|
||||
std::set<QString> customAlertsKeys = {"GreenLightAlert", "LeadDepartingAlert", "LoudBlindspotAlert", "SpeedLimitChangedAlert"};
|
||||
std::set<QString> customOnroadUIKeys = {"AccelerationPath", "AdjacentPath", "BlindSpotPath", "FPSCounter", "LeadInfo", "PedalsOnUI", "RoadNameUI"};
|
||||
std::set<QString> customThemeKeys = {"HolidayThemes", "CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"};
|
||||
std::set<QString> modelUIKeys = {"DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"};
|
||||
std::set<QString> qolKeys = {"DriveStats", "FullMap", "HideSpeed", "MapStyle", "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 isMetric = params.getBool("IsMetric");
|
||||
bool started = false;
|
||||
};
|
||||
Reference in New Issue
Block a user