Qt training guide (#19953)

* initial commit

* background kind of works

* checkpoint

* temp

* add images

* all works

* remove some files

* rename

* enable restart

* remove first

* lfs try1

* refactor labels

* remove nonneeded code

* centered

* more centering

* don't hardcode the training version

Co-authored-by: Comma Device <device@comma.ai>
albatross
grekiki 2021-01-29 17:54:00 +01:00 committed by GitHub
parent 82b894c645
commit c5762456e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 137 additions and 37 deletions

1
.gitattributes vendored
View File

@ -4,6 +4,7 @@
*.pb filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.apk filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.ipynb filter=nbstripout -diff
external/ffmpeg/bin/ffmpeg_cuda filter=lfs diff=lfs merge=lfs -text
models/segnet.keras filter=lfs diff=lfs merge=lfs -text

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

BIN
selfdrive/assets/training/step0.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step1.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step10.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step11.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step12.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step13.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step14.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step2.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step3.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step4.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step5.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step6.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step7.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step8.jpg (Stored with Git LFS) 100644

Binary file not shown.

BIN
selfdrive/assets/training/step9.jpg (Stored with Git LFS) 100644

Binary file not shown.

View File

@ -3,18 +3,73 @@
#include <QPushButton>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QDebug>
#include <QGuiApplication>
#include <QScreen>
#include <QApplication>
#include <QDesktopWidget>
#include "onboarding.hpp"
#include "common/params.h"
#include "home.hpp"
QLabel * title_label(QString text) {
QLabel *l = new QLabel(text);
l->setStyleSheet(R"(font-size: 100px;)");
l->setStyleSheet(R"(font-size: 100px; font-weight: bold;)");
return l;
}
QWidget * OnboardingWindow::terms_screen() {
QWidget* layout2Widget(QLayout* l){
QWidget* q = new QWidget;
q->setLayout(l);
return q;
}
void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) {
int leftOffset = (geometry().width()-1620)/2;
int mousex = e->x()-leftOffset;
int mousey = e->y();
// Check for restart
if (currentIndex == numberOfFrames-1) {
if (1050 <= mousex && mousex <= 1500 && 773 <= mousey && mousey <= 954){
slayout->setCurrentIndex(0);
currentIndex = 0;
return;
}
}
if (boundingBox[currentIndex][0] <= mousex && mousex <= boundingBox[currentIndex][1] && boundingBox[currentIndex][2] <= mousey && mousey <= boundingBox[currentIndex][3]) {
slayout->setCurrentIndex(++currentIndex);
}
if (currentIndex >= numberOfFrames) {
emit completedTraining();
return;
}
}
TrainingGuide::TrainingGuide(QWidget* parent) {
QHBoxLayout* hlayout = new QHBoxLayout;
slayout = new QStackedLayout(this);
for (int i = 0; i <= 14; i++) {
QWidget* w = new QWidget;
w->setStyleSheet(".QWidget {background-image: url(../assets/training/step" + QString::number(i) + ".jpg);}");
w->setFixedSize(1620, 1080);
slayout->addWidget(w);
}
QWidget* sw = layout2Widget(slayout);
hlayout->addWidget(sw, 1, Qt::AlignCenter);
setLayout(hlayout);
}
QWidget* OnboardingWindow::terms_screen() {
QGridLayout *main_layout = new QGridLayout();
main_layout->setMargin(100);
@ -35,7 +90,7 @@ QWidget * OnboardingWindow::terms_screen() {
QPushButton *accept_btn = new QPushButton("Accept");
main_layout->addWidget(accept_btn, 2, 1);
QObject::connect(accept_btn, &QPushButton::released, [=]() {
Params().write_db_value("HasAcceptedTerms", LATEST_TERMS_VERSION);
Params().write_db_value("HasAcceptedTerms", current_terms_version.toStdString());
updateActiveScreen();
});
@ -55,34 +110,11 @@ QWidget * OnboardingWindow::terms_screen() {
return widget;
}
QWidget * OnboardingWindow::training_screen() {
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout->setMargin(100);
main_layout->setSpacing(30);
main_layout->addWidget(title_label("Training Guide"));
main_layout->addWidget(new QLabel(), 1); // just a spacer
QPushButton *btn = new QPushButton("Continue");
main_layout->addWidget(btn);
QObject::connect(btn, &QPushButton::released, [=]() {
Params().write_db_value("CompletedTrainingVersion", LATEST_TRAINING_VERSION);
updateActiveScreen();
});
QWidget *widget = new QWidget;
widget->setLayout(main_layout);
return widget;
}
void OnboardingWindow::updateActiveScreen() {
Params params = Params();
bool accepted_terms = params.get("HasAcceptedTerms", false).compare(LATEST_TERMS_VERSION) == 0;
bool training_done = params.get("CompletedTrainingVersion", false).compare(LATEST_TRAINING_VERSION) == 0;
bool accepted_terms = params.get("HasAcceptedTerms", false).compare(current_terms_version.toStdString()) == 0;
bool training_done = params.get("CompletedTrainingVersion", false).compare(current_training_version.toStdString()) == 0;
if (!accepted_terms) {
setCurrentIndex(0);
} else if (!training_done) {
@ -93,8 +125,13 @@ void OnboardingWindow::updateActiveScreen() {
}
OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) {
Params params = Params();
current_terms_version = QString::fromStdString(params.get("TermsVersion", false));
current_training_version = QString::fromStdString(params.get("TrainingVersion", false));
addWidget(terms_screen());
addWidget(training_screen());
TrainingGuide* tr = new TrainingGuide(this);
connect(tr, &TrainingGuide::completedTraining, [=](){Params().write_db_value("CompletedTrainingVersion", current_training_version.toStdString()); updateActiveScreen();});
addWidget(tr);
setStyleSheet(R"(
* {
@ -102,15 +139,11 @@ OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) {
background-color: black;
}
QPushButton {
font-size: 50px;
padding: 50px;
border-radius: 10px;
background-color: #292929;
}
)");
// TODO: remove this after training guide is done
Params().write_db_value("CompletedTrainingVersion", LATEST_TRAINING_VERSION);
updateActiveScreen();
}

View File

@ -2,10 +2,29 @@
#include <QWidget>
#include <QStackedWidget>
#include <QStackedLayout>
#include <QMouseEvent>
// TODO: this is defined in python too
#define LATEST_TERMS_VERSION "2"
#define LATEST_TRAINING_VERSION "0.2.0"
class TrainingGuide : public QWidget {
Q_OBJECT
public:
explicit TrainingGuide(QWidget *parent = 0);
protected:
void mouseReleaseEvent(QMouseEvent* e) override;
private:
int currentIndex = 0;
const int numberOfFrames = 15;
QStackedLayout* slayout;
//Vector of bounding boxes for the next step. (minx, maxx, miny, maxy)
QVector<QVector<int>> boundingBox {{250, 930, 750, 900}, {280, 1280, 650, 950}, {330, 1130, 590, 900}, {910, 1580, 500, 1000}, {1180, 1300, 630, 720}, {290, 1050, 590, 960},
{1090, 1240, 550, 660}, {1050, 1580, 250, 900}, {320, 1130, 670, 1020}, {1010, 1580, 410, 750}, {1040, 1500, 230, 1030}, {300, 1190, 590, 920}, {1050, 1310, 170, 870}, {950, 1530, 460, 770}, {190, 970, 750, 970}};
signals:
void completedTraining();
};
class OnboardingWindow : public QStackedWidget {
Q_OBJECT
@ -14,6 +33,8 @@ public:
explicit OnboardingWindow(QWidget *parent = 0);
private:
QString current_terms_version;
QString current_training_version;
QWidget * terms_screen();
QWidget * training_screen();