Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Feature/battery stats and refresh (#622)
Browse files Browse the repository at this point in the history
* make division between soft and hard refresh

* formatting

* add battery low message
  • Loading branch information
mrlukasbos authored Jun 19, 2019
1 parent 3ebbded commit 8bde303
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
32 changes: 19 additions & 13 deletions roboteam_ai/src/interface/widgets/MainControlsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ MainControlsWidget::MainControlsWidget(QWidget * parent) {
}
select_ruleset->setStyleSheet(QString::fromUtf8("QComboBox:disabled" "{ color: gray }"));

auto refreshHButtonsLayout = new QHBoxLayout();

refreshBtn = new QPushButton("Soft refresh");
QObject::connect(refreshBtn, SIGNAL(clicked()), this, SLOT(refreshSignal()));
refreshHButtonsLayout->addWidget(refreshBtn);
refreshBtn->setStyleSheet("background-color: #0000cc;");

refreshJsonBtn = new QPushButton("Hard refresh");
QObject::connect(refreshJsonBtn, SIGNAL(clicked()), this, SLOT(refreshJSONSignal()));
refreshHButtonsLayout->addWidget(refreshJsonBtn);
refreshJsonBtn->setStyleSheet("background-color: #0000cc;");
vLayout->addLayout(refreshHButtonsLayout);


auto hButtonsLayout = new QHBoxLayout();

haltBtn = new QPushButton("Halt");
Expand All @@ -70,11 +84,6 @@ MainControlsWidget::MainControlsWidget(QWidget * parent) {
spaceClick = new QShortcut(QKeySequence(Qt::Key_Space), this, SLOT(sendPauseSignal()));
spaceClick->setAutoRepeat(false);

refreshBtn = new QPushButton("Refresh");
QObject::connect(refreshBtn, SIGNAL(clicked()), this, SLOT(refreshSignal()));
hButtonsLayout->addWidget(refreshBtn);
refreshBtn->setStyleSheet("background-color: #0000cc;");

toggleColorBtn = new QPushButton("Color");
QObject::connect(toggleColorBtn, SIGNAL(clicked()), this, SLOT(toggleOurColorParam()));
hButtonsLayout->addWidget(toggleColorBtn);
Expand Down Expand Up @@ -127,14 +136,6 @@ void MainControlsWidget::setTimeOutTop(bool top) {
Output::setTimeOutTop(top);
}

QString MainControlsWidget::getSelectStrategyText() const {
return select_strategy->currentText();
}

void MainControlsWidget::setSelectStrategyText(QString text) {
select_strategy->setCurrentText(text);
}

void MainControlsWidget::setUseReferee(bool useRef) {
Output::setUseRefereeCommands(useRef);

Expand Down Expand Up @@ -213,6 +214,11 @@ void MainControlsWidget::setToggleSideBtnLayout() const {


void MainControlsWidget::refreshSignal() {
robotDealer::RobotDealer::refresh();
emit treeHasChanged();
}

void MainControlsWidget::refreshJSONSignal() {
BTFactory::makeTrees();
robotDealer::RobotDealer::refresh();
emit treeHasChanged();
Expand Down
4 changes: 2 additions & 2 deletions roboteam_ai/src/interface/widgets/MainControlsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class MainControlsWidget : public QWidget {
Q_OBJECT
public:
explicit MainControlsWidget(QWidget * parent = nullptr);
QString getSelectStrategyText() const;
void setSelectStrategyText(QString text);

signals:
void treeHasChanged();
Expand All @@ -30,6 +28,7 @@ Q_OBJECT
QVBoxLayout* vLayout;
QPushButton* pauseBtn;
QPushButton* refreshBtn;
QPushButton* refreshJsonBtn;
QPushButton* toggleColorBtn;
QPushButton* toggleSideBtn;
QPushButton* haltBtn;
Expand All @@ -54,6 +53,7 @@ public slots:
void updatePause();
void setUseReferee(bool useRef);
void refreshSignal();
void refreshJSONSignal();
void updateContents();
void sendHaltSignal();
};
Expand Down
3 changes: 3 additions & 0 deletions roboteam_ai/src/interface/widgets/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ void Visualizer::drawRobot(QPainter &painter, Robot robot, bool ourTeam) {
if (!robot.hasWorkingBallSensor()) {
text += "BS ";
}
if (robot.isBatteryLow()) {
text += "BATTERY LOW";
}
painter.drawText(robotpos.x, ypos += 20, QString::fromStdString(text));
}

Expand Down

0 comments on commit 8bde303

Please sign in to comment.