diff --git a/selfdrive/clearpilot/models/duck-amigo.thneed b/selfdrive/clearpilot/models/duck-amigo.thneed new file mode 100644 index 0000000..08b167c Binary files /dev/null and b/selfdrive/clearpilot/models/duck-amigo.thneed differ diff --git a/selfdrive/clearpilot/models/farmville.onnx b/selfdrive/clearpilot/models/farmville.onnx new file mode 100755 index 0000000..181c264 Binary files /dev/null and b/selfdrive/clearpilot/models/farmville.onnx differ diff --git a/selfdrive/clearpilot/models/wd-40.thneed b/selfdrive/clearpilot/models/wd-40.thneed new file mode 100644 index 0000000..1bc870e Binary files /dev/null and b/selfdrive/clearpilot/models/wd-40.thneed differ diff --git a/selfdrive/clearpilot/notes.txt b/selfdrive/clearpilot/notes.txt index 655645d..e69de29 100644 --- a/selfdrive/clearpilot/notes.txt +++ b/selfdrive/clearpilot/notes.txt @@ -1,3 +0,0 @@ -example of using stdin and stdout as a message buffer: - -selfdrive/manager/build.py \ No newline at end of file diff --git a/selfdrive/frogpilot/controls/lib/model_manager.py b/selfdrive/frogpilot/controls/lib/model_manager.py index 9664137..36e5b51 100644 --- a/selfdrive/frogpilot/controls/lib/model_manager.py +++ b/selfdrive/frogpilot/controls/lib/model_manager.py @@ -6,12 +6,14 @@ import urllib.request from openpilot.common.params import Params from openpilot.system.version import get_short_branch +# CLEARPILOT this doesnt really matter. VERSION = 'v1' if get_short_branch() == "clearpilot" else 'v2' REPOSITORY_URL = 'https://privategit.hanson.xyz/brianhansonxyz/clearpilot' DEFAULT_MODEL = "wd-40" DEFAULT_MODEL_NAME = "WD40 (Default)" -MODELS_PATH = '/data/models' +# CLEARPILOT changed path. +MODELS_PATH = '/data/openpilot/selfdrive/clearpilot/models' NAVIGATIONLESS_MODELS = {"radical-turtle", "wd-40"} RADARLESS_MODELS = {"radical-turtle"} @@ -77,26 +79,24 @@ def download_model(): print(f"Failed to download the {model} model after {attempt + 1} attempts. Giving up... :(") def populate_models(): - model_names_url = f"https://raw.githubusercontent.com/FrogAi/FrogPilot-Resources/master/model_names_{VERSION}.txt" + # CLEARPILOT hardcoded list + models = """ +wd-40 - WD40 (Default) +duck-amigo - Duck Amigo +""" + # todo - get farmville working + # farmville - FarmVille - for attempt in range(5): - try: - with urllib.request.urlopen(model_names_url) as response: - model_info = [line.decode('utf-8').strip().split(' - ') for line in response.readlines() if ' - ' in line.decode('utf-8')] + model_info = [line.decode('utf-8').strip().split(' - ') for line in models.readlines() if ' - ' in line.decode('utf-8')] - available_models = ','.join(model[0] for model in model_info) - available_models_names = [model[1] for model in model_info] + available_models = ','.join(model[0] for model in model_info) + available_models_names = [model[1] for model in model_info] - params.put("AvailableModels", available_models) - params.put("AvailableModelsNames", ','.join(available_models_names)) + params.put("AvailableModels", available_models) + params.put("AvailableModelsNames", ','.join(available_models_names)) - current_model_name = params.get("ModelName", encoding='utf-8') - if current_model_name not in available_models_names and "(Default)" in current_model_name: - updated_model_name = current_model_name.replace("(Default)", "").strip() - params.put("ModelName", updated_model_name) + current_model_name = params.get("ModelName", encoding='utf-8') + if current_model_name not in available_models_names and "(Default)" in current_model_name: + updated_model_name = current_model_name.replace("(Default)", "").strip() + params.put("ModelName", updated_model_name) - except Exception as e: - print(f"Failed to update models list. Error: {e}. Retrying...") - time.sleep(5) - else: - print(f"Failed to update models list after 5 attempts. Giving up... :(") diff --git a/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc index 4080f90..5f7f5ee 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/control_settings.cc @@ -422,7 +422,8 @@ FrogPilotControlsPanel::FrogPilotControlsPanel(SettingsWindow *parent) : FrogPil }); toggle = modelsToggle; - QDir modelDir("/data/models/"); + // CLEARPILOT changed path. + QDir modelDir("/data/openpilot/selfdrive/clearpilot/models/"); deleteModelBtn = new ButtonControl(tr("Delete Model"), tr("DELETE"), ""); QObject::connect(deleteModelBtn, &ButtonControl::clicked, [=]() { diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index 9c7c89a..49c85d5 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -39,6 +39,11 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { body = new BodyWindow(this); slayout->addWidget(body); + // CLEARPILOT + // show_ready = true; + ready = new ReadyWindow(this); + slayout->addWidget(ready); + driver_view = new DriverViewWindow(this); connect(driver_view, &DriverViewWindow::done, [=] { showDriverView(false); @@ -61,11 +66,12 @@ void HomeWindow::showMapPanel(bool show) { void HomeWindow::updateState(const UIState &s) { const SubMaster &sm = *(s.sm); + // CLEARPILOT // switch to the generic robot UI - if (onroad->isVisible() && !body->isEnabled() && sm["carParams"].getCarParams().getNotCar()) { - body->setEnabled(true); - slayout->setCurrentWidget(body); - } + // if (onroad->isVisible() && !body->isEnabled() && sm["carParams"].getCarParams().getNotCar()) { + // body->setEnabled(true); + // slayout->setCurrentWidget(body); + // } if (s.scene.started) { showDriverView(s.scene.driver_camera_timer >= 10, true); @@ -76,7 +82,8 @@ void HomeWindow::offroadTransition(bool offroad) { body->setEnabled(false); sidebar->setVisible(offroad); if (offroad) { - slayout->setCurrentWidget(home); + slayout->setCurrentWidget(ready); + // slayout->setCurrentWidget(home); } else { slayout->setCurrentWidget(onroad); uiState()->scene.map_open = onroad->isMapVisible(); @@ -101,11 +108,18 @@ void HomeWindow::showDriverView(bool show, bool started) { void HomeWindow::mousePressEvent(QMouseEvent* e) { // Handle sidebar collapsing + // CLEARPILOT todo - tap on main goes straight to settings + // Unless we click a debug widget. if ((onroad->isVisible() || body->isVisible()) && (!sidebar->isVisible() || e->x() > sidebar->width())) { sidebar->setVisible(!sidebar->isVisible() && !onroad->isMapVisible()); uiState()->scene.map_open = onroad->isMapVisible(); params.putBool("Sidebar", sidebar->isVisible()); } + + // CLEARPILOT - click ready shows home + if (!onroad->isVisible() && ready->isVisible()) { + slayout->setCurrentWidget(home); + } } void HomeWindow::mouseDoubleClickEvent(QMouseEvent* e) { @@ -234,7 +248,8 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) { void OffroadHome::showEvent(QShowEvent *event) { refresh(); - timer->start(10 * 1000); + // CLEARPILOT changed timeout to 2 min + timer->start(120 * 1000); } void OffroadHome::hideEvent(QHideEvent *event) { @@ -251,8 +266,9 @@ void OffroadHome::refresh() { int alerts = alerts_widget->refresh(); // pop-up new notification + // CLEARPILOT temp disabled update notifications int idx = center_layout->currentIndex(); - if (!updateAvailable && !alerts) { + if (!updateAvailable && !alerts && false) { idx = 0; } else if (updateAvailable && (!update_notif->isVisible() || (!alerts && idx == 2))) { idx = 1; @@ -261,8 +277,11 @@ void OffroadHome::refresh() { } center_layout->setCurrentIndex(idx); - update_notif->setVisible(updateAvailable); - alert_notif->setVisible(alerts); + // CLEARPILOT temp disabled update notifications +// update_notif->setVisible(updateAvailable); +// alert_notif->setVisible(alerts); + update_notif->setVisible(false); + alert_notif->setVisible(false); if (alerts) { alert_notif->setText(QString::number(alerts) + (alerts > 1 ? tr(" ALERTS") : tr(" ALERT"))); } diff --git a/selfdrive/ui/qt/home.h b/selfdrive/ui/qt/home.h index 5ea4a16..978670d 100644 --- a/selfdrive/ui/qt/home.h +++ b/selfdrive/ui/qt/home.h @@ -10,6 +10,7 @@ #include "common/params.h" #include "selfdrive/ui/qt/offroad/driverview.h" #include "selfdrive/ui/qt/body.h" +#include "selfdrive/ui/qt/ready.h" #include "selfdrive/ui/qt/onroad.h" #include "selfdrive/ui/qt/sidebar.h" #include "selfdrive/ui/qt/widgets/controls.h" @@ -75,6 +76,10 @@ private: // FrogPilot variables Params params; + // CLEARPILOT + // bool show_ready; + ReadyWindow *ready; + private slots: void updateState(const UIState &s); }; diff --git a/selfdrive/ui/qt/ready.cc b/selfdrive/ui/qt/ready.cc new file mode 100644 index 0000000..dac18cf --- /dev/null +++ b/selfdrive/ui/qt/ready.cc @@ -0,0 +1,64 @@ +#include "selfdrive/ui/qt/ready.h" + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "common/params.h" +#include "common/timing.h" + +#include "system/hardware/hw.h" +#include "selfdrive/ui/qt/qt_window.h" +#include "selfdrive/ui/qt/util.h" + +ReadyWindow::ReadyWindow(QWidget *parent) : QWidget(parent) { + QGridLayout *layout = new QGridLayout(this); + layout->setSpacing(0); + layout->setMargin(0); + + setAttribute(Qt::WA_OpaquePaintEvent); + + setStyleSheet(R"( + BodyWindow { + background-color: black; + } + )"); + + QObject::connect(uiState(), &UIState::uiUpdate, this, &BodyWindow::updateState); +} + +void ReadyWindow::paintEvent(QPaintEvent *event) { + QPainter painter(this); + + QPixmap comma_img = loadPixmap("/data/openpilot/selfdrive/clearpilot/theme/clearpilot/images/ready.png"); + + // Calculate the top-left position to center the image in the window. + int x = (this->width() - comma_img.width()) / 2; + int y = (this->height() - comma_img.height()) / 2; + + // Draw the pixmap at the calculated position. + painter.drawPixmap(x, y, comma_img); +} + +void ReadyWindow::showEvent(QShowEvent *event) { + refresh(); + timer->start(180 * 1000); +} + +void ReadyWindow::hideEvent(QHideEvent *event) { + timer->stop(); +} + +void ReadyWindow::updateState(const UIState &s) { +} + +void ReadyWindow::offroadTransition(bool offroad) { +} diff --git a/selfdrive/ui/qt/ready.h b/selfdrive/ui/qt/ready.h new file mode 100644 index 0000000..3668a84 --- /dev/null +++ b/selfdrive/ui/qt/ready.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common/util.h" +#include "selfdrive/ui/ui.h" + +class ReadyWindow : public QWidget { + Q_OBJECT +public: + BodyWindow(QWidget* parent = 0); +private: + void paintEvent(QPaintEvent*) override; +private slots: + void updateState(const UIState &s); + void offroadTransition(bool onroad); + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; + void refresh(); + + QTimer* timer; +}; diff --git a/system/clearpilot/configure/provision.sh b/system/clearpilot/configure/provision.sh index e459237..cb87af1 100644 --- a/system/clearpilot/configure/provision.sh +++ b/system/clearpilot/configure/provision.sh @@ -20,3 +20,5 @@ pip3 install termqt cd /data/openpilot/third_party/libyuv bash build.sh cd libyuv && make && make install + +pip install PyQt5-sip \ No newline at end of file