diff --git a/ground/src/plugins/config/ahrs.ui b/ground/src/plugins/config/ahrs.ui
index d765e0cf7..fa0ef4c2d 100644
--- a/ground/src/plugins/config/ahrs.ui
+++ b/ground/src/plugins/config/ahrs.ui
@@ -17,9 +17,9 @@
10
- 10
- 411
- 321
+ 9
+ 641
+ 461
@@ -28,73 +28,247 @@
QFrame::Raised
-
+
10
10
- 361
- 151
+ 341
+ 141
-
- <!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:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This panel will be where you setup your AHRS. For now it is just a placeholder, please be patient!</p></body></html>
+
+ Qt::ScrollBarAlwaysOff
+
+
+ Qt::ScrollBarAlwaysOff
-
+
- 190
- 280
+ 390
+ 90
+ 301
+ 17
+
+
+
+ Instructions......................
+
+
+
+
+
+ 400
+ 30
93
27
-
- Send to OpenPilot but don't write in SD.
-Beware of not locking yourself out!
+
+ Start
+
+
+
+
+
+ 540
+ 30
+ 93
+ 27
+
+
+
+ Cancel
+
+
+
+
+
+ 127
+ 150
+ 411
+ 20
+
+
+
+ Qt::Horizontal
+
+
+
+
+
+ 10
+ 180
+ 111
+ 17
+
+
+
+ AHRS Algorithm:
+
+
+
+
+
+ 140
+ 170
+ 131
+ 31
+
+
+
+
+
+
+ 130
+ 220
+ 411
+ 20
+
+
+
+ Qt::Horizontal
+
+
+
+
+
+ 10
+ 260
+ 191
+ 151
+
+
+
+
+
+
+ 40
+ 240
+ 121
+ 17
+
+
+
+ Calibration #2
+
+
+
+
+
+ 230
+ 270
+ 93
+ 27
+
+
+
+ PushButton
+
+
+
+
+
+ 230
+ 320
+ 93
+ 27
+
+
+
+ PushButton
+
+
+
+
+
+ 230
+ 370
+ 93
+ 27
+
+
+
+ PushButton
+
+
+
+
+
+ 360
+ 250
+ 271
+ 161
+
+
+
+
+
+
+ 290
+ 180
+ 201
+ 22
+
+
+
+ Save Home Location to SD
+
+
+
+
+
+ 430
+ 430
+ 93
+ 27
+
Save to RAM
-
+
- 80
- 280
+ 540
+ 430
93
27
-
- Retrieve settings from OpenPilot
-
-
- Get Current
-
-
-
-
-
- 300
- 280
- 93
- 27
-
-
-
- Applies and Saves all settings to SD.
-Beware of not locking yourself out!
-
Save to SD
+
+
+
+ 320
+ 430
+ 93
+ 27
+
+
+
+ Request
+
+
+
+
+
+ 120
+ 410
+ 411
+ 20
+
+
+
+ Qt::Horizontal
+
+
diff --git a/ground/src/plugins/config/configahrswidget.cpp b/ground/src/plugins/config/configahrswidget.cpp
index 2179da846..c6d3769e3 100644
--- a/ground/src/plugins/config/configahrswidget.cpp
+++ b/ground/src/plugins/config/configahrswidget.cpp
@@ -27,6 +27,7 @@
#include "configahrswidget.h"
#include
+#include
#include
#include
#include
@@ -41,6 +42,70 @@ ConfigAHRSWidget::ConfigAHRSWidget(QWidget *parent) : ConfigTaskWidget(parent)
m_ahrs->setupUi(this);
+ m_ahrs->ahrsBargraph->setScene(new QGraphicsScene(this));
+
+ QSvgRenderer *renderer = new QSvgRenderer();
+ ahrsbargraph = new QGraphicsSvgItem();
+ renderer->load(QString(":/configgadget/images/ahrs-calib.svg"));
+ ahrsbargraph->setSharedRenderer(renderer);
+ ahrsbargraph->setElementId("background");
+ ahrsbargraph->setObjectName("background");
+ m_ahrs->ahrsBargraph->scene()->addItem(ahrsbargraph);
+ m_ahrs->ahrsBargraph->setSceneRect(ahrsbargraph->boundingRect());
+
+ // Initialize the 9 bargraph values:
+
+ QMatrix lineMatrix = renderer->matrixForElement("accel_x");
+ qreal startX = lineMatrix.mapRect(renderer->boundsOnElement("accel_x")).x();
+ qreal startY = lineMatrix.mapRect(renderer->boundsOnElement("accel_x")).y();
+ // Then once we have the initial location, we can put it
+ // into a QGraphicsSvgItem which we will display at the same
+ // place: we do this so that the heading scale can be clipped to
+ // the compass dial region.
+ accel_x = new QGraphicsSvgItem();
+ accel_x->setSharedRenderer(renderer);
+ accel_x->setElementId("accel_x");
+ m_ahrs->ahrsBargraph->scene()->addItem(accel_x);
+ QTransform matrix;
+ matrix.translate(startX,startY);
+ accel_x->setTransform(matrix,false);
+
+ lineMatrix = renderer->matrixForElement("accel_y");
+ startX = lineMatrix.mapRect(renderer->boundsOnElement("accel_y")).x();
+ startY = lineMatrix.mapRect(renderer->boundsOnElement("accel_y")).y();
+ accel_y = new QGraphicsSvgItem();
+ accel_y->setSharedRenderer(renderer);
+ accel_y->setElementId("accel_y");
+ m_ahrs->ahrsBargraph->scene()->addItem(accel_y);
+ matrix.reset();
+ matrix.translate(startX,startY);
+ accel_y->setTransform(matrix,false);
+
+ lineMatrix = renderer->matrixForElement("accel_z");
+ startX = lineMatrix.mapRect(renderer->boundsOnElement("accel_z")).x();
+ startY = lineMatrix.mapRect(renderer->boundsOnElement("accel_z")).y();
+ accel_z = new QGraphicsSvgItem();
+ accel_z->setSharedRenderer(renderer);
+ accel_z->setElementId("accel_z");
+ m_ahrs->ahrsBargraph->scene()->addItem(accel_z);
+ matrix.reset();
+ matrix.translate(startX,startY);
+ accel_z->setTransform(matrix,false);
+
+
+
+ // Fill the dropdown menus:
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ UAVObjectManager *objManager = pm->getObject();
+
+ UAVObject *obj = dynamic_cast(objManager->getObject(QString("AHRSSettings")));
+ UAVObjectField *field = obj->getField(QString("Algorithm"));
+ m_ahrs->algorithm->addItems(field->getOptions());
+
+
+ // Connect the signals
+ connect(m_ahrs->ahrsCalibStart, SIGNAL(clicked()), this, SLOT(launchAHRSCalibration()));
+
}
ConfigAHRSWidget::~ConfigAHRSWidget()
@@ -49,4 +114,42 @@ ConfigAHRSWidget::~ConfigAHRSWidget()
}
+void ConfigAHRSWidget::showEvent(QShowEvent *event)
+{
+ m_ahrs->ahrsBargraph->fitInView(ahrsbargraph, Qt::KeepAspectRatio);
+}
+
+/**
+ Launches the AHRS sensors calibration
+ */
+void ConfigAHRSWidget::launchAHRSCalibration()
+{
+ m_ahrs->calibInstructions->setText("Calibration launched...");
+ m_ahrs->ahrsCalibStart->setEnabled(false);
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ UAVObjectManager *objManager = pm->getObject();
+
+ UAVObject *obj = dynamic_cast(objManager->getObject(QString("AHRSCalibration")));
+ UAVObjectField *field = obj->getField(QString("measure_var"));
+ field->setValue("TRUE");
+ obj->updated();
+
+ QTimer *waitabit = new QTimer();
+ waitabit->setSingleShot(true);
+ waitabit->start(15000);
+ connect(waitabit, SIGNAL(timeout()), this, SLOT(calibPhase2()));
+
+}
+
+
+void ConfigAHRSWidget::calibPhase2()
+{
+ m_ahrs->calibInstructions->setText("Confirming settings...");
+
+ // Now update size of all the graphs in log scale
+ // 'log(1/val)'
+
+ m_ahrs->ahrsCalibStart->setEnabled(true);
+}
+
diff --git a/ground/src/plugins/config/configahrswidget.h b/ground/src/plugins/config/configahrswidget.h
index 47ef0bd8d..e991af9e7 100644
--- a/ground/src/plugins/config/configahrswidget.h
+++ b/ground/src/plugins/config/configahrswidget.h
@@ -33,6 +33,8 @@
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
#include
+#include
+#include
#include
@@ -46,8 +48,18 @@ public:
private:
Ui_AHRSWidget *m_ahrs;
+ QGraphicsSvgItem *ahrsbargraph;
+ QGraphicsSvgItem *accel_x;
+ QGraphicsSvgItem *accel_y;
+ QGraphicsSvgItem *accel_z;
private slots:
+ void launchAHRSCalibration();
+ void calibPhase2();
+
+protected:
+ void showEvent(QShowEvent *event);
+
};
diff --git a/ground/src/plugins/config/configgadget.qrc b/ground/src/plugins/config/configgadget.qrc
index 86aa1cbd8..1188d1c01 100644
--- a/ground/src/plugins/config/configgadget.qrc
+++ b/ground/src/plugins/config/configgadget.qrc
@@ -3,5 +3,6 @@
images/XBee.svg
images/Airframe.png
images/Servo.png
+ images/ahrs-calib.svg
diff --git a/ground/src/plugins/config/images/ahrs-calib.svg b/ground/src/plugins/config/images/ahrs-calib.svg
new file mode 100644
index 000000000..965027b5e
--- /dev/null
+++ b/ground/src/plugins/config/images/ahrs-calib.svg
@@ -0,0 +1,632 @@
+
+
+
+