diff --git a/groundStation/gui/MicroCART/crazyflieworker.cpp b/groundStation/gui/MicroCART/crazyflieworker.cpp index 853dc259d83a11b02a8ec6c7efa13531f20e52d2..cb241a10c9e6d80736720022c3823d21ca2e74dd 100644 --- a/groundStation/gui/MicroCART/crazyflieworker.cpp +++ b/groundStation/gui/MicroCART/crazyflieworker.cpp @@ -108,6 +108,24 @@ void CrazyflieWorker::sendAttSetpoint() } } +void CrazyflieWorker::sendMixedAttSetpoint(){ + + qInfo() << "send mixed setpoint"; + + if(isBackendConnected){ + struct frontend_override_data data; + data.enable = 3; //roll and pitch are attitude, yaw is attitude angle + data.time = 0; + data.throttle = currAttitudeSetpoint.throttle; + data.roll = currAttitudeSetpoint.roll; + data.pitch = currAttitudeSetpoint.pitch; + data.yaw = currAttitudeRateSetpoint.yaw; + + //send setpoint + frontend_setoutputoverride(conn, &data); + } +} + void CrazyflieWorker::getParamValue(QString paramName){ struct toc_info info = paramNameLookup(paramName); diff --git a/groundStation/gui/MicroCART/crazyflieworker.h b/groundStation/gui/MicroCART/crazyflieworker.h index 1ff1ca6792e266f64a65246f6a057ec766d911bb..43d37fc4955d23b4a245edf254aba96823017d7d 100644 --- a/groundStation/gui/MicroCART/crazyflieworker.h +++ b/groundStation/gui/MicroCART/crazyflieworker.h @@ -52,6 +52,7 @@ public slots: void disconnectBackend(); void sendAttSetpoint(); void sendAttRateSetpoint(); + void sendMixedAttSetpoint(); void getParamValue(QString paramName); void setCurrAttSetpoint(float roll, float pitch, float yaw, float throttle); void setCurrAttRateSetpoint(float rollRate, float pitchRate, float yawRate, float throttleRate); @@ -62,8 +63,6 @@ private: struct backend_conn * conn; Setpoint currAttitudeSetpoint; Setpoint currAttitudeRateSetpoint; - void sendAttitudeSetpoint(); - void sendAttitudeRateSetpoint(); std::string getLogFile(int type); void loadParamIds(); void loadLogIds(); diff --git a/groundStation/gui/MicroCART/mainwindow.cpp b/groundStation/gui/MicroCART/mainwindow.cpp index 18a70c83812f15667fdf1495fbbe284d2cdd8999..773e7291fa0f825d79f8892c01d2ada7d83b5250 100644 --- a/groundStation/gui/MicroCART/mainwindow.cpp +++ b/groundStation/gui/MicroCART/mainwindow.cpp @@ -108,13 +108,16 @@ MainWindow::MainWindow(QWidget *parent) : connect(crazyflieTimer, SIGNAL(timeout()), this, SLOT(trigger_send_setpoint())); connect(this, SIGNAL(triggerAttSetpointSend()), crazyflieWorker, SLOT(sendAttSetpoint())); connect(this, SIGNAL(triggerAttRateSetpointSend()), crazyflieWorker, SLOT(sendAttRateSetpoint())); + connect(this, SIGNAL(triggerMixedAttSetpointSend()), crazyflieWorker, SLOT(sendMixedAttSetpoint())); connect(crazyflieWorker, SIGNAL (gotParamGroups(QStringList)), this, SLOT (setParamGroups(QStringList))); + connect(ui->paramGroupComboBox, SIGNAL (currentIndexChanged(int)), this, SLOT (getGroupBoxChange(int))); connect(ui->paramGroupComboBox_2, SIGNAL (currentIndexChanged(int)), this, SLOT (getGroupBox2Change(int))); connect(ui->paramEntriesComboBox, SIGNAL (currentIndexChanged(int)), this, SLOT (getEntryBoxChange(int))); connect(ui->paramEntriesComboBox_2, SIGNAL (currentIndexChanged(int)), this, SLOT (getEntryBoxChange2(int))); connect(ui->pb_getParam, SIGNAL (clicked()), this, SLOT (on_pb_getParam_click())); connect(ui->pb_setParam, SIGNAL (clicked()), this, SLOT (on_pb_setParam_click())); + connect(crazyflieWorker, SIGNAL (gotGroupEntries(int, QStringList)), this, SLOT (newGroupEntries(int, QStringList))); connect(this, SIGNAL (getGroupEntries(int, QString)), crazyflieWorker, SLOT (getGroupEntries(int, QString))); connect(this, SIGNAL (getParamValue(QString)), crazyflieWorker, SLOT (getParamValue(QString))); @@ -125,9 +128,11 @@ MainWindow::MainWindow(QWidget *parent) : connect(workerStartTimer, SIGNAL (timeout()), trackerWorker, 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()), controlWorker, SLOT (connectBackend())); connect(this, SIGNAL (connectWorkers()), crazyflieWorker, SLOT (connectBackend())); + connect(this, SIGNAL (disconnectWorkers()), trackerWorker, SLOT (disconnectBackend())); connect(this, SIGNAL (disconnectWorkers()), controlWorker, SLOT (disconnectBackend())); connect(this, SIGNAL (disconnectWorkers()), crazyflieWorker, SLOT (disconnectBackend())); @@ -835,7 +840,10 @@ void MainWindow::updateGamepad(){ float yaw = gamepadMonitor->getYaw(); float thrust = gamepadMonitor->getThrust(); - crazyflieWorker->setCurrAttRateSetpoint(roll, pitch, yaw, thrust); + //create mixed setpoint + crazyflieWorker->setCurrAttSetpoint(roll, pitch, 0, thrust); + crazyflieWorker->setCurrAttRateSetpoint(0, 0, yaw, 0); + ui->rollSetpointBox->setText(QString::number(roll)); ui->pitchSetpointBox->setText(QString::number(pitch)); ui->yawSetpointBox->setText(QString::number(yaw)); @@ -874,9 +882,8 @@ void MainWindow::on_pb_configThrust_clicked() void MainWindow::on_rbManualSetpoint_toggled(bool checked) { if(checked) { - //TODO Fix this, hacky fix becuase the backend gets overloaded with setpoints - //ideally want to constantly send setpoints crazyflieWorker->setCurrAttRateSetpoint(0,0,0,0); + crazyflieWorker->setCurrAttSetpoint(0,0,0,0); ui->pitchSetpointBox->setText("0"); ui->rollSetpointBox->setText("0"); ui->yawSetpointBox->setText("0"); @@ -887,26 +894,35 @@ void MainWindow::on_rbManualSetpoint_toggled(bool checked) ui->tActual-> setEnabled(true); ui->angleRadioButton-> setEnabled(true); ui->rateRadioButton-> setEnabled(true); + ui->applySetpointButton->setEnabled(true); + ui->stopSetpointButton->setEnabled(true); } } void MainWindow::on_rbGamepadControl_toggled(bool checked) { - ui->rollSetpointBox-> setEnabled(false); - ui->pitchSetpointBox-> setEnabled(false); - ui->yawSetpointBox-> setEnabled(false); - ui->tActual-> setEnabled(false); - ui->angleRadioButton-> setEnabled(false); - ui->rateRadioButton-> setEnabled(false); - ui->rateRadioButton-> setChecked(true); + if(checked){ + ui->rollSetpointBox-> setEnabled(false); + ui->pitchSetpointBox-> setEnabled(false); + ui->yawSetpointBox-> setEnabled(false); + ui->tActual-> setEnabled(false); + ui->angleRadioButton-> setEnabled(false); + ui->rateRadioButton-> setEnabled(false); + ui->applySetpointButton->setEnabled(false); + ui->stopSetpointButton->setEnabled(false); + } } void MainWindow::trigger_send_setpoint(){ - if(ui->angleRadioButton->isChecked()){ - emit(triggerAttSetpointSend()); + if(ui->rbGamepadControl->isChecked()){ + //using gamepad, send mixed attitude setpoint + emit(triggerMixedAttSetpointSend()); }else{ - emit(triggerAttRateSetpointSend()); - + if(ui->angleRadioButton->isChecked()){ + emit(triggerAttSetpointSend()); + }else{ + emit(triggerAttRateSetpointSend()); + } } } diff --git a/groundStation/gui/MicroCART/mainwindow.h b/groundStation/gui/MicroCART/mainwindow.h index f1cfb88af35af0af82cbdbc8eebcdc29293ceb2c..1a706bab06e5b036acc064881b78fcee0f517b58 100644 --- a/groundStation/gui/MicroCART/mainwindow.h +++ b/groundStation/gui/MicroCART/mainwindow.h @@ -36,6 +36,7 @@ signals: void getGroupEntries(int box, QString gName); void triggerAttSetpointSend(); void triggerAttRateSetpointSend(); + void triggerMixedAttSetpointSend(); private slots: void on_pbStart_clicked(); diff --git a/groundStation/gui/MicroCART/mainwindow.ui b/groundStation/gui/MicroCART/mainwindow.ui index 6e92e077e2d1a7778ad5a3fa72d237ad13855cb5..b360c4e7365c6292de26246c5fc2e74080b1d96a 100644 --- a/groundStation/gui/MicroCART/mainwindow.ui +++ b/groundStation/gui/MicroCART/mainwindow.ui @@ -33,7 +33,7 @@ </size> </property> <property name="currentIndex"> - <number>0</number> + <number>4</number> </property> <widget class="QWidget" name="backend"> <attribute name="title">