Commit 1ca53ab0 authored by Lorenz Meier's avatar Lorenz Meier

Re-did sensor calibration, WIP

parent d5603052
...@@ -292,7 +292,8 @@ FORMS += src/ui/MainWindow.ui \ ...@@ -292,7 +292,8 @@ FORMS += src/ui/MainWindow.ui \
src/ui/configuration/SerialSettingsDialog.ui \ src/ui/configuration/SerialSettingsDialog.ui \
src/ui/configuration/ApmFirmwareConfig.ui \ src/ui/configuration/ApmFirmwareConfig.ui \
src/ui/px4_configuration/QGCPX4AirframeConfig.ui \ src/ui/px4_configuration/QGCPX4AirframeConfig.ui \
src/ui/px4_configuration/QGCPX4MulticopterConfig.ui src/ui/px4_configuration/QGCPX4MulticopterConfig.ui \
src/ui/px4_configuration/QGCPX4SensorCalibration.ui
INCLUDEPATH += src \ INCLUDEPATH += src \
src/ui \ src/ui \
...@@ -496,7 +497,8 @@ HEADERS += src/MG.h \ ...@@ -496,7 +497,8 @@ HEADERS += src/MG.h \
src/ui/QGCPendingParamWidget.h \ src/ui/QGCPendingParamWidget.h \
src/ui/px4_configuration/QGCPX4AirframeConfig.h \ src/ui/px4_configuration/QGCPX4AirframeConfig.h \
src/ui/QGCBaseParamWidget.h \ src/ui/QGCBaseParamWidget.h \
src/ui/px4_configuration/QGCPX4MulticopterConfig.h src/ui/px4_configuration/QGCPX4MulticopterConfig.h \
src/ui/px4_configuration/QGCPX4SensorCalibration.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
...@@ -717,7 +719,8 @@ SOURCES += src/main.cc \ ...@@ -717,7 +719,8 @@ SOURCES += src/main.cc \
src/ui/QGCPendingParamWidget.cc \ src/ui/QGCPendingParamWidget.cc \
src/ui/px4_configuration/QGCPX4AirframeConfig.cc \ src/ui/px4_configuration/QGCPX4AirframeConfig.cc \
src/ui/QGCBaseParamWidget.cc \ src/ui/QGCBaseParamWidget.cc \
src/ui/px4_configuration/QGCPX4MulticopterConfig.cc src/ui/px4_configuration/QGCPX4MulticopterConfig.cc \
src/ui/px4_configuration/QGCPX4SensorCalibration.cc
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
...@@ -167,6 +167,14 @@ ...@@ -167,6 +167,14 @@
<file>files/images/px4/airframes/plane_ert.png</file> <file>files/images/px4/airframes/plane_ert.png</file>
<file>files/images/px4/airframes/plane_aert.png</file> <file>files/images/px4/airframes/plane_aert.png</file>
<file>files/images/px4/airframes/quad_h.png</file> <file>files/images/px4/airframes/quad_h.png</file>
<file>files/images/px4/calibration/arrows.png</file>
<file>files/images/px4/calibration/accel_x+.png</file>
<file>files/images/px4/calibration/accel_x-.png</file>
<file>files/images/px4/calibration/accel_y-.png</file>
<file>files/images/px4/calibration/accel_z+.png</file>
<file>files/images/px4/calibration/accel_z-.png</file>
<file>files/images/px4/calibration/accel_y+.png</file>
<file>files/images/px4/calibration/mag_calibration_figure8.png</file>
</qresource> </qresource>
<qresource prefix="/general"> <qresource prefix="/general">
<file alias="vera.ttf">files/styles/Vera.ttf</file> <file alias="vera.ttf">files/styles/Vera.ttf</file>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "UASParameterCommsMgr.h" #include "UASParameterCommsMgr.h"
#include "ui_QGCPX4VehicleConfig.h" #include "ui_QGCPX4VehicleConfig.h"
#include "px4_configuration/QGCPX4AirframeConfig.h" #include "px4_configuration/QGCPX4AirframeConfig.h"
#include "px4_configuration/QGCPX4SensorCalibration.h"
#include <dialog_bare.h> #include <dialog_bare.h>
#define WIDGET_INDEX_FIRMWARE 0 #define WIDGET_INDEX_FIRMWARE 0
...@@ -54,6 +55,7 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ...@@ -54,6 +55,7 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
calibrationEnabled(false), calibrationEnabled(false),
configEnabled(false), configEnabled(false),
px4AirframeConfig(NULL), px4AirframeConfig(NULL),
px4SensorCalibration(NULL),
#ifdef QUPGRADE_SUPPORT #ifdef QUPGRADE_SUPPORT
firmwareDialog(NULL), firmwareDialog(NULL),
#endif #endif
...@@ -90,6 +92,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) : ...@@ -90,6 +92,9 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
px4AirframeConfig = new QGCPX4AirframeConfig(this); px4AirframeConfig = new QGCPX4AirframeConfig(this);
ui->airframeLayout->addWidget(px4AirframeConfig); ui->airframeLayout->addWidget(px4AirframeConfig);
px4SensorCalibration = new QGCPX4SensorCalibration(this);
ui->sensorLayout->addWidget(px4SensorCalibration);
#ifdef QUPGRADE_SUPPORT #ifdef QUPGRADE_SUPPORT
firmwareDialog = new DialogBare(this); firmwareDialog = new DialogBare(this);
ui->firmwareLayout->addWidget(firmwareDialog); ui->firmwareLayout->addWidget(firmwareDialog);
...@@ -635,44 +640,6 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary) ...@@ -635,44 +640,6 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
} }
} }
} }
// Load general calibration for autopilot
//TODO: Handle this more gracefully, maybe have it scan the directory for multiple calibration entries?
tool = new QGCToolWidget("", ui->sensorContents);
tool->addUAS(mav);
if (tool->loadSettings(autopilotdir.absolutePath() + "/general/calibration/calibration.qgw", false))
{
toolWidgets.append(tool);
QGroupBox *box = new QGroupBox(ui->sensorContents);
box->setTitle(tool->objectName());
box->setLayout(new QVBoxLayout(box));
box->layout()->addWidget(tool);
ui->sensorLayout->addWidget(box);
} else {
delete tool;
}
// Load vehicle-specific autopilot configuration
tool = new QGCToolWidget("", ui->sensorContents);
tool->addUAS(mav);
if (tool->loadSettings(autopilotdir.absolutePath() + "/" + mav->getSystemTypeName().toLower() + "/calibration/calibration.qgw", false))
{
toolWidgets.append(tool);
QGroupBox *box = new QGroupBox(ui->sensorContents);
box->setTitle(tool->objectName());
box->setLayout(new QVBoxLayout(box));
box->layout()->addWidget(tool);
ui->sensorLayout->addWidget(box);
} else {
delete tool;
}
// //description.txt
// QFile sensortipsfile(autopilotdir.absolutePath() + "/general/calibration/description.txt");
// sensortipsfile.open(QIODevice::ReadOnly);
//// ui->sensorTips->setHtml(sensortipsfile.readAll());
// sensortipsfile.close();
} }
void QGCPX4VehicleConfig::menuButtonClicked() void QGCPX4VehicleConfig::menuButtonClicked()
{ {
...@@ -1056,7 +1023,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active) ...@@ -1056,7 +1023,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
foreach(QWidget* child, ui->advanceColumnContents->findChildren<QWidget*>()) { foreach(QWidget* child, ui->advanceColumnContents->findChildren<QWidget*>()) {
child->deleteLater(); child->deleteLater();
} }
foreach(QWidget* child, ui->sensorContents->findChildren<QWidget*>()) { foreach(QWidget* child, ui->sensorLayout->findChildren<QWidget*>()) {
child->deleteLater(); child->deleteLater();
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
class UASParameterCommsMgr; class UASParameterCommsMgr;
class DialogBare; class DialogBare;
class QGCPX4SensorCalibration;
namespace Ui { namespace Ui {
class QGCPX4VehicleConfig; class QGCPX4VehicleConfig;
...@@ -322,6 +323,7 @@ protected: ...@@ -322,6 +323,7 @@ protected:
QGCPX4AirframeConfig* px4AirframeConfig; QGCPX4AirframeConfig* px4AirframeConfig;
DialogBare* firmwareDialog; DialogBare* firmwareDialog;
QGCPX4SensorCalibration* px4SensorCalibration;
QMessageBox msgBox; QMessageBox msgBox;
QPushButton* skipActionButton; QPushButton* skipActionButton;
......
...@@ -154,7 +154,7 @@ Config</string> ...@@ -154,7 +154,7 @@ Config</string>
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>5</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="firmwareTab"> <widget class="QWidget" name="firmwareTab">
<layout class="QVBoxLayout" name="firmwareLayout"> <layout class="QVBoxLayout" name="firmwareLayout">
...@@ -918,33 +918,7 @@ Config</string> ...@@ -918,33 +918,7 @@ Config</string>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="sensorLayout"/>
<item>
<widget class="QGCMessageView" name="widget" native="true"/>
</item>
<item>
<widget class="QScrollArea" name="scrollArea_3">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="sensorContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>39</width>
<height>26</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QVBoxLayout" name="sensorLayout"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget> </widget>
<widget class="QWidget" name="airframeTab"> <widget class="QWidget" name="airframeTab">
<layout class="QHBoxLayout" name="airframeLayout"/> <layout class="QHBoxLayout" name="airframeLayout"/>
...@@ -1020,8 +994,8 @@ Config</string> ...@@ -1020,8 +994,8 @@ Config</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>16</width> <width>98</width>
<height>16</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
...@@ -1057,8 +1031,8 @@ Config</string> ...@@ -1057,8 +1031,8 @@ Config</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>16</width> <width>98</width>
<height>16</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
...@@ -1272,12 +1246,6 @@ Config</string> ...@@ -1272,12 +1246,6 @@ Config</string>
<header>ui/QGCPendingParamWidget.h</header> <header>ui/QGCPendingParamWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>QGCMessageView</class>
<extends>QWidget</extends>
<header location="global">QGCMessageView.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>QGCParamWidget</class> <class>QGCParamWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
......
#include "QGCPX4SensorCalibration.h"
#include "ui_QGCPX4SensorCalibration.h"
#include <UASManager.h>
#include <QMenu>
#include <QScrollBar>
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()));
setInstructionImage("./files/images/px4/calibration/accel_z-.png");
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*)));
}
QGCPX4SensorCalibration::~QGCPX4SensorCalibration()
{
delete ui;
}
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));
}
void QGCPX4SensorCalibration::resizeEvent(QResizeEvent* event)
{
int w = ui->iconLabel->width();
int h = ui->iconLabel->height();
ui->iconLabel->setPixmap(instructionIcon.scaled(w, h, Qt::KeepAspectRatio));
QWidget::resizeEvent(event);
}
void QGCPX4SensorCalibration::setActiveUAS(UASInterface* uas)
{
if (!uas)
return;
if (activeUAS) {
disconnect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString)));
ui->textView->clear();
}
connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString)));
activeUAS = uas;
}
void QGCPX4SensorCalibration::handleTextMessage(int uasid, int compId, int severity, QString text)
{
// 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();
UASInterface *uas = UASManager::instance()->getUASForId(uasid);
QString uasName(uas->getUASName());
QString colorName(uas->getColor().name());
//change styling based on severity
if (160 == severity ) { //TODO where is the constant for "critical" severity?
//GAudioOutput::instance()->say(text.toLower());
msgWidget->appendHtml(QString("<p style=\"color:#DC143C;background-color:#FFFACD;font-size:large;font-weight:bold\">[%1:%2] %3</p>").arg(uasName).arg(compId).arg(text));
}
else {
msgWidget->appendHtml(QString("<p style=\"color:%1;font-size:smaller\">[%2:%3] %4</p>").arg(colorName).arg(uasName).arg(compId).arg(text));
}
// Ensure text area scrolls correctly
scroller->setValue(scroller->maximum());
msgWidget->setUpdatesEnabled(true);
}
void QGCPX4SensorCalibration::contextMenuEvent(QContextMenuEvent* event)
{
QMenu menu(this);
menu.addAction(clearAction);
menu.exec(event->globalPos());
}
#ifndef QGCPX4SENSORCALIBRATION_H
#define QGCPX4SENSORCALIBRATION_H
#include <QWidget>
#include <UASInterface.h>
#include <QAction>
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 Hand context menu event
* @param event
*/
virtual void contextMenuEvent(QContextMenuEvent* event);
void setInstructionImage(const QString &path);
protected:
UASInterface* activeUAS;
QAction* clearAction;
QPixmap instructionIcon;
virtual void resizeEvent(QResizeEvent* event);
private:
Ui::QGCPX4SensorCalibration *ui;
};
#endif // QGCPX4SENSORCALIBRATION_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCPX4SensorCalibration</class>
<widget class="QWidget" name="QGCPX4SensorCalibration">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">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 {
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;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="1,20,3,2,1,1" columnstretch="30,15,5">
<item row="0" column="0">
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>Magnetometer Calibration</string>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="2" colspan="2">
<widget class="QPlainTextEdit" name="textView"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="instructionLabel">
<property name="text">
<string>To calibrate the system, execute the three calibration steps below.</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>498</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="3">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="magButton">
<property name="text">
<string>Magnetometer</string>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/px4/calibration/arrows.png</normaloff>:/files/images/px4/calibration/arrows.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="gyroButton">
<property name="text">
<string>Gyroscope</string>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/px4/calibration/arrows.png</normaloff>:/files/images/px4/calibration/arrows.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="accelButton">
<property name="text">
<string>Accelerometer</string>
</property>
<property name="icon">
<iconset resource="../../../qgroundcontrol.qrc">
<normaloff>:/files/images/px4/calibration/arrows.png</normaloff>:/files/images/px4/calibration/arrows.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="../../../qgroundcontrol.qrc"/>
</resources>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment