diff --git a/groundStation/gui/MicroCART/MicroCART.pro b/groundStation/gui/MicroCART/MicroCART.pro index f8aa76c36c28c220e464900187f77d1a8b9225bf..094787c0fc0a27ed7504a4aaeed3448e5a849aaf 100644 --- a/groundStation/gui/MicroCART/MicroCART.pro +++ b/groundStation/gui/MicroCART/MicroCART.pro @@ -16,13 +16,11 @@ INCLUDEPATH += ../../src/frontend/ SOURCES += main.cpp\ mainwindow.cpp \ - wrappers.c \ trackerworker.cpp \ controlworker.cpp \ quaditem.cpp HEADERS += mainwindow.h \ - wrappers.h \ trackerworker.h \ controlworker.h \ quaditem.h diff --git a/groundStation/gui/MicroCART/controlworker.cpp b/groundStation/gui/MicroCART/controlworker.cpp index 6cd8b01c08877ad2b17ef8c27307006f361cb265..0127485bcbd97be98b40c969001ee2bad26cbb51 100644 --- a/groundStation/gui/MicroCART/controlworker.cpp +++ b/groundStation/gui/MicroCART/controlworker.cpp @@ -3,6 +3,7 @@ #include "frontend_param.h" #include "frontend_source.h" #include "graph_blocks.h" +#include "frontend_output.h" #include <QProcess> #include <err.h> @@ -40,7 +41,7 @@ void ControlWorker::getNodes() QStringList const_block_nodes; for (size_t i = 0; i < num_nodes; i++) { nodes.append(QString(nd[i].name)); - if (nd[i].type == BLOCK_CONSTANT) { + if ((nd[i].type == BLOCK_CONSTANT) || (nd[i].type == BLOCK_ADD)) { const_block_nodes.append(nd[i].name); } } @@ -159,6 +160,28 @@ void ControlWorker::getParamValue(QString node, QString param) } } +void ControlWorker::getNodeOutput(QString node) +{ + if (conn) { + frontend_node_data *nd = NULL; + size_t num_nodes = 0; + + frontend_getnodes(conn, &nd, &num_nodes); for (size_t i = 0; i < num_nodes; i++) { + if (QString(nd[i].name) == node) { + frontend_output_data od; + od.block = nd[i].block; + + od.output = 0; // TODO: Get rid of this assumption + + frontend_getoutput(conn, &od); + + emit(gotNodeOutput(node, od.value)); + } + } + frontend_free_node_data(nd, num_nodes); + } +} + void ControlWorker::setParamValue(QString node, QString param, float value) { if (conn) { diff --git a/groundStation/gui/MicroCART/controlworker.h b/groundStation/gui/MicroCART/controlworker.h index 9a2c6de5101100953c3cd65eb8fa5abc5998ba08..c32f46e0d8c2dfb6506d44feed7c89c1731ce87f 100644 --- a/groundStation/gui/MicroCART/controlworker.h +++ b/groundStation/gui/MicroCART/controlworker.h @@ -16,6 +16,7 @@ signals: void gotNodes(QStringList nodes); void gotParams(QStringList params); void gotParamValue(QString node, QString param, float value); + void gotNodeOutput(QString node, float output); void gotConstantBlocks(QStringList blocks); void paramSet(QString node, QString param); void graphRendered(QString graph); @@ -27,6 +28,7 @@ public slots: void getParams(QString node); void getParamValue(QString node, QString param); void setParamValue(QString node, QString name, float value); + void getNodeOutput(QString node); private: struct backend_conn * conn; diff --git a/groundStation/gui/MicroCART/mainwindow.cpp b/groundStation/gui/MicroCART/mainwindow.cpp index b3ee612dd1d3eedeaa233ccd380f1159662599f4..74b375419a9b593bc10717fa634de6e2edba080b 100644 --- a/groundStation/gui/MicroCART/mainwindow.cpp +++ b/groundStation/gui/MicroCART/mainwindow.cpp @@ -8,22 +8,21 @@ #include <QProcessEnvironment> #include <QPixmap> -#include "wrappers.h" #include "trackerworker.h" #include "controlworker.h" #include "graph_blocks.h" #include "quaditem.h" +#include <iostream> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - backendPid(0), - backendPipe(-1), setpointList(new QStandardItemModel(this)), nextSpTimer(new QTimer(this)), sp_x(0.0f), sp_y(0.0f), - sp_z(0.0f) + sp_z(0.0f), + trackerTimer(new QTimer(this)) { ui->setupUi(this); @@ -62,6 +61,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(controlWorker, SIGNAL (gotNodes(QStringList)), this, SLOT (newNodes(QStringList))); connect(controlWorker, SIGNAL (gotParams(QStringList)), this, SLOT (newParams(QStringList))); connect(controlWorker, SIGNAL (gotParamValue(QString, QString, float)), this, SLOT (newParamValue(QString, QString, float))); + connect(controlWorker, SIGNAL (gotNodeOutput(QString, float)), this, SLOT (newNodeOutput(QString, float))); connect(controlWorker, SIGNAL (gotConstantBlocks(QStringList)), this, SLOT (newConstantBlocks(QStringList))); connect(controlWorker, SIGNAL (graphRendered(QString)), this, SLOT (newControlGraph(QString))); connect(controlWorker, SIGNAL (paramSet(QString, QString)), controlWorker, SLOT (getParamValue(QString, QString))); @@ -71,6 +71,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->nodeSelect, SIGNAL (currentIndexChanged(QString)), controlWorker, SLOT (getParams(QString))); connect(this, SIGNAL (getParamValue(QString, QString)), controlWorker, SLOT (getParamValue(QString, QString))); connect(this, SIGNAL (setParamValue(QString, QString, float)), controlWorker, SLOT (setParamValue(QString, QString, float))); + connect(this, SIGNAL (getNodeOutput(QString)), controlWorker, SLOT (getNodeOutput(QString))); /* Connect and disconnect from backend when signals emitted */ connect(this, SIGNAL (connectWorkers()), trackerWorker, SLOT (connectBackend())); @@ -79,16 +80,17 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, SIGNAL (disconnectWorkers()), controlWorker, SLOT (disconnectBackend())); /* Connect refresh button and refresh timer to tracker worker */ - QTimer * trackerTimer = new QTimer(this); - connect(trackerTimer, SIGNAL(timeout()), trackerWorker, SLOT(process())); - connect(ui->pbRefresh, SIGNAL (clicked()), trackerWorker, SLOT (process())); + connect(trackerTimer, SIGNAL(timeout()), this, SLOT(updatePosAtt())); + connect(ui->pbRefresh, SIGNAL (clicked()), this, SLOT (updatePosAtt())); + + connect(this, SIGNAL(getPosAttFromBackend()), trackerWorker, SLOT(process())); /* Timer used for next setpoint */ nextSpTimer->setSingleShot(true); connect(nextSpTimer, SIGNAL (timeout()), this, SLOT (on_pbNextSetpoint_clicked())); /* Start the things */ - trackerTimer->start(300); + trackerTimer->start(100); workerThread->start(); cwThread->start(); @@ -105,9 +107,17 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::updateConsole() +void MainWindow::updatePosAtt() { - if (backendPipe != -1) { + if (ui->posattSrcVrpn->isChecked()) { + emit(getPosAttFromBackend()); + } else if (ui->posattSrcQuad->isChecked()) { + emit(getNodeOutput(ui->xPositionSelect->currentText())); + emit(getNodeOutput(ui->yPositionSelect->currentText())); + emit(getNodeOutput(ui->zPositionSelect->currentText())); + emit(getNodeOutput(ui->pAttitudeSelect->currentText())); + emit(getNodeOutput(ui->rAttitudeSelect->currentText())); + emit(getNodeOutput(ui->yAttitudeSelect->currentText())); } } @@ -133,10 +143,8 @@ void MainWindow::updateTracker(float x, float y, float z, float p, float r, floa void MainWindow::on_pbStart_clicked() { QProcessEnvironment::systemEnvironment().insert("UCART_SOCKET", ui->socketPath->text()); - this->backendPid = startBackend(ui->backendPath_2->text().toStdString().c_str(), &backendPipe); ui->pbStart->setEnabled(false); ui->pbStop->setEnabled(true); - backendState = 1; } void MainWindow::on_pbConnect_clicked() @@ -146,21 +154,14 @@ void MainWindow::on_pbConnect_clicked() ui->pbConnect->setEnabled(false); ui->pbStop->setEnabled(true); emit(connectWorkers()); - backendState = 1; } void MainWindow::on_pbStop_clicked() { emit(disconnectWorkers()); - if (backendPid) { - stopBackend(backendPid, backendPipe); - backendPipe = -1; - backendPid = 0; - } ui->pbStart->setEnabled(true); ui->pbConnect->setEnabled(true); ui->pbStop->setEnabled(false); - backendState = 0; } void MainWindow::on_chooseBackend_clicked() @@ -185,30 +186,93 @@ void MainWindow::newNodes(QStringList blocks) void MainWindow::newConstantBlocks(QStringList blocks) { - QComboBox * xSelect = ui->xSetpointSelect; - xSelect->clear(); - xSelect->addItems(blocks); + ui->xSetpointSelect->clear(); + ui->xSetpointSelect->addItems(blocks); + + ui->ySetpointSelect->clear(); + ui->ySetpointSelect->addItems(blocks); + + ui->zSetpointSelect->clear(); + ui->zSetpointSelect->addItems(blocks); + + ui->yawSetpointSelect->clear(); + ui->yawSetpointSelect->addItems(blocks); + + ui->xPositionSelect->clear(); + ui->xPositionSelect->addItems(blocks); + + ui->yPositionSelect->clear(); + ui->yPositionSelect->addItems(blocks); - QComboBox * ySelect = ui->ySetpointSelect; - ySelect->clear(); - ySelect->addItems(blocks); + ui->zPositionSelect->clear(); + ui->zPositionSelect->addItems(blocks); - QComboBox * zSelect = ui->zSetpointSelect; - zSelect->clear(); - zSelect->addItems(blocks); + ui->pAttitudeSelect->clear(); + ui->pAttitudeSelect->addItems(blocks); + + ui->rAttitudeSelect->clear(); + ui->rAttitudeSelect->addItems(blocks); + + ui->yAttitudeSelect->clear(); + ui->yAttitudeSelect->addItems(blocks); for (ssize_t i = 0; i < blocks.size(); i++) { if (blocks[i].contains("setpoint", Qt::CaseInsensitive) || blocks[i].contains("sp", Qt::CaseInsensitive)) { if (blocks[i].contains("x ", Qt::CaseInsensitive)) { - xSelect->setCurrentIndex(i); + ui->xSetpointSelect->setCurrentIndex(i); } if (blocks[i].contains("y ", Qt::CaseInsensitive)) { - ySelect->setCurrentIndex(i); + ui->ySetpointSelect->setCurrentIndex(i); } if (blocks[i].contains("z ", Qt::CaseInsensitive) || blocks[i].contains("alt", Qt::CaseInsensitive)) { - zSelect->setCurrentIndex(i); + ui->zSetpointSelect->setCurrentIndex(i); + } + if (blocks[i].contains("yaw", Qt::CaseInsensitive) || blocks[i].contains("alt", Qt::CaseInsensitive)) { + ui->yawSetpointSelect->setCurrentIndex(i); } } + + if (blocks[i] == QString("Pitch")) { + ui->pAttitudeSelect->setCurrentIndex(i); + } + + if (blocks[i] == QString("Roll")) { + ui->rAttitudeSelect->setCurrentIndex(i); + } + + if (blocks[i] == QString("Yaw")) { + ui->yAttitudeSelect->setCurrentIndex(i); + } + + if (blocks[i] == QString("Lidar")) { + ui->zPositionSelect->setCurrentIndex(i); + } + + if (blocks[i] == QString("OF X Trim Add")) { + ui->xPositionSelect->setCurrentIndex(i); + } + + if (blocks[i] == QString("OF Y Trim Add")) { + ui->yPositionSelect->setCurrentIndex(i); + } + } +} + +void MainWindow::newNodeOutput(QString node, float val) +{ + /* Update the nav page if quad is set as the source for pos/att */ + if (node == ui->xPositionSelect->currentText()) { + ui->xActual->setText(QString::number(val)); + } else if (node == ui->yPositionSelect->currentText()) { + ui->yActual->setText(QString::number(val)); + } else if (node == ui->zPositionSelect->currentText()) { + ui->zActual->setText(QString::number(val)); + } else if (node == ui->pAttitudeSelect->currentText()) { + ui->pitchActual->setText(QString::number(val)); + } else if (node == ui->rAttitudeSelect->currentText()) { + ui->rollActual->setText(QString::number(val)); + } else if (node == ui->yAttitudeSelect->currentText()) { + ui->yawActual->setText(QString::number(val)); } } @@ -247,17 +311,29 @@ void MainWindow::on_paramValue_returnPressed() void MainWindow::sendSetpoints() { - sp_x = ui->xSetpoint->text().toFloat(); - emit (setParamValue(ui->xSetpointSelect->currentText(), - blockDefs[BLOCK_CONSTANT]->param_names[0], sp_x)); + if (ui->sendX->isChecked()) { + sp_x = ui->xSetpoint->text().toFloat(); + emit (setParamValue(ui->xSetpointSelect->currentText(), + blockDefs[BLOCK_CONSTANT]->param_names[0], sp_x)); + } - sp_y = ui->ySetpoint->text().toFloat(); - emit (setParamValue(ui->ySetpointSelect->currentText(), - blockDefs[BLOCK_CONSTANT]->param_names[0], sp_y)); + if (ui->sendY->isChecked()) { + sp_y = ui->ySetpoint->text().toFloat(); + emit (setParamValue(ui->ySetpointSelect->currentText(), + blockDefs[BLOCK_CONSTANT]->param_names[0], sp_y)); + } - sp_z = ui->zSetpoint->text().toFloat(); - emit (setParamValue(ui->zSetpointSelect->currentText(), - blockDefs[BLOCK_CONSTANT]->param_names[0], sp_z)); + if (ui->sendZ->isChecked()) { + sp_z = ui->zSetpoint->text().toFloat(); + emit (setParamValue(ui->zSetpointSelect->currentText(), + blockDefs[BLOCK_CONSTANT]->param_names[0], sp_z)); + } + + if (ui->sendYaw->isChecked()) { + emit (setParamValue(ui->yawSetpointSelect->currentText(), + blockDefs[BLOCK_CONSTANT]->param_names[0], + ui->yawSetpoint->text().toFloat())); + } } void MainWindow::on_pbAppendSetpoint_clicked() @@ -284,13 +360,14 @@ void MainWindow::on_pbNextSetpoint_clicked() void MainWindow::sendSelectedSetpoint() { if (ui->setpointList->currentIndex().isValid()) { - QRegExp regex("\\[(.*), (.*), (.*)\\]"); + QRegExp regex("\\[(.*), (.*), (.*), (.*)\\]"); int row = ui->setpointList->currentIndex().row(); regex.indexIn(setpointList->item(row)->text()); ui->xSetpoint->setText(regex.cap(1)); ui->ySetpoint->setText(regex.cap(2)); ui->zSetpoint->setText(regex.cap(3)); + ui->yawSetpoint->setText(regex.cap(4)); sendSetpoints(); } @@ -301,6 +378,7 @@ void MainWindow::on_pbActualToSetpoint_clicked() ui->xSetpoint->setText(ui->xActual->text()); ui->ySetpoint->setText(ui->yActual->text()); ui->zSetpoint->setText(ui->zActual->text()); + ui->yawSetpoint->setText(ui->yawActual->text()); } void MainWindow::on_pbDeleteSetpoint_clicked() @@ -318,8 +396,9 @@ void MainWindow::newControlGraph(QString graph) void MainWindow::on_pbActualToWaypoint_clicked() { QString str("[" + ui->xActual->text() + ", "+ - ui->yActual->text() + ", " + - ui->zActual->text() + "]"); + ui->yActual->text() + ", " + + ui->zActual->text() + ", " + + ui->yawActual->text() + "]"); setpointList->appendRow(new QStandardItem(str)); } @@ -354,16 +433,21 @@ void MainWindow::on_pbInsertSetpoint_clicked() } QString str("[" + ui->xSetpoint->text() + ", "+ - ui->ySetpoint->text() + ", " + - ui->zSetpoint->text() + "]"); + ui->ySetpoint->text() + ", " + + ui->zSetpoint->text() + ", " + + ui->yawSetpoint->text() + "]"); setpointList->insertRow(current, new QStandardItem(str)); } void MainWindow::on_pbSaveWaypoints_clicked() { - QString savePath = QFileDialog::getSaveFileName(this); + QString filter = "Waypoints (*.wpt)"; + QString savePath = QFileDialog::getSaveFileName(this, tr("Save waypoint"), QString(), filter, &filter, QFileDialog::DontUseNativeDialog); if (!savePath.isEmpty()) { + QFileInfo finfo(savePath); + if (finfo.suffix().isNull()) + savePath.append(".wpt"); QFile f(savePath); f.open(QIODevice::WriteOnly | QIODevice::Text); for (int i= 0; i < setpointList->rowCount(); i++) { @@ -417,3 +501,20 @@ void MainWindow::on_zSetpoint_returnPressed() emit (setParamValue(ui->zSetpointSelect->currentText(), blockDefs[BLOCK_CONSTANT]->param_names[0], sp_z)); } + +void MainWindow::on_yawSetpoint_returnPressed() +{ + emit (setParamValue(ui->yawSetpointSelect->currentText(), + blockDefs[BLOCK_CONSTANT]->param_names[0], + ui->yawSetpoint->text().toFloat())); +} + +void MainWindow::on_posattSrcVrpn_clicked() +{ + trackerTimer->setInterval(100); +} + +void MainWindow::on_posattSrcQuad_clicked() +{ + trackerTimer->setInterval(500); +} diff --git a/groundStation/gui/MicroCART/mainwindow.h b/groundStation/gui/MicroCART/mainwindow.h index 62b0443047c1fab4a612573f8d90f4ee1e150cda..a67d22907ec0000d4beeda473f132979949994a8 100644 --- a/groundStation/gui/MicroCART/mainwindow.h +++ b/groundStation/gui/MicroCART/mainwindow.h @@ -23,7 +23,9 @@ signals: void connectWorkers(); void disconnectWorkers(); void getParamValue(QString node, QString param); + void getNodeOutput(QString node); void setParamValue(QString node, QString param, float value); + void getPosAttFromBackend(); private slots: void on_pbStart_clicked(); @@ -36,11 +38,12 @@ private slots: void updateTracker(float x, float y, float z, float p, float r, float yaw); - void updateConsole(); + void updatePosAtt(); void newNodes(QStringList blocks); void newParams(QStringList params); void newParamValue(QString node, QString param, float val); + void newNodeOutput(QString node, float output); void newConstantBlocks(QStringList blocks); void newControlGraph(QString graph); @@ -73,16 +76,26 @@ private slots: void on_socketPath_returnPressed(); + void on_xSetpoint_returnPressed(); + + void on_ySetpoint_returnPressed(); + + void on_zSetpoint_returnPressed(); + + void on_posattSrcVrpn_clicked(); + + void on_posattSrcQuad_clicked(); + + void on_yawSetpoint_returnPressed(); + private: Ui::MainWindow *ui; - pid_t backendPid; - int backendPipe; - int backendState; QStandardItemModel * setpointList; QTimer * nextSpTimer; float sp_x; float sp_y; float sp_z; + QTimer * trackerTimer; }; #endif // MAINWINDOW_H diff --git a/groundStation/gui/MicroCART/mainwindow.ui b/groundStation/gui/MicroCART/mainwindow.ui index a6795802eddc4c1dc1e89b03f408fb82bb30762b..097552bfbcfd9ae482f88f835a7cef234974178b 100644 --- a/groundStation/gui/MicroCART/mainwindow.ui +++ b/groundStation/gui/MicroCART/mainwindow.ui @@ -37,7 +37,7 @@ <item row="0" column="1"> <widget class="QLineEdit" name="socketPath"> <property name="enabled"> - <bool>true</bool> + <bool>false</bool> </property> <property name="text"> <string/> @@ -154,8 +154,8 @@ <rect> <x>0</x> <y>0</y> - <width>98</width> - <height>76</height> + <width>968</width> + <height>577</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_8"> @@ -258,6 +258,13 @@ </item> </layout> </item> + <item> + <widget class="Line" name="line_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> @@ -315,6 +322,126 @@ <item> <widget class="QComboBox" name="zSetpointSelect"/> </item> + <item> + <widget class="QLabel" name="label_18"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Yaw Setpoint:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="yawSetpointSelect"/> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="QLabel" name="label_11"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>X Position</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="xPositionSelect"/> + </item> + <item> + <widget class="QLabel" name="label_13"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Y Position </string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="yPositionSelect"/> + </item> + <item> + <widget class="QLabel" name="label_14"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Z Position</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="zPositionSelect"/> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <item> + <widget class="QLabel" name="label_15"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>P Attitude</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="pAttitudeSelect"/> + </item> + <item> + <widget class="QLabel" name="label_16"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>R Attitude</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="rAttitudeSelect"/> + </item> + <item> + <widget class="QLabel" name="label_17"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Y Attitude</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="yAttitudeSelect"/> + </item> </layout> </item> </layout> @@ -362,6 +489,52 @@ </property> </widget> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <item> + <widget class="QLabel" name="label_12"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Position/Attitude Source: </string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="posattSrcVrpn"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Backend Tracker (&VRPN)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="posattSrcQuad"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>From &Quad</string> + </property> + </widget> + </item> + </layout> + </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> @@ -593,36 +766,6 @@ </property> </widget> </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="xSetpoint"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="ySetpoint"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="zSetpoint"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> <item row="2" column="0"> <widget class="QLabel" name="setpointLabel_3"> <property name="text"> @@ -637,6 +780,109 @@ </property> </widget> </item> + <item row="3" column="0"> + <widget class="QLabel" name="yawLabel"> + <property name="text"> + <string>Yaw</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <widget class="QLineEdit" name="xSetpoint"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="sendX"> + <property name="text"> + <string/> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_13"> + <item> + <widget class="QLineEdit" name="ySetpoint"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="sendY"> + <property name="text"> + <string/> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_14"> + <item> + <widget class="QLineEdit" name="zSetpoint"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="sendZ"> + <property name="text"> + <string/> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_15"> + <item> + <widget class="QLineEdit" name="yawSetpoint"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="sendYaw"> + <property name="text"> + <string/> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> </layout> </item> <item> @@ -882,7 +1128,7 @@ <x>0</x> <y>0</y> <width>1004</width> - <height>27</height> + <height>30</height> </rect> </property> </widget> diff --git a/groundStation/gui/MicroCART/wrappers.c b/groundStation/gui/MicroCART/wrappers.c deleted file mode 100644 index 45fdf0b28619f4d7d3cd6803239e6b0e2f999f62..0000000000000000000000000000000000000000 --- a/groundStation/gui/MicroCART/wrappers.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "wrappers.h" -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/socket.h> -#include <unistd.h> -#include <signal.h> -#include <err.h> -#include <stdlib.h> - - -size_t readBackend(int fd, char * buf, size_t maxlen) -{ - int len = read(fd, buf, maxlen); - if (len < 0) { - len = 0; - } - - return len; -} - -int stopBackend(int pid, int pipefd) -{ - close(pipefd); - kill(pid, SIGTERM); - int status; - wait(&status); - return status; -} - -int startBackend(const char * backend, int * pipefd) -{ - /* Create a pipe */ - int pipe_fds[2]; - if (pipe(pipe_fds)) { - warn("Failed to open pipe, cannot start backend!"); - return -1; - } - - int pid = fork(); - if (!pid) { - /* Child closes read end of pipe */ - close(pipe_fds[0]); - - write(pipe_fds[1], "From child", 11); - /* dup write end of pipe to stdout (FD 1), closing old stdout */ - //dup2(pipe_fds[1], 1); - //dup2(pipe_fds[1], 2); - - write(2, "Child stderr\n", 13); - printf("Child stdout\n"); - - /* Don't need whatever FD is in pipe_fds[1] anymore, since it is stdout now */ - close(pipe_fds[1]); - - execl(backend, "BackEnd", NULL); - exit(0); - } - - /* Return the read end of the pipe in pipefd pointer */ - *pipefd = pipe_fds[0]; - - - /* Parent closes write end of the pipe */ - close(pipe_fds[1]); - - - return pid; -} diff --git a/groundStation/gui/MicroCART/wrappers.h b/groundStation/gui/MicroCART/wrappers.h deleted file mode 100644 index 6a29ecf90a9b59c71a3595242fa5fb31c68899e8..0000000000000000000000000000000000000000 --- a/groundStation/gui/MicroCART/wrappers.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef WRAPPERS_H -#define WRAPPERS_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <stdio.h> - -int startBackend(const char * backend, int * pipefd); -int stopBackend(int pid, int pipefd); -size_t readBackend(int fd, char * buf, size_t maxlen); - -#ifdef __cplusplus -} -#endif - -#endif // WRAPPERS_H diff --git a/groundStation/src/frontend/frontend_output.h b/groundStation/src/frontend/frontend_output.h index b2a4e4333cc83344c0154c9bc20d764d9439799d..f0e2fbaea121bf7a5c726501c187640d9d1d2434 100644 --- a/groundStation/src/frontend/frontend_output.h +++ b/groundStation/src/frontend/frontend_output.h @@ -8,9 +8,15 @@ * * Returns 0 on success, 1 on error */ +#ifdef __cplusplus +extern "C" { +#endif int frontend_getoutput( struct backend_conn * conn, struct frontend_output_data * output_data); +#ifdef __cplusplus +} +#endif -#endif /* __FRONTEND_OUTPUT_H */ \ No newline at end of file +#endif /* __FRONTEND_OUTPUT_H */