Skip to content
Snippets Groups Projects
Commit 1dc42fbb authored by Jake's avatar Jake
Browse files

Autonav implemented

parent 07d4f566
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,11 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -19,7 +19,11 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow), ui(new Ui::MainWindow),
backendPid(0), backendPid(0),
backendPipe(-1), backendPipe(-1),
setpointList(new QStandardItemModel(this)) setpointList(new QStandardItemModel(this)),
nextSpTimer(new QTimer(this)),
sp_x(0.0f),
sp_y(0.0f),
sp_z(0.0f)
{ {
ui->setupUi(this); ui->setupUi(this);
...@@ -70,6 +74,10 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -70,6 +74,10 @@ MainWindow::MainWindow(QWidget *parent) :
connect(trackerTimer, SIGNAL(timeout()), trackerWorker, SLOT(process())); connect(trackerTimer, SIGNAL(timeout()), trackerWorker, SLOT(process()));
connect(findChild<QPushButton *>("pbRefresh"), SIGNAL (clicked()), trackerWorker, SLOT (process())); connect(findChild<QPushButton *>("pbRefresh"), SIGNAL (clicked()), trackerWorker, SLOT (process()));
/* Timer used for next setpoint */
nextSpTimer->setSingleShot(true);
connect(nextSpTimer, SIGNAL (timeout()), this, SLOT (on_pbNextSetpoint_clicked()));
/* Start the things */ /* Start the things */
trackerTimer->start(300); trackerTimer->start(300);
workerThread->start(); workerThread->start();
...@@ -113,6 +121,15 @@ void MainWindow::updateTracker(float x, float y, float z, float p, float r, floa ...@@ -113,6 +121,15 @@ void MainWindow::updateTracker(float x, float y, float z, float p, float r, floa
findChild<QLineEdit *>("pitchActual")->setText(QString::number(p)); findChild<QLineEdit *>("pitchActual")->setText(QString::number(p));
findChild<QLineEdit *>("rollActual")->setText(QString::number(r)); findChild<QLineEdit *>("rollActual")->setText(QString::number(r));
findChild<QLineEdit *>("yawActual")->setText(QString::number(yaw)); findChild<QLineEdit *>("yawActual")->setText(QString::number(yaw));
float dist = sqrt(pow(x - sp_x, 2.0) + pow(y - sp_y, 2.0) + pow(z - sp_z, 2.0));
findChild<QLineEdit *>("dist")->setText(QString::number(dist));
if (!nextSpTimer->isActive() && findChild<QCheckBox *>("autonavEnabled")->isChecked() &&
(dist < findChild<QLineEdit *>("autonavThreshold")->text().toFloat())) {
nextSpTimer->start(findChild<QLineEdit *>("autonavDelay")->text().toInt());
}
} }
void MainWindow::on_pbStart_clicked() void MainWindow::on_pbStart_clicked()
...@@ -232,17 +249,17 @@ void MainWindow::on_paramValue_returnPressed() ...@@ -232,17 +249,17 @@ void MainWindow::on_paramValue_returnPressed()
void MainWindow::sendSetpoints() void MainWindow::sendSetpoints()
{ {
sp_x = findChild<QLineEdit *>("xSetpoint")->text().toFloat();
emit (setParamValue(findChild<QComboBox *>("xSetpointSelect")->currentText(), emit (setParamValue(findChild<QComboBox *>("xSetpointSelect")->currentText(),
blockDefs[BLOCK_CONSTANT]->param_names[0], blockDefs[BLOCK_CONSTANT]->param_names[0], sp_x));
findChild<QLineEdit *>("xSetpoint")->text().toFloat()));
sp_y = findChild<QLineEdit *>("ySetpoint")->text().toFloat();
emit (setParamValue(findChild<QComboBox *>("ySetpointSelect")->currentText(), emit (setParamValue(findChild<QComboBox *>("ySetpointSelect")->currentText(),
blockDefs[BLOCK_CONSTANT]->param_names[0], blockDefs[BLOCK_CONSTANT]->param_names[0], sp_y));
findChild<QLineEdit *>("ySetpoint")->text().toFloat()));
sp_z = findChild<QLineEdit *>("zSetpoint")->text().toFloat();
emit (setParamValue(findChild<QComboBox *>("zSetpointSelect")->currentText(), emit (setParamValue(findChild<QComboBox *>("zSetpointSelect")->currentText(),
blockDefs[BLOCK_CONSTANT]->param_names[0], blockDefs[BLOCK_CONSTANT]->param_names[0], sp_z));
findChild<QLineEdit *>("zSetpoint")->text().toFloat()));
} }
void MainWindow::on_pbAppendSetpoint_clicked() void MainWindow::on_pbAppendSetpoint_clicked()
......
...@@ -65,6 +65,10 @@ private: ...@@ -65,6 +65,10 @@ private:
int backendPipe; int backendPipe;
int backendState; int backendState;
QStandardItemModel * setpointList; QStandardItemModel * setpointList;
QTimer * nextSpTimer;
float sp_x;
float sp_y;
float sp_z;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1369</width> <width>1004</width>
<height>995</height> <height>934</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="backend"> <widget class="QWidget" name="backend">
<attribute name="title"> <attribute name="title">
...@@ -151,8 +151,8 @@ ...@@ -151,8 +151,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1333</width> <width>968</width>
<height>727</height> <height>666</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
...@@ -503,6 +503,46 @@ ...@@ -503,6 +503,46 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="1">
<widget class="QLineEdit" name="dist">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>D</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5"/>
</item>
<item> <item>
<widget class="QPushButton" name="pbActualToSetpoint"> <widget class="QPushButton" name="pbActualToSetpoint">
<property name="text"> <property name="text">
...@@ -700,22 +740,33 @@ ...@@ -700,22 +740,33 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QCheckBox" name="autonavEnabled"> <widget class="QPushButton" name="pbSaveWaypoints">
<property name="text"> <property name="text">
<string>Auto</string> <string>Save</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="Line" name="line_5"> <widget class="QPushButton" name="pbLoadWaypoints">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>Load</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> </layout>
</item>
<item>
<widget class="QCheckBox" name="autonavEnabled">
<property name="text">
<string>Enable Autonavigation</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="label_9">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
...@@ -723,12 +774,19 @@ ...@@ -723,12 +774,19 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text">
<string>Threshold</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="delayLabel">
<property name="text"> <property name="text">
<string>Delay</string> <string>Delay</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1">
<widget class="QLineEdit" name="autonavDelay"> <widget class="QLineEdit" name="autonavDelay">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
...@@ -741,6 +799,19 @@ ...@@ -741,6 +799,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLineEdit" name="autonavThreshold">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>0.05</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
...@@ -750,24 +821,6 @@ ...@@ -750,24 +821,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbSaveWaypoints">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbLoadWaypoints">
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
<item> <item>
...@@ -803,7 +856,7 @@ ...@@ -803,7 +856,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1369</width> <width>1004</width>
<height>30</height> <height>30</height>
</rect> </rect>
</property> </property>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment