diff --git a/groundStation/gui/MicroCART/mainwindow.cpp b/groundStation/gui/MicroCART/mainwindow.cpp index d457ed40d005117c1f1df63cbe474d9dea58bc5a..4dc1382073f27e409aaa31d1425981f2c9e3a23c 100644 --- a/groundStation/gui/MicroCART/mainwindow.cpp +++ b/groundStation/gui/MicroCART/mainwindow.cpp @@ -15,7 +15,6 @@ #include <QProcess> #include <QDebug> -#include "trackerworker.h" #include "controlworker.h" #include "crazyflieworker.h" #include "quaditem.h" @@ -24,20 +23,17 @@ #include "graph_blocks.h" #include <iostream> + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - setpointList(new QStandardItemModel(this)), - nextSpTimer(new QTimer(this)), sp_roll(0.0f), sp_pitch(0.0f), sp_yaw(0.0f), sp_thrust(0.0f), - trackerTimer(new QTimer(this)), workerStartTimer(new QTimer(this)), crazyflieTimer(new QTimer(this)), backendProcess(new QProcess(this)), - matlabProcess(new QProcess(this)), pollGamepadTimer(new QTimer(this)), connectedWorkers(0) { @@ -46,38 +42,17 @@ MainWindow::MainWindow(QWidget *parent) : qRegisterMetaType<int8_t>("int8_t"); QGraphicsScene *posScene = new QGraphicsScene(this); - // ui->posView->setScene(posScene); + QuadItem * posIndicator = new QuadItem(); posScene->addItem(posIndicator); QGraphicsScene *attScene = new QGraphicsScene(this); - //ui->attView->setScene(attScene); + QADI * attIndicator = new QADI(); attScene->addWidget(attIndicator); - workerStartTimer->setSingleShot(true); - /* Create a thread for workers */ - //QThread* workerThread = new QThread(this); - - /* Create a worker to update the tracker */ - // TrackerWorker * trackerWorker = new TrackerWorker(); - - /* Move it to the worker thread. This means that slots of this worker - * will run in the worker thread, and not block the UI */ - //trackerWorker->moveToThread(workerThread); - - /* Connect tracker worker */ - //connect(trackerWorker, SIGNAL (finished(float, float, float, float, float, float)), - // this, SLOT (updateTracker(float, float, float, float, float, float))); - - //connect(trackerWorker, SIGNAL (finished(float, float, float, float, float, float)), - // posIndicator, SLOT(updatePos(float,float,float,float,float,float))); - - //connect(trackerWorker, SIGNAL (finished(float, float, float, float, float, float)), - // attIndicator, SLOT(updateAttitude(float, float, float, float, float, float))); - backendProcess->setProcessChannelMode(QProcess::MergedChannels); /* Create another worker for the control graph */ @@ -86,17 +61,9 @@ MainWindow::MainWindow(QWidget *parent) : controlWorker->moveToThread(cwThread); /* Connect signals from control worker */ - 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))); /* Signals to control worker */ - // connect(ui->pbControlRefresh, SIGNAL (clicked()), controlWorker, SLOT (getNodes())); - // 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))); @@ -160,17 +127,14 @@ MainWindow::MainWindow(QWidget *parent) : connect(crazyflieWorker, SIGNAL (gotParamValue(QString, float)), this, SLOT (displayParamValue(QString, float))); /* Connect and disconnect from backend when signals emitted */ - //connect(workerStartTimer, SIGNAL (timeout()), trackerWorker, SLOT (connectBackend())); connect(workerStartTimer, SIGNAL (timeout()), logWorker, SLOT (connectBackend())); connect(workerStartTimer, SIGNAL (timeout()), controlWorker, SLOT (connectBackend())); connect(workerStartTimer, SIGNAL (timeout()), crazyflieWorker, SLOT (connectBackend())); - //connect(this, SIGNAL (connectWorkers()), trackerWorker, SLOT (connectBackend())); connect(this, SIGNAL (connectWorkers()), logWorker, SLOT (connectBackend())); connect(this, SIGNAL (connectWorkers()), controlWorker, SLOT (connectBackend())); connect(this, SIGNAL (connectWorkers()), crazyflieWorker, SLOT (connectBackend())); - //connect(this, SIGNAL (disconnectWorkers()), trackerWorker, SLOT (disconnectBackend())); connect(this, SIGNAL (disconnectWorkers()), logWorker, SLOT (disconnectBackend())); connect(this, SIGNAL (disconnectWorkers()), controlWorker, SLOT (disconnectBackend())); connect(this, SIGNAL (disconnectWorkers()), crazyflieWorker, SLOT (disconnectBackend())); @@ -184,36 +148,17 @@ MainWindow::MainWindow(QWidget *parent) : connect(controlWorker, SIGNAL (connected()), this, SLOT (workerConnected())); connect(controlWorker, SIGNAL (disconnected()), this, SLOT (workerDisconnected())); - //connect(trackerWorker, SIGNAL (connected()), this, SLOT (workerConnected())); - //connect(trackerWorker, SIGNAL (disconnected()), this, SLOT (workerDisconnected())); - connect(logWorker, SIGNAL (connected()), this, SLOT (workerConnected())); connect(logWorker, SIGNAL (disconnected()), this, SLOT (workerDisconnected())); connect(crazyflieWorker, SIGNAL (connected()), this, SLOT (workerConnected())); connect(crazyflieWorker, SIGNAL (disconnected()), this, SLOT (workerDisconnected())); - /* Connect refresh button and refresh timer to tracker worker */ - 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(100); crazyflieTimer->start(300); - //workerThread->start(); cwThread->start(); cfThread->start(); logThread->start(); - matlabProcess->start(); - - /* Connect the setpointlist to the model */ - // ui->setpointList->setModel(setpointList); ui->pb_getParam->setEnabled(false); ui->pb_setParam->setEnabled(false); @@ -231,10 +176,6 @@ MainWindow::MainWindow(QWidget *parent) : logVar4 = "Logging Variable 4"; logVar5 = "Logging Variable 5"; - /* Connect various things that can result in sending setpoints */ - // connect(ui->pbSendSetpoint, SIGNAL (clicked()), this, SLOT (sendSetpoints())); - // connect(ui->setpointList, SIGNAL (doubleClicked(QModelIndex)), this, SLOT (sendSelectedSetpoint())); - /* start gamepad monitor */ gamepadMonitor = new GamepadMonitor(); if(gamepadMonitor->isGamepadConnected()){ @@ -255,8 +196,6 @@ MainWindow::MainWindow(QWidget *parent) : ui->gamepadYawScale->setValue((int)gamepadMonitor->getYawScale()); ui->gamepadThrustScale->setValue((int)gamepadMonitor->getThrustScale()); - - /* Populate scripts list */ QDir scriptsDir("scripts/"); QStringList scripts = scriptsDir.entryList(); @@ -273,28 +212,6 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::connectMatlab() -{ - -} - -void MainWindow::on_run_data_analysis_button_clicked() -{ - QProcess * matProcess = new QProcess(this); - QString matlab = "/usr/local/bin/matlab"; - matProcess->start(matlab, QStringList() << QString("-nodesktop")<< QString("-nosplash")<<QString("-r")<<QString("run('../../../controls/DataAnalysisTool/Tool/GUI.m');")); -} - -void MainWindow::updatePosAtt() -{ - // 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())); -} - void MainWindow::updateTracker(float thrust, float pitch, float roll, float yaw, float pitchRate, float rollRate, float yawRate) { ui->currThrustActual->setText(QString::number(thrust)); @@ -310,7 +227,6 @@ void MainWindow::updateTracker(float thrust, float pitch, float roll, float yaw, void MainWindow::on_pbStart_clicked() { backendProcess->setProgram(ui->backendPath->text()); - backendProcess->start(); } @@ -384,18 +300,6 @@ void MainWindow::on_chooseBackend_clicked() ui->backendPath->setText(backendPath); } - -void MainWindow::newNodes(QStringList blocks) -{ - // QComboBox * select = ui->nodeSelect; - // select->clear(); - // select->addItems(blocks); - - // this->ui->noGraphWarning1->setVisible(false); - // this->ui->noGraphWarning2->setVisible(false); - // this->ui->noGraphWarningLine->setVisible(false); -} - void MainWindow::setParamGroups(QStringList groupNames) { ui->paramGroupComboBox->addItem(""); ui->paramGroupComboBox->addItems(groupNames); @@ -408,9 +312,6 @@ void MainWindow::setLoggingVariableBox(QStringList variableNames) { } void MainWindow::getGroupBoxChange(int index) { - // for(int i = 0; i < ui->paramGroupComboBox->count(); i++) { - // ui->paramEntriesComboBox->removeItem(i); - // } ui->paramEntriesComboBox->clear(); QString qStrGroup = ui->paramGroupComboBox->itemText(index); std::string check = qStrGroup.toStdString(); @@ -424,9 +325,6 @@ void MainWindow::getGroupBoxChange(int index) { } void MainWindow::getGroupBox2Change(int index) { - // for(int i = 0; i < ui->paramGroupComboBox->count(); i++) { - // ui->paramEntriesComboBox->removeItem(i); - // } ui->paramEntriesComboBox_2->clear(); QString qStrGroup = ui->paramGroupComboBox_2->itemText(index); std::string check = qStrGroup.toStdString(); @@ -492,331 +390,6 @@ void MainWindow::displayParamValue(QString key, float value) { ui->valueVallabel->setNum(value); } -void MainWindow::newConstantBlocks(QStringList 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); - - // ui->zPositionSelect->clear(); - // ui->zPositionSelect->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)) { - // ui->xSetpointSelect->setCurrentIndex(i); - // } - // if (blocks[i].contains("y ", Qt::CaseInsensitive)) { - // ui->ySetpointSelect->setCurrentIndex(i); - // } - // if (blocks[i].contains("z ", Qt::CaseInsensitive) || blocks[i].contains("alt", Qt::CaseInsensitive)) { - // 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)); - // } -} - -void MainWindow::newParams(QStringList params) -{ - // QComboBox * select = ui->paramSelect; - // select->clear(); - // select->addItems(params); -} - -void MainWindow::newParamValue(QString node, QString param, float val) -{ - // ui->paramValue->setText(QString::number(val)); - - // /* Update the nav page setpoints if it's a setpoint paramvalue */ - // if (node == ui->xSetpointSelect->currentText()) { - // ui->xSetpoint->setText(QString::number(val)); - // } else if (node == ui->ySetpointSelect->currentText()) { - // ui->ySetpoint->setText(QString::number(val)); - // } else if (node == ui->zSetpointSelect->currentText()) { - // ui->zSetpoint->setText(QString::number(val)); - // } -} - -void MainWindow::on_paramSelect_currentIndexChanged(const QString &arg1) -{ - // emit(getParamValue(ui->nodeSelect->currentText(), arg1)); -} - -void MainWindow::on_paramValue_returnPressed() -{ - // emit (setParamValue(ui->nodeSelect->currentText(), - // ui->paramSelect->currentText(), - // ui->paramValue->text().toFloat())); -} - - -void MainWindow::sendSetpoints() -{ - - // if (ui->sendX->isChecked()) { - // sp_x = ui->xSetpoint->text().toFloat(); - // emit (setParamValue(ui->xSetpointSelect->currentText(), - // blockDefs[BLOCK_CONSTANT]->param_names[0], sp_x)); - // } - - // if (ui->sendY->isChecked()) { - // sp_y = ui->ySetpoint->text().toFloat(); - // emit (setParamValue(ui->ySetpointSelect->currentText(), - // blockDefs[BLOCK_CONSTANT]->param_names[0], sp_y)); - // } - - // 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() -{ - // QString str("[" + ui->xSetpoint->text() + ", "+ - // ui->ySetpoint->text() + ", " + - // ui->zSetpoint->text() + ", " + - // ui->yawSetpoint->text() + "]"); - - // setpointList->appendRow(new QStandardItem(str)); -} - -void MainWindow::on_pbNextSetpoint_clicked() -{ - // QListView * listView = ui->setpointList; - // if (listView->currentIndex().isValid() && setpointList->index(listView->currentIndex().row() + 1, 0).isValid()) { - // listView->setCurrentIndex(setpointList->index(listView->currentIndex().row() + 1, 0)); - // } else { - // listView->setCurrentIndex(setpointList->index(0, 0)); - // } - // sendSelectedSetpoint(); -} - - -void MainWindow::sendSelectedSetpoint() -{ - // if (ui->setpointList->currentIndex().isValid()) { - // 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(); - // } -} - -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() -{ - // if (ui->setpointList->currentIndex().isValid()) { - // setpointList->removeRow(ui->setpointList->currentIndex().row()); - // } -} - -// void MainWindow::newControlGraph(QString graph) -// { -// ui->graphImage->setPixmap(QPixmap(graph)); -// } - -void MainWindow::on_pbActualToWaypoint_clicked() -{ - // QString str("[" + ui->xActual->text() + ", "+ - // ui->yActual->text() + ", " + - // ui->zActual->text() + ", " + - // ui->yawActual->text() + "]"); - - // setpointList->appendRow(new QStandardItem(str)); -} - -void MainWindow::on_pbMoveUp_clicked() -{ - // if (ui->setpointList->currentIndex().isValid()) { - // int current = ui->setpointList->currentIndex().row(); - // if (current > 0) { - // setpointList->insertRow(current - 1, setpointList->takeItem(current)); - // setpointList->removeRow(current + 1); - // } - // } -} - -void MainWindow::on_pbMoveDown_clicked() -{ - // if (ui->setpointList->currentIndex().isValid()) { - // int current = ui->setpointList->currentIndex().row(); - // if (current < (setpointList->rowCount() - 1)) { - // setpointList->insertRow(current + 2, setpointList->takeItem(current)); - // setpointList->removeRow(current); - // } - // } -} - -void MainWindow::on_pbInsertSetpoint_clicked() -{ - // int current = 0; - // if (ui->setpointList->currentIndex().isValid()) { - // current = ui->setpointList->currentIndex().row(); - // } - - // QString str("[" + ui->xSetpoint->text() + ", "+ - // ui->ySetpoint->text() + ", " + - // ui->zSetpoint->text() + ", " + - // ui->yawSetpoint->text() + "]"); - // setpointList->insertRow(current, new QStandardItem(str)); -} - -void MainWindow::on_pbSaveWaypoints_clicked() -{ - 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++) { - f.write(setpointList->item(i)->text().toStdString().c_str()); - f.write("\n"); - } - f.close(); - } -} - -void MainWindow::on_pbLoadWaypoints_clicked() -{ - - QString filter = "Waypoints (*.wpt)"; - QString openPath = QFileDialog::getOpenFileName(this, tr("Open Waypoint File"), QString(),filter); - - if (!openPath.isEmpty()) { - QFile f(openPath); - f.open(QIODevice::ReadOnly | QIODevice::Text); - - setpointList->clear(); - while (!f.atEnd()) { - QString line = f.readLine(); - line.chop(1); - setpointList->appendRow(new QStandardItem(line)); - } - f.close(); - } -} - -void MainWindow::on_xSetpoint_returnPressed() -{ - // sp_x = ui->xSetpoint->text().toFloat(); - // emit (setParamValue(ui->xSetpointSelect->currentText(), - // blockDefs[BLOCK_CONSTANT]->param_names[0], sp_x)); -} - -void MainWindow::on_ySetpoint_returnPressed() -{ - // sp_y = ui->ySetpoint->text().toFloat(); - // emit (setParamValue(ui->ySetpointSelect->currentText(), - // blockDefs[BLOCK_CONSTANT]->param_names[0], sp_y)); -} - -void MainWindow::on_zSetpoint_returnPressed() -{ - // sp_z = ui->zSetpoint->text().toFloat(); - // 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_applySetpointButton_clicked() { sp_roll = ui->rollSetpointBox->text().toFloat(); @@ -832,7 +405,6 @@ void MainWindow::on_applySetpointButton_clicked() //send as rate setpoint emit(rateSetpointSignal(sp_roll, sp_pitch, sp_yaw, sp_thrust)); } - trigger_send_setpoint(); } @@ -893,8 +465,8 @@ void MainWindow::onGamepadDisconnect(){ ui->gamepadThrustScale->setEnabled(false); ui->thrustScaleLabel->setEnabled(false); ui->thrustScaleNote->setEnabled(false); - - + ui->degPerSecLabel->setEnabled(false); + ui->degLabel->setEnabled(false); } @@ -920,6 +492,9 @@ void MainWindow::onGamepadConnect(){ ui->gamepadThrustScale->setEnabled(true); ui->thrustScaleLabel->setEnabled(true); ui->thrustScaleNote->setEnabled(true); + ui->degPerSecLabel->setEnabled(true); + ui->degLabel->setEnabled(true); + } void MainWindow::updateGamepad(){ @@ -976,8 +551,6 @@ void MainWindow::on_pb_configThrust_clicked() gamepadMonitor->configureAxis("thrust"); } - - void MainWindow::on_rbManualSetpoint_toggled(bool checked) { if(checked) { @@ -1229,8 +802,7 @@ void MainWindow::graphLogs(QStringList logs) // qInfo() << x0 << endl; // qInfo() << y0 << endl; - //start graph and set data - + //set data if(log0) { ui->dataPlot->graph(0)->setData(x0, y0); } @@ -1362,6 +934,7 @@ void MainWindow::getLogEntryBoxChange1(QString text) { } } } + void MainWindow::getLogEntryBoxChange2(QString text) { if(logVar2.toStdString().compare("Logging Variable 2")) { ui->logEntriesComboBox1->addItem(logVar2); @@ -1390,6 +963,7 @@ void MainWindow::getLogEntryBoxChange2(QString text) { } } } + void MainWindow::getLogEntryBoxChange3(QString text) { if(logVar3.toStdString().compare("Logging Variable 3")) { ui->logEntriesComboBox1->addItem(logVar3); @@ -1418,6 +992,7 @@ void MainWindow::getLogEntryBoxChange3(QString text) { } } } + void MainWindow::getLogEntryBoxChange4(QString text) { if(logVar4.toStdString().compare("Logging Variable 4")) { ui->logEntriesComboBox2->addItem(logVar4); @@ -1446,6 +1021,7 @@ void MainWindow::getLogEntryBoxChange4(QString text) { } } } + void MainWindow::getLogEntryBoxChange5(QString text) { if(logVar5.toStdString().compare("Logging Variable 5")) { ui->logEntriesComboBox2->addItem(logVar5); diff --git a/groundStation/gui/MicroCART/mainwindow.h b/groundStation/gui/MicroCART/mainwindow.h index 345a41ebc05ebaa7582704d0272f1a1c33345367..28a220315fd3b62239e30836ad13d5d9b37f0dda 100644 --- a/groundStation/gui/MicroCART/mainwindow.h +++ b/groundStation/gui/MicroCART/mainwindow.h @@ -55,78 +55,48 @@ private slots: void updateTracker(float thrust, float pitch, float roll, float yaw, float pitchRate, float rollRate, float yawRate); - 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 newGroupEntries(int box, QStringList entries); void on_pb_getParam_click(); void on_pb_setParam_click(); - void on_paramSelect_currentIndexChanged(const QString &arg1); - - void on_paramValue_returnPressed(); - - void on_pbAppendSetpoint_clicked(); - - void on_pbNextSetpoint_clicked(); - - void sendSetpoints(); - void sendSelectedSetpoint(); - - void on_pbActualToSetpoint_clicked(); - - void on_pbDeleteSetpoint_clicked(); - - void on_pbActualToWaypoint_clicked(); - - void on_pbMoveUp_clicked(); - - void on_pbMoveDown_clicked(); - - void on_pbInsertSetpoint_clicked(); - - void on_pbSaveWaypoints_clicked(); - - void on_pbLoadWaypoints_clicked(); - - void on_xSetpoint_returnPressed(); - - void on_run_data_analysis_button_clicked(); - - void on_ySetpoint_returnPressed(); - - void on_zSetpoint_returnPressed(); - - void on_yawSetpoint_returnPressed(); - void backendStarted(); - void connectMatlab(); + void backendFinished(int exitCode, QProcess::ExitStatus exitStatus); + void backendError(QProcess::ProcessError error); + void backendRead(); + void workerConnected(); + void workerDisconnected(); void on_applySetpointButton_clicked(); void on_stopSetpointButton_clicked(); + void setParamGroups(QStringList groupNames); + void getGroupBoxChange(int index); + void getGroupBox2Change(int index); + void setLoggingVariableBox(QStringList variableNames); + void displayParamValue(QString param, float value); + void getEntryBoxChange(int index); + void getEntryBoxChange2(int index); void onGamepadDisconnect(); + void onGamepadConnect(); + void on_pb_configRoll_clicked(); + void updateGamepad(); void on_pb_resetConfig_clicked(); @@ -160,20 +130,32 @@ private slots: void gotLogBlockNames(QStringList logBlockNames); void on_pb_lbRefresh(); + void on_pb_lbStop(); + void on_pb_lbResume(); + void on_pb_lbPause(); + void on_pb_lbDelete(); + void useLogBlockID(int id, int8_t command); + void setLogButtons(bool isEnabled); + void fillLogVariablesBox(QStringList activeVars); + void getLogEntryBoxChange1(QString text); + void getLogEntryBoxChange2(QString text); + void getLogEntryBoxChange3(QString text); + void getLogEntryBoxChange4(QString text); + void getLogEntryBoxChange5(QString text); - void receiveLogFile(QString filename); + void receiveLogFile(QString filename); //void on_pb_stopLog_clicked(); @@ -183,19 +165,15 @@ private slots: private: Ui::MainWindow *ui; - QStandardItemModel * setpointList; - QTimer * nextSpTimer; float sp_roll; float sp_pitch; float sp_yaw; float sp_thrust; - QTimer * trackerTimer; QString logVar1, logVar2, logVar3, logVar4, logVar5; QTimer * workerStartTimer; QTimer * crazyflieTimer; QTimer *pollGamepadTimer; QProcess * backendProcess; - QProcess * matlabProcess; int connectedWorkers; GamepadMonitor *gamepadMonitor; CrazyflieWorker *crazyflieWorker; diff --git a/groundStation/gui/MicroCART/mainwindow.ui b/groundStation/gui/MicroCART/mainwindow.ui index 33cbca21987096dd10982b15a2e79968a26caa10..9ac99c70e30c0fafefd910832f1ff79f305c4408 100644 --- a/groundStation/gui/MicroCART/mainwindow.ui +++ b/groundStation/gui/MicroCART/mainwindow.ui @@ -33,7 +33,7 @@ </size> </property> <property name="currentIndex"> - <number>2</number> + <number>3</number> </property> <widget class="QWidget" name="backend"> <attribute name="title"> @@ -780,7 +780,7 @@ <string>Pitch Scale: Deg</string> </property> </widget> - <widget class="QLabel" name="label_4"> + <widget class="QLabel" name="degPerSecLabel"> <property name="geometry"> <rect> <x>294</x> @@ -793,7 +793,7 @@ <string>deg/s</string> </property> </widget> - <widget class="QLabel" name="label_9"> + <widget class="QLabel" name="degLabel"> <property name="geometry"> <rect> <x>852</x> @@ -826,8 +826,8 @@ <zorder>thrustScaleNote</zorder> <zorder>gamepadRollScale</zorder> <zorder>gamepadPitchScale</zorder> - <zorder>label_4</zorder> - <zorder>label_9</zorder> + <zorder>degPerSecLabel</zorder> + <zorder>degLabel</zorder> </widget> <widget class="QWidget" name="plots"> <attribute name="title">