diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 1ea95f2..23f04bd 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -717,7 +717,6 @@ INCLUDEPATH += \ FORMS += \ src/VehicleSetup/ParameterEditor.ui \ - src/ui/QGCPX4VehicleConfig.ui \ src/VehicleSetup/SetupView.ui \ HEADERS+= \ diff --git a/src/ui/QGCConfigView.cc b/src/ui/QGCConfigView.cc deleted file mode 100644 index 1c1a354..0000000 --- a/src/ui/QGCConfigView.cc +++ /dev/null @@ -1,76 +0,0 @@ -#include "QGCConfigView.h" -#include "ui_QGCConfigView.h" -#include "UASManager.h" -#include "QGCPX4VehicleConfig.h" -#include "MainWindow.h" - -QGCConfigView::QGCConfigView(QWidget *parent) : - QWidget(parent), - ui(new Ui::QGCConfigView), - config(NULL), - mav(NULL) -{ - ui->setupUi(this); - - connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(activeUASChanged(UASInterface*))); - - ui->gridLayout->removeWidget(ui->waitingLabel); - ui->waitingLabel->setVisible(false); - delete ui->waitingLabel; - ui->waitingLabel = NULL; - - config = new QGCPX4VehicleConfig(); - ui->gridLayout->addWidget(config); -} - -QGCConfigView::~QGCConfigView() -{ - delete ui; -} - -void QGCConfigView::activeUASChanged(UASInterface* uas) -{ - if (mav == uas) - return; - - int type = -1; - if (mav) - type = mav->getAutopilotType(); - - mav = uas; - if (uas && type != uas->getAutopilotType()) { - - if (ui->waitingLabel) { - ui->gridLayout->removeWidget(ui->waitingLabel); - ui->waitingLabel->setVisible(false); - } - - //remove all child widgets since they could contain stale data - //for example, when we switch from one PX4 UAS to another UAS - foreach (QObject* obj, ui->gridLayout->children()) { - QWidget* w = dynamic_cast(obj); - if (w) { - if (obj != ui->waitingLabel) { - ui->gridLayout->removeWidget(w); - delete obj; - } - } - } - - QGCPX4VehicleConfig* px4config = qobject_cast(config); - if (!px4config) { - if (config) - delete config; - config = new QGCPX4VehicleConfig(); - ui->gridLayout->addWidget(config); - } - } - else { - if (ui->waitingLabel) { - //restore waiting label if we no longer have a connection - ui->gridLayout->addWidget(ui->waitingLabel); - ui->waitingLabel->setVisible(true); - } - } - -} diff --git a/src/ui/QGCConfigView.h b/src/ui/QGCConfigView.h deleted file mode 100644 index a1bd340..0000000 --- a/src/ui/QGCConfigView.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QGCCONFIGVIEW_H -#define QGCCONFIGVIEW_H - -#include -#include - -namespace Ui { -class QGCConfigView; -} - -class QGCConfigView : public QWidget -{ - Q_OBJECT - -public: - explicit QGCConfigView(QWidget *parent = 0); - ~QGCConfigView(); - -public slots: - void activeUASChanged(UASInterface* uas); - -private: - Ui::QGCConfigView *ui; - QWidget *config; - UASInterface* mav; - -}; - -#endif // QGCCONFIGVIEW_H diff --git a/src/ui/QGCConfigView.ui b/src/ui/QGCConfigView.ui deleted file mode 100644 index 38ce1ce..0000000 --- a/src/ui/QGCConfigView.ui +++ /dev/null @@ -1,31 +0,0 @@ - - - QGCConfigView - - - - 0 - 0 - 400 - 300 - - - - Form - - - - 0 - - - - - Waiting for connection... - - - - - - - - diff --git a/src/ui/QGCPX4VehicleConfig.cc b/src/ui/QGCPX4VehicleConfig.cc deleted file mode 100644 index c90d9c2..0000000 --- a/src/ui/QGCPX4VehicleConfig.cc +++ /dev/null @@ -1,331 +0,0 @@ -// On Windows (for VS2010) stdint.h contains the limits normally contained in limits.h -// It also needs the __STDC_LIMIT_MACROS macro defined in order to include them (done -// in qgroundcontrol.pri). -#ifdef WIN32 -#include -#else -#include -#endif - -#include -#include -#include -#include - -#include "QGCPX4VehicleConfig.h" - -#include "QGC.h" -#include "QGCToolWidget.h" -#include "UASManager.h" -#include "LinkManager.h" -#include "UASParameterCommsMgr.h" -#include "ui_QGCPX4VehicleConfig.h" -#include "px4_configuration/QGCPX4AirframeConfig.h" -#include "px4_configuration/QGCPX4SensorCalibration.h" -#include "px4_configuration/PX4RCCalibration.h" - -#include "PX4FirmwareUpgrade.h" - -#define WIDGET_INDEX_FIRMWARE 0 -#define WIDGET_INDEX_RC 1 -#define WIDGET_INDEX_SENSOR_CAL 2 -#define WIDGET_INDEX_AIRFRAME_CONFIG 3 -#define WIDGET_INDEX_GENERAL_CONFIG 4 -#define WIDGET_INDEX_ADV_CONFIG 5 - -#define MIN_PWM_VAL 800 -#define MAX_PWM_VAL 2200 - -QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : - QWidget(parent), - mav(NULL), - px4AirframeConfig(NULL), - planeBack(":/files/images/px4/rc/cessna_back.png"), - planeSide(":/files/images/px4/rc/cessna_side.png"), - px4SensorCalibration(NULL), - ui(new Ui::QGCPX4VehicleConfig) -{ - doneLoadingConfig = false; - - setObjectName("QGC_VEHICLECONFIG"); - ui->setupUi(this); - - ui->advancedMenuButton->setEnabled(false); - ui->airframeMenuButton->setEnabled(false); - ui->sensorMenuButton->setEnabled(false); - ui->rcMenuButton->setEnabled(false); - - px4AirframeConfig = new QGCPX4AirframeConfig(this); - ui->airframeLayout->addWidget(px4AirframeConfig); - - px4SensorCalibration = new QGCPX4SensorCalibration(this); - ui->sensorLayout->addWidget(px4SensorCalibration); - - px4RCCalibration = new PX4RCCalibration(this); - ui->rcLayout->addWidget(px4RCCalibration); - - PX4FirmwareUpgrade* firmwareUpgrade = new PX4FirmwareUpgrade(this); - ui->firmwareLayout->addWidget(firmwareUpgrade); - - connect(ui->rcMenuButton,SIGNAL(clicked()), - this,SLOT(rcMenuButtonClicked())); - connect(ui->sensorMenuButton,SIGNAL(clicked()), - this,SLOT(sensorMenuButtonClicked())); - connect(ui->flightModeMenuButton, SIGNAL(clicked()), - this, SLOT(flightModeMenuButtonClicked())); - connect(ui->safetyConfigButton, SIGNAL(clicked()), - this, SLOT(safetyConfigMenuButtonClicked())); - connect(ui->tuningMenuButton,SIGNAL(clicked()), - this,SLOT(tuningMenuButtonClicked())); - connect(ui->advancedMenuButton,SIGNAL(clicked()), - this,SLOT(advancedMenuButtonClicked())); - connect(ui->airframeMenuButton, SIGNAL(clicked()), - this, SLOT(airframeMenuButtonClicked())); - connect(ui->firmwareMenuButton, SIGNAL(clicked()), - this, SLOT(firmwareMenuButtonClicked())); - - //TODO connect buttons here to save/clear actions? - UASInterface* tmpMav = UASManager::instance()->getActiveUAS(); - if (tmpMav) { - ui->pendingCommitsWidget->initWithUAS(tmpMav); - ui->pendingCommitsWidget->update(); - setActiveUAS(tmpMav); - } - - connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), - this, SLOT(setActiveUAS(UASInterface*))); - - firmwareMenuButtonClicked(); -} - -QGCPX4VehicleConfig::~QGCPX4VehicleConfig() -{ - delete ui; -} - -void QGCPX4VehicleConfig::rcMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->rcTab); - ui->tabTitleLabel->setText(tr("Radio Calibration")); -} - -void QGCPX4VehicleConfig::sensorMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->sensorTab); - ui->tabTitleLabel->setText(tr("Sensor Calibration")); -} - -void QGCPX4VehicleConfig::tuningMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->tuningTab); - ui->tabTitleLabel->setText(tr("Controller Tuning")); -} - -void QGCPX4VehicleConfig::flightModeMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->flightModeTab); - ui->tabTitleLabel->setText(tr("Flight Mode Configuration")); -} - -void QGCPX4VehicleConfig::safetyConfigMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->safetyConfigTab); - ui->tabTitleLabel->setText(tr("Safety Feature Configuration")); -} - -void QGCPX4VehicleConfig::advancedMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->advancedTab); - ui->tabTitleLabel->setText(tr("Advanced Configuration Options")); -} - -void QGCPX4VehicleConfig::airframeMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->airframeTab); - ui->tabTitleLabel->setText(tr("Airframe Configuration")); -} - -void QGCPX4VehicleConfig::firmwareMenuButtonClicked() -{ - ui->stackedWidget->setCurrentWidget(ui->firmwareTab); - ui->tabTitleLabel->setText(tr("Firmware Upgrade")); -} - -void QGCPX4VehicleConfig::menuButtonClicked() -{ - QPushButton *button = qobject_cast(sender()); - if (!button) - { - return; - } - if (buttonToWidgetMap.contains(button)) - { - ui->stackedWidget->setCurrentWidget(buttonToWidgetMap[button]); - } - -} - -void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) -{ - // Hide items if NULL and abort - if (!active) { - return; - } - - - // Do nothing if UAS is already visible - if (mav == active) - return; - - if (mav) - { - - //TODO use paramCommsMgr instead - disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, - SLOT(parameterChanged(int,int,QString,QVariant))); - - foreach(QWidget* child, ui->airframeLayout->findChildren()) - { - child->deleteLater(); - } - - // And then delete any custom tabs - foreach(QWidget* child, additionalTabs) { - child->deleteLater(); - } - additionalTabs.clear(); - - toolWidgets.clear(); - paramToWidgetMap.clear(); - libParamToWidgetMap.clear(); - systemTypeToParamMap.clear(); - toolToBoxMap.clear(); - paramTooltips.clear(); - } - - // Connect new system - mav = active; - - paramMgr = mav->getParamManager(); - - ui->pendingCommitsWidget->setUAS(mav); - ui->paramTreeWidget->setUAS(mav); - - //TODO eliminate the separate RC_TYPE call - mav->requestParameter(0, "RC_TYPE"); - - // Connect new system - connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, - SLOT(parameterChanged(int,int,QString,QVariant))); - - - if (systemTypeToParamMap.contains(mav->getSystemTypeName())) { - paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()]; - } - else { - //Indication that we have no meta data for this system type. - qDebug() << "No parameters defined for system type:" << mav->getSystemTypeName(); - paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()]; - } - - if (!paramTooltips.isEmpty()) { - mav->getParamManager()->setParamDescriptions(paramTooltips); - } - - qDebug() << "CALIBRATION!! System Type Name:" << mav->getSystemTypeName(); - - updateStatus(QString("Reading from system %1").arg(mav->getUASName())); - - // Since a system is now connected, enable the VehicleConfig UI. - // Enable buttons - - bool px4Firmware = mav->getAutopilotType() == MAV_AUTOPILOT_PX4; - ui->airframeMenuButton->setEnabled(px4Firmware); - ui->sensorMenuButton->setEnabled(px4Firmware); - ui->rcMenuButton->setEnabled(px4Firmware); - ui->advancedMenuButton->setEnabled(true); -} - -void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value) -{ - if (!doneLoadingConfig) { - //We do not want to attempt to generate any UI elements until loading of the config file is complete. - //We should re-request params later if needed, that is not implemented yet. - return; - } - - if (paramToWidgetMap.contains(parameterName)) { - //Main group of parameters of the selected airframe - paramToWidgetMap.value(parameterName)->setParameterValue(uas,component,parameterName,value); - if (toolToBoxMap.contains(paramToWidgetMap.value(parameterName))) { - toolToBoxMap[paramToWidgetMap.value(parameterName)]->show(); - } - else { - qCritical() << "Widget with no box, possible memory corruption for param:" << parameterName; - } - } - else if (libParamToWidgetMap.contains(parameterName)) { - //All the library parameters - libParamToWidgetMap.value(parameterName)->setParameterValue(uas,component,parameterName,value); - if (toolToBoxMap.contains(libParamToWidgetMap.value(parameterName))) { - toolToBoxMap[libParamToWidgetMap.value(parameterName)]->show(); - } - else { - qCritical() << "Widget with no box, possible memory corruption for param:" << parameterName; - } - } - else { - //Param recieved that we have no metadata for. Search to see if it belongs in a - //group with some other params - //bool found = false; - for (int i=0;iobjectName())) { - //It should be grouped with this one, add it. - toolWidgets[i]->addParam(uas,component,parameterName,value); - libParamToWidgetMap.insert(parameterName,toolWidgets[i]); - //found = true; - break; - } - } -// if (!found) { -// //New param type, create a QGroupBox for it. -// QWidget* parent = ui->advanceColumnContents; - -// // Create the tool, attaching it to the QGroupBox -// QGCToolWidget *tool = new QGCToolWidget("", parent); -// QString tooltitle = parameterName; -// if (parameterName.split("_").size() > 1) { -// tooltitle = parameterName.split("_")[0] + "_"; -// } -// tool->setTitle(tooltitle); -// tool->setObjectName(tooltitle); -// //tool->setSettings(set); -// libParamToWidgetMap.insert(parameterName,tool); -// toolWidgets.append(tool); -// tool->addParam(uas, component, parameterName, value); -// QGroupBox *box = new QGroupBox(parent); -// box->setTitle(tool->objectName()); -// box->setLayout(new QVBoxLayout(box)); -// box->layout()->addWidget(tool); - -// libParamToWidgetMap.insert(parameterName,tool); -// toolWidgets.append(tool); -// ui->advancedColumnLayout->addWidget(box); - -// toolToBoxMap[tool] = box; -// } - } - -} - -void QGCPX4VehicleConfig::updateStatus(const QString& str) -{ - ui->advancedStatusLabel->setText(str); - ui->advancedStatusLabel->setStyleSheet(""); -} - -void QGCPX4VehicleConfig::updateError(const QString& str) -{ - ui->advancedStatusLabel->setText(str); - ui->advancedStatusLabel->setStyleSheet(QString("QLabel { margin: 0px 2px; font: 14px; color: %1; background-color: %2; }").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.name())); -} diff --git a/src/ui/QGCPX4VehicleConfig.h b/src/ui/QGCPX4VehicleConfig.h deleted file mode 100644 index 1009cab..0000000 --- a/src/ui/QGCPX4VehicleConfig.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef QGCPX4VehicleConfig_H -#define QGCPX4VehicleConfig_H - -#include -#include -#include -#include -#include -#include -#include - -#include "QGCToolWidget.h" -#include "UASInterface.h" -#include "px4_configuration/QGCPX4AirframeConfig.h" - -class UASParameterCommsMgr; -class QGCPX4SensorCalibration; -class PX4RCCalibration; - -namespace Ui { -class QGCPX4VehicleConfig; -} - -class QGCPX4VehicleConfig : public QWidget -{ - Q_OBJECT - -public: - explicit QGCPX4VehicleConfig(QWidget *parent = 0); - ~QGCPX4VehicleConfig(); - - enum RC_MODE { - RC_MODE_1 = 1, - RC_MODE_2 = 2, - RC_MODE_3 = 3, - RC_MODE_4 = 4, - RC_MODE_NONE = 5 - }; - -public slots: - void rcMenuButtonClicked(); - void sensorMenuButtonClicked(); - void tuningMenuButtonClicked(); - void flightModeMenuButtonClicked(); - void safetyConfigMenuButtonClicked(); - void advancedMenuButtonClicked(); - void airframeMenuButtonClicked(); - void firmwareMenuButtonClicked(); - - /** Set the MAV currently being calibrated */ - void setActiveUAS(UASInterface* active); - -protected slots: - void menuButtonClicked(); - /** Parameter changed onboard */ - void parameterChanged(int uas, int component, QString parameterName, QVariant value); - void updateStatus(const QString& str); - void updateError(const QString& str); - -protected: - - bool doneLoadingConfig; - UASInterface* mav; ///< The current MAV - QGCUASParamManagerInterface* paramMgr; ///< params mgr for the mav - QList toolWidgets; ///< Configurable widgets - QMap toolWidgetsByName; ///< - - QMap paramToWidgetMap; ///< Holds the current active MAV's parameter widgets. - QList additionalTabs; ///< Stores additional tabs loaded for this vehicle/autopilot configuration. Used for cleaning up. - QMap libParamToWidgetMap; ///< Holds the library parameter widgets - QMap > systemTypeToParamMap; ///< Holds all loaded MAV specific parameter widgets, for every MAV. - QMap toolToBoxMap; ///< Easy method of figuring out which QGroupBox is tied to which ToolWidget. - QMap paramTooltips; ///< Tooltips for the ? button next to a parameter. - - QGCPX4AirframeConfig* px4AirframeConfig; - QPixmap planeBack; - QPixmap planeSide; - QGCPX4SensorCalibration* px4SensorCalibration; - PX4RCCalibration* px4RCCalibration; - QGraphicsScene scene; - QPushButton* skipActionButton; - -private: - Ui::QGCPX4VehicleConfig *ui; - QMap buttonToWidgetMap; -signals: - void visibilityChanged(bool visible); -}; - -#endif // QGCPX4VehicleConfig_H diff --git a/src/ui/QGCPX4VehicleConfig.ui b/src/ui/QGCPX4VehicleConfig.ui deleted file mode 100644 index e49b37c..0000000 --- a/src/ui/QGCPX4VehicleConfig.ui +++ /dev/null @@ -1,563 +0,0 @@ - - - QGCPX4VehicleConfig - - - - 0 - 0 - 1293 - 1132 - - - - - 0 - 0 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 16 - 75 - true - - - - - - - - - - - - - 1 - - - - - - - - 16 - 75 - true - - - - - - - - 16 - 75 - true - - - - - - - - - - - 16 - 75 - true - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'.Helvetica Neue DeskInterface'; font-size:16pt; font-weight:600; font-style:normal;"> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI';"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt; font-weight:400;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt; font-weight:400;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt; font-weight:400;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt; font-weight:400;"><br /></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.Lucida Grande UI'; font-size:24pt; font-weight:400;">Coming Soon</span></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.Lucida Grande UI'; font-size:24pt; font-weight:400;">(Use Advanced Config instead)</span></p></body></html> - - - - - - - - - - - - - - 3 - 1 - - - - Onboard Configuration - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - - - 0 - 0 - 16 - 16 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - true - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - 2 - 0 - - - - - 329 - 0 - - - - Changes Pending - - - - - - -1 - - - - - - 0 - 0 - - - - true - - - - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - - Status - - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'.Helvetica Neue DeskInterface'; font-size:13pt; font-weight:400; font-style:normal;"> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI';"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.Lucida Grande UI'; font-size:24pt;">Coming Soon</span></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.Lucida Grande UI'; font-size:24pt;">(Use Radio Calibration instead)</span></p></body></html> - - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'.Helvetica Neue DeskInterface'; font-size:13pt; font-weight:400; font-style:normal;"> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI';"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Lucida Grande UI'; font-size:24pt;"><br /></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.Lucida Grande UI'; font-size:24pt;">Coming Soon</span></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.Lucida Grande UI'; font-size:24pt;">(Use Advanced Config instead)</span></p></body></html> - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QLayout::SetMinAndMaxSize - - - 12 - - - 12 - - - 24 - - - 12 - - - - - Firmware -Upgrade - - - - :/files/images/px4/menu/firmware_upgrade.png:/files/images/px4/menu/firmware_upgrade.png - - - - 60 - 60 - - - - - - - - Airframe -Config - - - - :/files/images/px4/menu/plane.png:/files/images/px4/menu/plane.png - - - - 60 - 60 - - - - - - - - - 100 - 75 - - - - Sensor -Calibration - - - - :/files/images/px4/menu/sensors.png:/files/images/px4/menu/sensors.png - - - - 60 - 60 - - - - - - - - - 100 - 75 - - - - - 16777215 - 16777215 - - - - Radio -Calibration - - - - :/files/images/px4/menu/remote.png:/files/images/px4/menu/remote.png - - - - 60 - 60 - - - - - - - - - 100 - 75 - - - - Flight Mode -Config - - - - :/files/images/px4/menu/toggle_switch.png:/files/images/px4/menu/toggle_switch.png - - - - 60 - 60 - - - - - - - - - 100 - 75 - - - - Safety -Config - - - - :/files/images/px4/menu/cogwheels.png:/files/images/px4/menu/cogwheels.png - - - - 60 - 60 - - - - - - - - - 100 - 75 - - - - Controller -Tuning - - - - :/files/images/px4/menu/cogwheels.png:/files/images/px4/menu/cogwheels.png - - - - 60 - 60 - - - - - - - - - 100 - 75 - - - - Advanced -Config - - - - :/files/images/px4/menu/cogwheels.png:/files/images/px4/menu/cogwheels.png - - - - 60 - 60 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - QGCPendingParamWidget - QWidget -
ui/QGCPendingParamWidget.h
- 1 -
- - QGCParamWidget - QWidget -
ui/QGCParamWidget.h
- 1 -
-
- - - - -
diff --git a/src/ui/px4_configuration/QGCPX4SensorCalibration.cc b/src/ui/px4_configuration/QGCPX4SensorCalibration.cc deleted file mode 100644 index dc7c0bd..0000000 --- a/src/ui/px4_configuration/QGCPX4SensorCalibration.cc +++ /dev/null @@ -1,507 +0,0 @@ -#include "QGCPX4SensorCalibration.h" -#include "ui_QGCPX4SensorCalibration.h" -#include -#include -#include -#include - -QGCPX4SensorCalibration::QGCPX4SensorCalibration(QWidget *parent) : - QWidget(parent), - activeUAS(NULL), - clearAction(new QAction(tr("Clear Text"), this)), - ui(new Ui::QGCPX4SensorCalibration) -{ - ui->setupUi(this); - connect(clearAction, SIGNAL(triggered()), ui->textView, SLOT(clear())); - - connect(ui->gyroButton, SIGNAL(clicked()), this, SLOT(gyroButtonClicked())); - connect(ui->magButton, SIGNAL(clicked()), this, SLOT(magButtonClicked())); - connect(ui->accelButton, SIGNAL(clicked()), this, SLOT(accelButtonClicked())); - connect(ui->diffPressureButton, SIGNAL(clicked()), this, SLOT(diffPressureButtonClicked())); - - connect(ui->logCheckBox, SIGNAL(clicked(bool)), ui->textView, SLOT(setVisible(bool))); - ui->logCheckBox->setChecked(false); - ui->textView->setVisible(false); - - ui->gyroButton->setEnabled(false); - ui->magButton->setEnabled(false); - ui->accelButton->setEnabled(false); - - ui->autopilotComboBox->setEnabled(false); - ui->magComboBox->setEnabled(false); - - setInstructionImage(":/files/images/px4/calibration/accel_down.png"); - setAutopilotImage(":/files/images/px4/calibration/accel_down.png"); - setGpsImage(":/files/images/px4/calibration/accel_down.png"); - - // Fill combo boxes - ui->autopilotComboBox->addItem(tr("Default Orientation"), 0); - ui->autopilotComboBox->addItem(tr("ROTATION_YAW_45"), 1); - ui->autopilotComboBox->addItem(tr("ROTATION_YAW_90"), 2); - ui->autopilotComboBox->addItem(tr("ROTATION_YAW_135"), 3); - ui->autopilotComboBox->addItem(tr("ROTATION_YAW_180"), 4); - ui->autopilotComboBox->addItem(tr("ROTATION_YAW_225"), 5); - ui->autopilotComboBox->addItem(tr("ROTATION_YAW_270"), 6); - ui->autopilotComboBox->addItem(tr("ROTATION_YAW_315"), 7); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180"), 8); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_YAW_45"), 9); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_YAW_90"), 10); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_YAW_135"), 11); - ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_180"), 12); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_YAW_225"), 13); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_YAW_270"), 14); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_YAW_315"), 15); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90"), 16); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_YAW_45"), 17); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_YAW_90"), 18); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_YAW_135"), 19); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270"), 20); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_YAW_45"), 21); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_YAW_90"), 22); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_YAW_135"), 23); - ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_90"), 24); - ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_270"), 25); - ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_180_YAW_90"), 26); - ui->autopilotComboBox->addItem(tr("ROTATION_PITCH_180_YAW_270"), 27); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_90"), 28); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_PITCH_90"), 29); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_PITCH_90"), 30); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_180"), 31); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_PITCH_180"), 32); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_270"), 33); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_180_PITCH_270"), 34); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_270_PITCH_270"), 35); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_PITCH_180_YAW_90"), 36); - ui->autopilotComboBox->addItem(tr("ROTATION_ROLL_90_YAW_270"), 37); - - ui->magComboBox->addItem(tr("Default Orientation"), 0); - ui->magComboBox->addItem(tr("ROTATION_YAW_45"), 1); - ui->magComboBox->addItem(tr("ROTATION_YAW_90"), 2); - ui->magComboBox->addItem(tr("ROTATION_YAW_135"), 3); - ui->magComboBox->addItem(tr("ROTATION_YAW_180"), 4); - ui->magComboBox->addItem(tr("ROTATION_YAW_225"), 5); - ui->magComboBox->addItem(tr("ROTATION_YAW_270"), 6); - ui->magComboBox->addItem(tr("ROTATION_YAW_315"), 7); - ui->magComboBox->addItem(tr("ROTATION_ROLL_180"), 8); - ui->magComboBox->addItem(tr("ROTATION_ROLL_180_YAW_45"), 9); - ui->magComboBox->addItem(tr("ROTATION_ROLL_180_YAW_90"), 10); - ui->magComboBox->addItem(tr("ROTATION_ROLL_180_YAW_135"), 11); - ui->magComboBox->addItem(tr("ROTATION_PITCH_180"), 12); - ui->magComboBox->addItem(tr("ROTATION_ROLL_180_YAW_225"), 13); - ui->magComboBox->addItem(tr("ROTATION_ROLL_180_YAW_270"), 14); - ui->magComboBox->addItem(tr("ROTATION_ROLL_180_YAW_315"), 15); - ui->magComboBox->addItem(tr("ROTATION_ROLL_90"), 16); - ui->magComboBox->addItem(tr("ROTATION_ROLL_90_YAW_45"), 17); - ui->magComboBox->addItem(tr("ROTATION_ROLL_90_YAW_90"), 18); - ui->magComboBox->addItem(tr("ROTATION_ROLL_90_YAW_135"), 19); - ui->magComboBox->addItem(tr("ROTATION_ROLL_270"), 20); - ui->magComboBox->addItem(tr("ROTATION_ROLL_270_YAW_45"), 21); - ui->magComboBox->addItem(tr("ROTATION_ROLL_270_YAW_90"), 22); - ui->magComboBox->addItem(tr("ROTATION_ROLL_270_YAW_135"), 23); - ui->magComboBox->addItem(tr("ROTATION_PITCH_90"), 24); - ui->magComboBox->addItem(tr("ROTATION_PITCH_270"), 25); - - setObjectName("PX4_SENSOR_CALIBRATION"); - - setStyleSheet("QScrollArea { border: 0px; } QPlainTextEdit { border: 0px }"); - - setActiveUAS(UASManager::instance()->getActiveUAS()); - connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); - ui->progressBar->setValue(0); - - connect(ui->autopilotComboBox, SIGNAL(activated(int)), this, SLOT(setAutopilotOrientation(int))); - connect(ui->magComboBox, SIGNAL(activated(int)), this, SLOT(setGpsOrientation(int))); - - updateIcons(); -} - -QGCPX4SensorCalibration::~QGCPX4SensorCalibration() -{ - delete ui; -} - -void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString parameterName, QVariant value) -{ - Q_UNUSED(uas); - Q_UNUSED(component); - - int index = (int)value.toFloat(); - - if (parameterName.contains("SENS_BOARD_ROT")) - { - ui->autopilotComboBox->setCurrentIndex(index); - setAutopilotImage(index); - ui->autopilotComboBox->setEnabled(true); - } - - if (parameterName.contains("SENS_EXT_MAG_ROT")) - { - ui->magComboBox->setCurrentIndex(index); - setGpsImage(index); - ui->magComboBox->setEnabled(true); - } - - // Check mag calibration naively - if (parameterName.contains("SENS_MAG_XOFF") || parameterName.contains("CAL_MAG0_ID")) { - float offset = value.toFloat(); - if (offset < 0.000001f && offset > -0.000001f) { - // Must be zero, not good - setMagCalibrated(false); - } else { - setMagCalibrated(true); - } - } - - // Check gyro calibration naively - if (parameterName.contains("SENS_GYRO_XOFF") || parameterName.contains("CAL_GYRO0_ID")) { - float offset = value.toFloat(); - if (offset < 0.000001f && offset > -0.000001f) { - // Must be zero, not good - setGyroCalibrated(false); - } else { - setGyroCalibrated(true); - } - } - - // Check accel calibration naively - if (parameterName.contains("SENS_ACC_XOFF") || parameterName.contains("CAL_ACC0_ID")) { - float offset = value.toFloat(); - if (offset < 0.000001f && offset > -0.000001f) { - // Must be zero, not good - setAccelCalibrated(false); - } else { - setAccelCalibrated(true); - } - } - - // Check differential pressure calibration naively - if (parameterName.contains("SENS_DPRES_OFF")) { - float offset = value.toFloat(); - if (offset < 0.000001f && offset > -0.000001f) { - // Must be zero, not good - setDiffPressureCalibrated(false); - } else { - setDiffPressureCalibrated(true); - } - } -} - -void QGCPX4SensorCalibration::setMagCalibrated(bool calibrated) -{ - if (calibrated) { - ui->magLabel->setText(tr("MAG CALIBRATED")); - ui->magLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #20AA20;" - "}"); - } else { - ui->magLabel->setText(tr("MAG UNCALIBRATED")); - ui->magLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #FF0037;" - "}"); - } -} - -void QGCPX4SensorCalibration::setGyroCalibrated(bool calibrated) -{ - if (calibrated) { - ui->gyroLabel->setText(tr("GYRO CALIBRATED")); - ui->gyroLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #20AA20;" - "}"); - } else { - ui->gyroLabel->setText(tr("GYRO UNCALIBRATED")); - ui->gyroLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #FF0037;" - "}"); - } -} - -void QGCPX4SensorCalibration::setAccelCalibrated(bool calibrated) -{ - if (calibrated) { - ui->accelLabel->setText(tr("ACCEL CALIBRATED")); - ui->accelLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #20AA20;" - "}"); - } else { - ui->accelLabel->setText(tr("ACCEL UNCALIBRATED")); - ui->accelLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #FF0037;" - "}"); - } -} - -void QGCPX4SensorCalibration::setDiffPressureCalibrated(bool calibrated) -{ - if (calibrated) { - ui->diffPressureLabel->setText(tr("DIFF. PRESSURE CALIBRATED")); - ui->diffPressureLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #20AA20;" - "}"); - } else { - ui->diffPressureLabel->setText(tr("DIFF. PRESSURE UNCALIBRATED")); - ui->diffPressureLabel->setStyleSheet("QLabel { color: #FFFFFF;" - "background-color: #FF0037;" - "}"); - } -} - -void QGCPX4SensorCalibration::setInstructionImage(const QString &path) -{ - instructionIcon.load(path); - - int w = ui->iconLabel->width(); - int h = ui->iconLabel->height(); - - ui->iconLabel->setPixmap(instructionIcon.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation)); -} - -void QGCPX4SensorCalibration::setAutopilotImage(int index) -{ - Q_UNUSED(index); - // FIXME: This was referencing a non-existent png. Need to figure out what this was trying to do. - //setAutopilotImage(QString(":/files/images/px4/calibration/pixhawk_%1.png").arg(index, 2, 10, QChar('0'))); -} - -void QGCPX4SensorCalibration::setGpsImage(int index) -{ - setGpsImage(QString(":/files/images/px4/calibration/3dr_gps/gps_%1.png").arg(index, 2, 10, QChar('0'))); -} - -void QGCPX4SensorCalibration::setAutopilotOrientation(int index) -{ - if (activeUAS) { - activeUAS->getParamManager()->setPendingParam(0, "SENS_BOARD_ROT", (int)index); - activeUAS->getParamManager()->sendPendingParameters(true); - } -} - -void QGCPX4SensorCalibration::setGpsOrientation(int index) -{ - if (activeUAS) { - activeUAS->getParamManager()->setPendingParam(0, "SENS_EXT_MAG_ROT", (int)index); - activeUAS->getParamManager()->sendPendingParameters(true); - } -} - -void QGCPX4SensorCalibration::setAutopilotImage(const QString &path) -{ - if (autopilotIcon.load(path)) { - int w = ui->autopilotLabel->width(); - int h = ui->autopilotLabel->height(); - - ui->autopilotLabel->setPixmap(autopilotIcon.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - } else { - qDebug() << "AutoPilot Icon image did not load" << path; - } -} - -void QGCPX4SensorCalibration::setGpsImage(const QString &path) -{ - if (gpsIcon.load(path)) { - int w = ui->gpsLabel->width(); - int h = ui->gpsLabel->height(); - - ui->gpsLabel->setPixmap(gpsIcon.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - } else { - qDebug() << "GPS Icon image did not load" << path; - } -} - -void QGCPX4SensorCalibration::updateIcons() -{ - int w = ui->iconLabel->width(); - int h = ui->iconLabel->height(); - ui->iconLabel->setPixmap(instructionIcon.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - - int wa = ui->autopilotLabel->width(); - int ha = ui->autopilotLabel->height(); - ui->autopilotLabel->setPixmap(autopilotIcon.scaled(wa, ha, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - - int wg = ui->gpsLabel->width(); - int hg = ui->gpsLabel->height(); - ui->gpsLabel->setPixmap(gpsIcon.scaled(wg, hg, Qt::KeepAspectRatio, Qt::SmoothTransformation)); -} - -void QGCPX4SensorCalibration::resizeEvent(QResizeEvent* event) -{ - updateIcons(); - QWidget::resizeEvent(event); -} - -void QGCPX4SensorCalibration::setActiveUAS(UASInterface* uas) -{ - if (!uas) - return; - - if (activeUAS) { - disconnect(activeUAS, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); - disconnect(activeUAS, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, SLOT(parameterChanged(int,int,QString,QVariant))); - ui->textView->clear(); - } - - ui->gyroButton->setEnabled(true); - ui->magButton->setEnabled(true); - ui->accelButton->setEnabled(true); - - connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); - connect(uas, SIGNAL(parameterChanged(int,int,QString,QVariant)), this, SLOT(parameterChanged(int,int,QString,QVariant))); - connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(updateSystemSpecs(int))); - activeUAS = uas; - - updateSystemSpecs(uas->getUASID()); - - // If the parameters are ready, we aren't going to get paramterChanged signals. So re-request them in order to make the UI work. - if (uas->getParamManager()->parametersReady()) { - _requestAllSensorParameters(); - } -} - -void QGCPX4SensorCalibration::updateSystemSpecs(int id) -{ - Q_UNUSED(id); - - if (activeUAS->isRotaryWing()) { - // Users are confused by the config button - ui->diffPressureButton->hide(); - ui->diffPressureLabel->hide(); - } else { - ui->diffPressureButton->show(); - ui->diffPressureLabel->show(); - } -} - -void QGCPX4SensorCalibration::handleTextMessage(int uasid, int compId, int severity, QString text) -{ - Q_UNUSED(uasid); - Q_UNUSED(compId); - Q_UNUSED(severity); - - if (text.startsWith("[cmd]") || - text.startsWith("[mavlink pm]")) - return; - - if (text.contains("progress <")) { - QString percent = text.split("<").last().split(">").first(); - bool ok; - int p = percent.toInt(&ok); - if (ok) - ui->progressBar->setValue(p); - return; - } - - ui->instructionLabel->setText(QString("%1").arg(text)); - - if (text.startsWith("Hold still, starting to measure ")) { - QString axis = text.section(" ", -2, -2); - setInstructionImage(QString(":/files/images/px4/calibration/accel_%1.png").arg(axis)); - } - - if (text.startsWith("pending: ")) { - QString axis = text.section(" ", 1, 1); - setInstructionImage(QString(":/files/images/px4/calibration/accel_%1.png").arg(axis)); - } - - if (text == "rotate in a figure 8 around all axis" /* support for old typo */ - || text == "rotate in a figure 8 around all axes" /* current version */) { - setInstructionImage(":/files/images/px4/calibration/mag_calibration_figure8.png"); - } - - if (text.endsWith(" calibration: done") || text.endsWith(" calibration: failed")) { - // XXX use a confirmation image or something - setInstructionImage(":/files/images/px4/calibration/accel_down.png"); - if (text.endsWith(" calibration: done")) { - ui->progressBar->setValue(100); - } else { - ui->progressBar->setValue(0); - } - - if (activeUAS) { - _requestAllSensorParameters(); - } - } - - if (text.endsWith(" calibration: started")) { - setInstructionImage(":/files/images/px4/calibration/accel_down.png"); - } - - // XXX color messages according to severity - - QPlainTextEdit *msgWidget = ui->textView; - - //turn off updates while we're appending content to avoid breaking the autoscroll behavior - msgWidget->setUpdatesEnabled(false); - QScrollBar *scroller = msgWidget->verticalScrollBar(); - - msgWidget->appendHtml(QString("%4").arg(text)); - - // Ensure text area scrolls correctly - scroller->setValue(scroller->maximum()); - msgWidget->setUpdatesEnabled(true); -} - -void QGCPX4SensorCalibration::gyroButtonClicked() -{ - setInstructionImage(":/files/images/px4/calibration/accel_down.png"); - activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); - ui->progressBar->setValue(0); -} - -void QGCPX4SensorCalibration::magButtonClicked() -{ - setInstructionImage(":/files/images/px4/calibration/accel_down.png"); - activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); - ui->progressBar->setValue(0); -} - -void QGCPX4SensorCalibration::accelButtonClicked() -{ - setInstructionImage(":/files/images/px4/calibration/accel_down.png"); - activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0); - ui->progressBar->setValue(0); -} - -void QGCPX4SensorCalibration::diffPressureButtonClicked() -{ - setInstructionImage(":/files/images/px4/calibration/accel_down.png"); - activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0); - ui->progressBar->setValue(0); -} - -void QGCPX4SensorCalibration::contextMenuEvent(QContextMenuEvent* event) -{ - QMenu menu(this); - menu.addAction(clearAction); - menu.exec(event->globalPos()); -} - -void QGCPX4SensorCalibration::_requestAllSensorParameters(void) -{ - static const char* rgSensorsCalParamsV1[] = { - "SENS_ACC_XOFF", "SENS_ACC_YOFF", "SENS_ACC_ZOFF", "SENS_ACC_XSCALE", "SENS_ACC_YSCALE", "SENS_ACC_ZSCALE", - "SENS_GYRO_XOFF", "SENS_GYRO_YOFF", "SENS_GYRO_ZOFF", "SENS_GYRO_XSCALE", "SENS_GYRO_YSCALE", "SENS_GYRO_ZSCALE", - "SENS_MAG_XOFF", "SENS_MAG_YOFF", "SENS_MAG_ZOFF", "SENS_MAG_XSCALE", "SENS_MAG_YSCALE", "SENS_MAG_ZSCALE", "SENS_EXT_MAG_ROT", - "SENS_DPRES_OFF", "SENS_DPRES_ANA", - "SENS_BOARD_ROT", - NULL }; - - static const char* rgSensorsCalParamsV2[] = { - "CAL_ACC0_ID", "CAL_ACC0_XOFF", "CAL_ACC0_YOFF", "CAL_ACC0_ZOFF", "CAL_ACC0_XSCALE", "CAL_ACC0_YSCALE", "CAL_ACC0_ZSCALE", - "CAL_GYRO0_ID", "CAL_GYRO0_XOFF", "CAL_GYRO0_YOFF", "CAL_GYRO0_ZOFF", "CAL_GYRO0_XSCALE", "CAL_GYRO0_YSCALE", "CAL_GYRO0_ZSCALE", - "CAL_MAG0_ID", "CAL_MAG0_XOFF", "CAL_MAG0_YOFF", "CAL_MAG0_ZOFF", "CAL_MAG0_XSCALE", "CAL_MAG0_YSCALE", "CAL_MAG0_ZSCALE", "SENS_EXT_MAG_ROT", - "SENS_DPRES_OFF", "SENS_DPRES_ANA", - "SENS_BOARD_ROT", - NULL }; - - Q_ASSERT(activeUAS); - QGCUASParamManagerInterface* paramMgr = activeUAS->getParamManager(); - - // Temp hack for parameter mapping - bool paramsV1 = paramMgr->getComponentForParam("SENS_MAG_XOFF").count(); - static const char** prgParamList = paramsV1 ? rgSensorsCalParamsV1 : rgSensorsCalParamsV2; - - for (size_t i=0; prgParamList[i] != NULL; i++) { - qDebug() << "Requesting" << prgParamList[i]; - activeUAS->requestParameter(0, prgParamList[i]); - } -} \ No newline at end of file diff --git a/src/ui/px4_configuration/QGCPX4SensorCalibration.h b/src/ui/px4_configuration/QGCPX4SensorCalibration.h deleted file mode 100644 index 8c84e62..0000000 --- a/src/ui/px4_configuration/QGCPX4SensorCalibration.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef QGCPX4SENSORCALIBRATION_H -#define QGCPX4SENSORCALIBRATION_H - -#include -#include -#include - -namespace Ui { -class QGCPX4SensorCalibration; -} - -class QGCPX4SensorCalibration : public QWidget -{ - Q_OBJECT - -public: - explicit QGCPX4SensorCalibration(QWidget *parent = 0); - ~QGCPX4SensorCalibration(); - -public slots: - /** - * @brief Set currently active UAS - * @param uas the current active UAS - */ - void setActiveUAS(UASInterface* uas); - - /** - * @brief Handle text message from current active UAS - * @param uasid - * @param componentid - * @param severity - * @param text - */ - void handleTextMessage(int uasid, int componentid, int severity, QString text); - - /** - * @brief Update system specs / properties - * @param id the UID of the aircraft - */ - void updateSystemSpecs(int id); - - void gyroButtonClicked(); - void magButtonClicked(); - void accelButtonClicked(); - void diffPressureButtonClicked(); - - /** - * @brief Hand context menu event - * @param event - */ - virtual void contextMenuEvent(QContextMenuEvent* event); - - void setAutopilotOrientation(int index); - void setGpsOrientation(int index); - void parameterChanged(int uas, int component, QString parameterName, QVariant value); - -protected slots: - - void setInstructionImage(const QString &path); - - void setAutopilotImage(const QString &path); - - void setGpsImage(const int index); - - void setAutopilotImage(const int index); - - void setGpsImage(const QString &path); - -protected: - UASInterface* activeUAS; - QAction* clearAction; - QPixmap instructionIcon; - QPixmap autopilotIcon; - QPixmap gpsIcon; - - virtual void resizeEvent(QResizeEvent* event); - - void setMagCalibrated(bool calibrated); - void setGyroCalibrated(bool calibrated); - void setAccelCalibrated(bool calibrated); - void setDiffPressureCalibrated(bool calibrated); - - void updateIcons(); - -private: - void _requestAllSensorParameters(void); - - Ui::QGCPX4SensorCalibration *ui; - -}; - -#endif // QGCPX4SENSORCALIBRATION_H diff --git a/src/ui/px4_configuration/QGCPX4SensorCalibration.ui b/src/ui/px4_configuration/QGCPX4SensorCalibration.ui deleted file mode 100644 index a99e1db..0000000 --- a/src/ui/px4_configuration/QGCPX4SensorCalibration.ui +++ /dev/null @@ -1,275 +0,0 @@ - - - QGCPX4SensorCalibration - - - - 0 - 0 - 659 - 636 - - - - Form - - - QPushButton#magButton { - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #73D95D, stop: 1 #18A154); - border-radius: 8px; - min-height: 25px; - max-height: 30px; - min-width: 60px; - max-width: 140px; - margin: 5px; - border: 2px solid #465158; -} - -QPushButton#gyroButton, QPushButton#accelButton, QPushButton#diffPressureButton { - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D3795D, stop: 1 #A81154); - border-radius: 8px; - min-height: 25px; - max-height: 30px; - min-width: 60px; - max-width: 140px; - margin: 5px; - border: 2px solid #465158; -} - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Autopilot Orientation - - - - - - - 0 - 250 - - - - - - - - - - - - - - - - - Magnetometer Orientation - - - - - - - 150 - 120 - - - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 498 - 5 - - - - - - - - - - - - - - - 24 - - - - - - - false - - - - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Qt::AlignCenter - - - - - - - Gyroscope - - - - :/files/images/px4/calibration/arrows.png:/files/images/px4/calibration/arrows.png - - - - - - - Magnetometer - - - - :/files/images/px4/calibration/arrows.png:/files/images/px4/calibration/arrows.png - - - - - - - Accelerometer - - - - :/files/images/px4/calibration/arrows.png:/files/images/px4/calibration/arrows.png - - - - - - - Diff. pressure - - - - :/files/images/px4/calibration/arrows.png:/files/images/px4/calibration/arrows.png - - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Qt::AlignCenter - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Log - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - -