From a4edd8d68d3313b6aced6f1a6dd3da31f7e71d9e Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sun, 24 Dec 2023 17:43:47 +0000 Subject: [PATCH] Driving Model Selector v2 --- CHANGELOGS.md | 4 ++++ .../qt/offroad/sunnypilot/models_fetcher.cc | 2 +- .../ui/qt/offroad/sunnypilot/models_fetcher.h | 6 +++++ .../sunnypilot/software_settings_sp.cc | 22 +++++++++++++++---- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 9c387e097b..b1d3bf8c14 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -2,6 +2,10 @@ sunnypilot - 0.9.6.1 (2023-xx-xx) ======================== * UPDATED: Dynamic Experimental Control (DEC) * Synced with dragonpilot-community/dragonpilot:lp-dp-beta2 commit 578d38b +* UPDATED: Driving Model Selector v2 + * Driving models sort in descending order based on availability date + * Experimental/unmerged driving models are only available in "dev-c3" branch + * To select and use experimental driving models, navigate to "Software" panel, select the "dev-c3" branch, and check for update * UPDATED: Vision-based Turn Speed Control (V-TSC) implementation * Refactored implementation thanks to pfeiferj! * More accurate and consistent velocity calculation to achieve smoother longitudinal control in curves diff --git a/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.cc b/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.cc index 4d3504bf96..8b323748b9 100644 --- a/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.cc +++ b/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.cc @@ -78,5 +78,5 @@ std::vector ModelsFetcher::getModelsFromURL(const QString&url) { } std::vector ModelsFetcher::getModelsFromURL() { - return getModelsFromURL("https://docs.sunnypilot.ai/models.json"); + return getModelsFromURL("https://docs.sunnypilot.ai/models_v2.json"); } diff --git a/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.h b/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.h index 07d76169c8..1759d3195e 100644 --- a/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.h +++ b/selfdrive/ui/qt/offroad/sunnypilot/models_fetcher.h @@ -26,6 +26,8 @@ public: fullName = json["full_name"].toString(); fileName = json["file_name"].toString(); downloadUri = json["download_uri"].toString(); + index = json["index"].toString(); + environment = json["environment"].toString(); } QJsonObject toJson() const { @@ -34,6 +36,8 @@ public: json["full_name"] = fullName; json["file_name"] = fileName; json["download_uri"] = downloadUri; + json["index"] = index; + json["environment"] = environment; return json; } @@ -41,6 +45,8 @@ public: QString fullName; QString fileName; QString downloadUri; + QString index; + QString environment; }; class ModelsFetcher : public QObject { diff --git a/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc b/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc index 87db0e00d0..17875dbc2e 100644 --- a/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc +++ b/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc @@ -56,12 +56,26 @@ void SoftwarePanelSP::handleCurrentModelLblBtnClicked() { checkNetwork(); const auto currentModelName = QString::fromStdString(params.get("DrivingModelName")); + const bool is_release_sp = params.getBool("IsReleaseSPBranch"); const auto models = models_fetcher.getModelsFromURL(); - QStringList modelNames; - // Collecting model names - for (const auto &model: models) { - modelNames.push_back(model.displayName); + QMap index_to_model; + + // Collecting indices with display names + for (const auto &model : models) { + if ((is_release_sp && model.environment == "release") || !is_release_sp) { + index_to_model.insert(model.index, model.displayName); + } + } + + QStringList modelNames; + QStringList indices = index_to_model.keys(); + std::sort(indices.begin(), indices.end(), [&](const QString &index1, const QString &index2) { + return index1.toInt() > index2.toInt(); + }); + + for (const QString &index : indices) { + modelNames.push_back(index_to_model[index]); } currentModelLblBtn->setEnabled(!is_onroad);