wip
This commit is contained in:
BIN
selfdrive/clearpilot/models/duck-amigo.thneed
Normal file
BIN
selfdrive/clearpilot/models/duck-amigo.thneed
Normal file
Binary file not shown.
BIN
selfdrive/clearpilot/models/farmville.onnx
Executable file
BIN
selfdrive/clearpilot/models/farmville.onnx
Executable file
Binary file not shown.
BIN
selfdrive/clearpilot/models/wd-40.thneed
Normal file
BIN
selfdrive/clearpilot/models/wd-40.thneed
Normal file
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
example of using stdin and stdout as a message buffer:
|
||||
|
||||
selfdrive/manager/build.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... :(")
|
||||
|
||||
@@ -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, [=]() {
|
||||
|
||||
@@ -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")));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
64
selfdrive/ui/qt/ready.cc
Normal file
64
selfdrive/ui/qt/ready.cc
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "selfdrive/ui/qt/ready.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStackedLayout>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGridLayout>
|
||||
#include <QString>
|
||||
#include <QTransform>
|
||||
#include <QPixmap>
|
||||
|
||||
#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) {
|
||||
}
|
||||
30
selfdrive/ui/qt/ready.h
Normal file
30
selfdrive/ui/qt/ready.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMovie>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QPixmap>
|
||||
#include <QProgressBar>
|
||||
#include <QSocketNotifier>
|
||||
#include <QVariantAnimation>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#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;
|
||||
};
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user