-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrolwindow.cpp
104 lines (80 loc) · 2.93 KB
/
controlwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "controlwindow.h"
#include "./ui_controlwindow.h"
ControlWindow::ControlWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::ControlWindow)
, _rosNode(std::make_unique<RosNode>(this))
{
ui->setupUi(this);
ui->portBox->setValidator(new QIntValidator(0, 65535, this));
}
ControlWindow::~ControlWindow()
{
delete ui;
}
void ControlWindow::getPropeller(int k)
{
double adjusted_value = k - (ui->propellerSlider->maximum() / 2);
ui->propellerBox->setValue(adjusted_value);
}
void ControlWindow::getPropeller(double k)
{
double reversed_value = k + (ui->propellerSlider->maximum() / 2);
_rosNode->propellerCallback(k);
ui->propellerSlider->setValue(reversed_value);
}
void ControlWindow::getVerticalFins(int k)
{
double adjusted_value = (k - (ui->verticalFinsSlider->maximum() / 2)) * 0.25 / 50.0;
ui->verticalFinsBox->setValue(adjusted_value);
}
void ControlWindow::getVerticalFins(double k)
{
int reversed_value = (k * 50.0 / 0.25) + (ui->verticalFinsSlider->maximum() / 2);
_rosNode->verticalFinsCallback(k);
ui->verticalFinsSlider->setValue(reversed_value);
}
void ControlWindow::getHorizontalFins(int k)
{
double adjusted_value = (k - (ui->horizontalFinsSlider->maximum() / 2)) * 0.25 / 50.0;
ui->horizontalFinsBox->setValue(adjusted_value);
}
void ControlWindow::getHorizontalFins(double k)
{
int reversed_value = (k * 50.0 / 0.25) + (ui->horizontalFinsSlider->maximum() / 2);
_rosNode->horizontalFinsCallback(k);
ui->horizontalFinsSlider->setValue(reversed_value);
}
void ControlWindow::restartGazeboTransport()
{
_gazeboNode.reset();
_gazeboNode = std::make_unique<GazeboNode>(ui->hostBox->text(), ui->portBox->text().toInt(), ui->nameBox->text().toStdString(), ui->evologicsRadio->isChecked(), this);
}
void ControlWindow::onDynamicPositionToggled(bool checked)
{
if (checked)
{
QRadioButton *btn = static_cast<QRadioButton *>(sender());
if (btn->objectName() == ui->disabledRadio->objectName())
{
ui->hostBox->setEnabled(false);
ui->portBox->setEnabled(false);
ui->nameBox->setEnabled(false);
_gazeboNode.reset();
}
else if (btn->objectName() == ui->udpPositionRadio->objectName())
{
ui->hostBox->setEnabled(true);
ui->portBox->setEnabled(true);
ui->nameBox->setEnabled(true);
_gazeboNode = std::make_unique<GazeboNode>(ui->hostBox->text(), ui->portBox->text().toInt(), ui->nameBox->text().toStdString(), false, this);
}
else if (btn->objectName() == ui->evologicsRadio->objectName())
{
ui->hostBox->setEnabled(true);
ui->portBox->setEnabled(true);
ui->nameBox->setEnabled(true);
_gazeboNode = std::make_unique<GazeboNode>(ui->hostBox->text(), ui->portBox->text().toInt(), ui->nameBox->text().toStdString(), true, this);
}
}
}