From 0a4599280b2b8e82980bed6f62dc852de19393b8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 17 Feb 2024 19:02:33 -0600 Subject: [PATCH] wip --- selfdrive/oscarpilot/settings/basic.cc | 8 +- selfdrive/oscarpilot/settings/basic.example | 280 ++++++++++++++++++ selfdrive/oscarpilot/settings/basic.h.example | 4 +- .../oscarpilot/settings/newmenus | 0 selfdrive/oscarpilot/settings/settings.cc | 4 +- selfdrive/ui/qt/text.cc | 40 ++- update.sh | 35 +++ update_and_launch_openpilot.sh | 38 +-- 8 files changed, 357 insertions(+), 52 deletions(-) rename newmenus => selfdrive/oscarpilot/settings/newmenus (100%) create mode 100644 update.sh diff --git a/selfdrive/oscarpilot/settings/basic.cc b/selfdrive/oscarpilot/settings/basic.cc index 0ec2c4d..1d3e417 100644 --- a/selfdrive/oscarpilot/settings/basic.cc +++ b/selfdrive/oscarpilot/settings/basic.cc @@ -41,7 +41,7 @@ OscarPilotBasicPanel::OscarPilotBasicPanel(OscarSettingsWindow *parent) : FrogPi // } } -void OscarPilotVisualsPanel::updateToggles() { +void OscarPilotBasicPanel::updateToggles() { std::thread([this]() { paramsMemory.putBool("FrogPilotTogglesUpdated", true); std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -49,11 +49,11 @@ void OscarPilotVisualsPanel::updateToggles() { }).detach(); } -void OscarPilotVisualsPanel::parentToggleClicked() { +void OscarPilotBasicPanel::parentToggleClicked() { this->openParentToggle(); } -void OscarPilotVisualsPanel::hideSubToggles() { +void OscarPilotBasicPanel::hideSubToggles() { // for (auto &[key, toggle] : toggles) { // bool subToggles = modelUIKeys.find(key.c_str()) != modelUIKeys.end() || // customOnroadUIKeys.find(key.c_str()) != customOnroadUIKeys.end() || @@ -65,6 +65,6 @@ void OscarPilotVisualsPanel::hideSubToggles() { this->closeParentToggle(); } -void OscarPilotVisualsPanel::hideEvent(QHideEvent *event) { +void OscarPilotBasicPanel::hideEvent(QHideEvent *event) { hideSubToggles(); } diff --git a/selfdrive/oscarpilot/settings/basic.example b/selfdrive/oscarpilot/settings/basic.example index e69de29..d3af63b 100644 --- a/selfdrive/oscarpilot/settings/basic.example +++ b/selfdrive/oscarpilot/settings/basic.example @@ -0,0 +1,280 @@ +#include "selfdrive/oscarpilot/settings/basic.h" +#include "selfdrive/ui/ui.h" + +OscarPilotBasicPanel::OscarPilotBasicPanel(OscarSettingsWindow *parent) : FrogPilotListWidget(parent) { + const std::vector> visualToggles { + {"CustomTheme", "Custom Themes", "Enable the ability to use custom themes.", "../frogpilot/assets/wheel_images/frog.png"}, + {"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!", ""}, + + {"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"}, + + {"CustomUI", "Custom Onroad UI", "Customize the Onroad UI with some additional visual functions.", "../assets/offroad/icon_road.png"}, + {"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.", ""}, + {"ShowFPS", "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.", ""}, + {"RoadNameUI", "Road Name", "See the name of the road you're on at the bottom of your screen. Sourced from OpenStreetMap.", ""}, + {"UseVienna", "Use Vienna Speed Limit Signs", "Use the Vienna (EU) speed limit style signs as opposed to MUTCD (US).", ""}, + + {"DriverCamera", "Driver Camera On Reverse", "Show the driver's camera feed when you shift to reverse.", "../assets/img_driver_face_static.png"}, + {"GreenLightAlert", "Green Light Alert", "Get an alert when a traffic light changes from red to green.", "../frogpilot/assets/toggle_icons/icon_green_light.png"}, + + {"ModelUI", "Model UI", "Personalize how the model's visualizations appear on your screen.", "../assets/offroad/icon_calibration.png"}, + {"AccelerationPath", "Acceleration Path", "Visualize the car's intended acceleration or deceleration with a color-coded path.", ""}, + {"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.", ""}, + + {"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.", ""}, + {"HideSpeed", "Hide Speed", "Hide the speed indicator in the onroad UI.", ""}, + {"ShowSLCOffset", "Show Speed Limit Offset", "Show the speed limit offset seperated from the speed limit in the onroad UI when using 'Speed Limit Controller'.", ""}, + + {"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"}, + {"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"}, + {"SilentMode", "Silent Mode", "Mute openpilot sounds for a quieter driving experience.", "../frogpilot/assets/toggle_icons/icon_mute.png"}, + {"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 == "CameraView") { + std::vector cameraOptions{tr("Auto"), tr("Standard"), tr("Wide"), tr("Driver")}; + FrogPilotButtonParamControl *preferredCamera = new FrogPilotButtonParamControl(param, title, desc, icon, cameraOptions); + toggle = preferredCamera; + + } 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 (param == "CustomColors" || param == "CustomIcons" || param == "CustomSignals" || param == "CustomSounds") { + std::vector 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(toggle), &FrogPilotButtonParamControl::buttonClicked, [this](int id) { + if (id == 1) { + if (FrogPilotConfirmationDialog::yesorno("Do you want to enable the bonus 'Goat' sound effect?", this)) { + params.putBool("GoatScream", true); + } else { + params.putBool("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 leadInfoToggles{tr("UseSI")}; + std::vector leadInfoToggleNames{tr("Use SI Values")}; + toggle = new FrogPilotParamToggleControl(param, title, desc, icon, leadInfoToggles, leadInfoToggleNames); + + } 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(), this, false, " inches"); + } else if (param == "PathEdgeWidth") { + toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map(), this, false, "%"); + } else if (param == "PathWidth") { + toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map(), this, false, " feet", 10); + + } 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()); + } + }); + toggle = qolToggle; + + } else if (param == "ScreenBrightness") { + std::map 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 == "WheelIcon") { + std::vector wheelToggles{"RotatingWheel"}; + std::vector wheelToggleNames{tr("Rotating")}; + std::map steeringWheelLabels = {{0, "Stock"}, {1, "Lexus"}, {2, "Toyota"}, {3, "Frog"}, {4, "Rocket"}, {5, "Hyundai"}, {6, "Stalin"}}; + toggle = new FrogPilotParamValueToggleControl(param, title, desc, icon, 0, 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(toggle), &FrogPilotParamValueControl::buttonPressed, [this]() { + updateToggles(); + }); + + QObject::connect(toggle, &AbstractControl::showDescriptionEvent, [this]() { + update(); + }); + + QObject::connect(static_cast(toggle), &FrogPilotParamManageControl::manageButtonClicked, [this]() { + update(); + }); + } + + std::set rebootKeys = {"DriveStats"}; + for (const std::string &key : rebootKeys) { + QObject::connect(toggles[key], &ToggleControl::toggleFlipped, [this]() { + if (FrogPilotConfirmationDialog::toggle("Reboot required to take effect.", "Reboot Now", this)) { + Hardware::reboot(); + } + }); + } + + customOnroadUIKeys = {"AdjacentPath", "BlindSpotPath", "ShowFPS", "LeadInfo", "RoadNameUI", "UseVienna"}; + customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"}; + modelUIKeys = {"AccelerationPath", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"}; + qolKeys = {"DriveStats", "HideSpeed", "ShowSLCOffset"}; + + QObject::connect(device(), &Device::interactiveTimeout, this, &OscarPilotBasicPanel::hideSubToggles); + QObject::connect(parent, &OscarSettingsWindow::closeParentToggle, this, &OscarPilotBasicPanel::hideSubToggles); + // QObject::connect(parent, &OscarSettingsWindow::updateMetric, this, &OscarPilotBasicPanel::updateMetric); + + hideSubToggles(); + // updateMetric(); +} + +void OscarPilotBasicPanel::updateToggles() { + std::thread([this]() { + paramsMemory.putBool("FrogPilotTogglesUpdated", true); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + paramsMemory.putBool("FrogPilotTogglesUpdated", false); + }).detach(); +} + +// void OscarPilotBasicPanel::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.putInt("LaneLinesWidth", std::nearbyint(params.getInt("LaneLinesWidth") * distanceConversion)); +// params.putInt("RoadEdgesWidth", std::nearbyint(params.getInt("RoadEdgesWidth") * distanceConversion)); +// params.putInt("PathWidth", std::nearbyint(params.getInt("PathWidth") * speedConversion)); +// } + +// FrogPilotParamValueControl *laneLinesWidthToggle = static_cast(toggles["LaneLinesWidth"]); +// FrogPilotParamValueControl *roadEdgesWidthToggle = static_cast(toggles["RoadEdgesWidth"]); +// FrogPilotParamValueControl *pathWidthToggle = static_cast(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"); +// } 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"); +// } + +// laneLinesWidthToggle->refresh(); +// roadEdgesWidthToggle->refresh(); + +// previousIsMetric = isMetric; +// } + +// void OscarPilotBasicPanel::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.putInt("LaneLinesWidth", std::nearbyint(params.getInt("LaneLinesWidth") * distanceConversion)); +// params.putInt("RoadEdgesWidth", std::nearbyint(params.getInt("RoadEdgesWidth") * distanceConversion)); +// params.putInt("PathWidth", std::nearbyint(params.getInt("PathWidth") * speedConversion)); +// } + +// FrogPilotParamValueControl *laneLinesWidthToggle = static_cast(toggles["LaneLinesWidth"]); +// FrogPilotParamValueControl *roadEdgesWidthToggle = static_cast(toggles["RoadEdgesWidth"]); +// FrogPilotParamValueControl *pathWidthToggle = static_cast(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"); +// } 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"); +// } + +// laneLinesWidthToggle->refresh(); +// roadEdgesWidthToggle->refresh(); + +// previousIsMetric = isMetric; +// } + +void OscarPilotBasicPanel::parentToggleClicked() { + this->openParentToggle(); +} + +void OscarPilotBasicPanel::hideSubToggles() { + for (auto &[key, toggle] : toggles) { + bool subToggles = modelUIKeys.find(key.c_str()) != modelUIKeys.end() || + customOnroadUIKeys.find(key.c_str()) != customOnroadUIKeys.end() || + customThemeKeys.find(key.c_str()) != customThemeKeys.end() || + qolKeys.find(key.c_str()) != qolKeys.end(); + toggle->setVisible(!subToggles); + } + + this->closeParentToggle(); +} + +void OscarPilotBasicPanel::hideEvent(QHideEvent *event) { + hideSubToggles(); +} diff --git a/selfdrive/oscarpilot/settings/basic.h.example b/selfdrive/oscarpilot/settings/basic.h.example index 2be2827..78a07ac 100644 --- a/selfdrive/oscarpilot/settings/basic.h.example +++ b/selfdrive/oscarpilot/settings/basic.h.example @@ -5,11 +5,11 @@ #include "selfdrive/frogpilot/ui/frogpilot_functions.h" #include "selfdrive/oscarpilot/settings/settings.h" -class OscarPilotVisualsPanel : public FrogPilotListWidget { +class OscarPilotBasicPanel : public FrogPilotListWidget { Q_OBJECT public: - explicit OscarPilotVisualsPanel(OscarSettingsWindow *parent); + explicit OscarPilotBasicPanel(OscarSettingsWindow *parent); signals: void closeParentToggle(); diff --git a/newmenus b/selfdrive/oscarpilot/settings/newmenus similarity index 100% rename from newmenus rename to selfdrive/oscarpilot/settings/newmenus diff --git a/selfdrive/oscarpilot/settings/settings.cc b/selfdrive/oscarpilot/settings/settings.cc index 50ae8ba..cbcd011 100644 --- a/selfdrive/oscarpilot/settings/settings.cc +++ b/selfdrive/oscarpilot/settings/settings.cc @@ -83,10 +83,10 @@ OscarSettingsWindow::OscarSettingsWindow(QWidget *parent) : QFrame(parent) { QList> panels = { {tr("Basic"), new OscarPilotBasicPanel(this)}, - // {tr("Software"), new SoftwarePanel(this)}, // {tr("Advanced"), basic}, + // {tr("OscarCloud"), basic}, // {tr("Logging"), basic}, // Log / Upload driver cam, Routes - // {tr("System"), new OscarPilotVisualsPanel(this)}, // Debugging + // {tr("System"), new OscarPilotBasicPanel(this)}, // Debugging // {tr("Status"), basic}, // Report on stuff like connectivity, free space, detected features // {tr("Extra"), basic}, // Custom cloud services, QOL automations }; diff --git a/selfdrive/ui/qt/text.cc b/selfdrive/ui/qt/text.cc index f30ce3e..f7f5c76 100644 --- a/selfdrive/ui/qt/text.cc +++ b/selfdrive/ui/qt/text.cc @@ -10,6 +10,26 @@ #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/qt_window.h" #include "selfdrive/ui/qt/widgets/scrollview.h" +#include "selfdrive/ui/qt/network/wifi_manager.h" + +// wifi connection screen +wifi = new QWidget; +{ + QVBoxLayout *layout = new QVBoxLayout(wifi); + layout->setContentsMargins(100, 100, 100, 100); + + Networking *networking = new Networking(this, false); + networking->setStyleSheet("Networking { background-color: #292929; border-radius: 13px; }"); + layout->addWidget(networking, 1); + + QPushButton *back = new QPushButton(tr("Back")); + back->setObjectName("navBtn"); + back->setStyleSheet("padding-left: 60px; padding-right: 60px;"); + QObject::connect(back, &QPushButton::clicked, [=]() { + setCurrentWidget(prompt); + }); + layout->addWidget(back, 0, Qt::AlignLeft); +} int main(int argc, char *argv[]) { initApp(argc, argv); @@ -35,16 +55,20 @@ int main(int argc, char *argv[]) { QPushButton *btnupdate = new QPushButton(); #ifdef __aarch64__ - btnupdate->setText(QObject::tr("Reboot")); + btnupdate->setText(QObject::tr("Update")); QObject::connect(btnupdate, &QPushButton::clicked, [=]() { QProcess process; - // BBOTCRASH - // Todo git revert here, show that is what we are doing on the textbox - // Also, must hide both buttons when this is clicked to prevent double clicks - process.setWorkingDirectory("/data/openpilot/"); - process.start("/bin/sh", QStringList{"-c", "echo hello world"}); - process.waitForFinished(); - Hardware::reboot(); + label->setText("Attempting to connect to wifi"); + wifi = new WifiManager(this); + connect(wifi, &WifiManager::refreshSignal, [=]() { + label->setText("Performing update"); + process.setWorkingDirectory("/data/openpilot/"); + process.start("/bin/bash", QStringList{"-c", "update.sh"}); + process.waitForFinished(); + label->setText("Rebooting"); + Hardware::reboot(); + }); + wifi->start(); }); #else btnupdate->setText(QObject::tr("Exit")); diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..9f63d05 --- /dev/null +++ b/update.sh @@ -0,0 +1,35 @@ + +# Set branch to your target branch +branch="oscarpilot" + +# Fetch the latest changes from the remote repository for the target branch +git fetch origin "$branch" + +# Check if the local branch is behind the remote branch +LOCAL=$(git rev-parse "@{0}") +REMOTE=$(git rev-parse "origin/$branch") + +if [ "$LOCAL" != "$REMOTE" ]; then + echo "Local branch is behind; updating." + + # Checkout the target branch forcefully, ignoring submodules as in the Python example + git checkout --force --no-recurse-submodules -B "$branch" "origin/$branch" + + # Reset the local changes hard, clean the directory including untracked files and directories, + # and ensure submodules are in sync, updated, and also reset hard + git reset --hard + git clean -xdff + git submodule sync + git submodule update --init --recursive + git submodule foreach --recursive git reset --hard + + echo "Repository and submodules have been updated and cleaned." + + # Run git cleanup in the repository directory + git gc + git lfs prune + + echo "Repository cleanup has been completed." +else + echo "Already at the latest version; no update needed." +fi \ No newline at end of file diff --git a/update_and_launch_openpilot.sh b/update_and_launch_openpilot.sh index 9b299d3..7918682 100644 --- a/update_and_launch_openpilot.sh +++ b/update_and_launch_openpilot.sh @@ -1,38 +1,4 @@ cd /data/openpilot -echo "Internet connection established, proceeding with update." - # Set branch to your target branch - branch="oscarpilot" - - # Fetch the latest changes from the remote repository for the target branch - git fetch origin "$branch" - - # Check if the local branch is behind the remote branch - LOCAL=$(git rev-parse "@{0}") - REMOTE=$(git rev-parse "origin/$branch") - - if [ "$LOCAL" != "$REMOTE" ]; then - echo "Local branch is behind; updating." - - # Checkout the target branch forcefully, ignoring submodules as in the Python example - git checkout --force --no-recurse-submodules -B "$branch" "origin/$branch" - - # Reset the local changes hard, clean the directory including untracked files and directories, - # and ensure submodules are in sync, updated, and also reset hard - git reset --hard - git clean -xdff - git submodule sync - git submodule update --init --recursive - git submodule foreach --recursive git reset --hard - - echo "Repository and submodules have been updated and cleaned." - - # Run git cleanup in the repository directory - git gc - git lfs prune - - echo "Repository cleanup has been completed." - else - echo "Already at the latest version; no update needed." - fi - bash launch_openpilot.sh \ No newline at end of file +bash update.sh +bash launch_openpilot.sh \ No newline at end of file