1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-38 Further updates to config plugin, please test!

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1416 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-08-26 14:23:40 +00:00 committed by edouard
parent 828363948d
commit 08f2c5fd82
12 changed files with 161 additions and 70 deletions

View File

@ -74,7 +74,7 @@ Tip: lower is better!</string>
<property name="toolTip">
<string>Press to start a calibration procedure.
Takes about 10 seconds.</string>
Takes about 30 seconds max.</string>
</property>
<property name="text">
<string>Start</string>
@ -214,7 +214,7 @@ Takes about 10 seconds.</string>
<string>Save Home Location to SD</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<widget class="QPushButton" name="ahrsSettingsSaveRAM">
<property name="geometry">
<rect>
<x>430</x>
@ -227,7 +227,7 @@ Takes about 10 seconds.</string>
<string>Save to RAM</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_7">
<widget class="QPushButton" name="ahrsSettingsSaveSD">
<property name="geometry">
<rect>
<x>540</x>
@ -240,7 +240,7 @@ Takes about 10 seconds.</string>
<string>Save to SD</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_8">
<widget class="QPushButton" name="ahrsSettingsRequest">
<property name="geometry">
<rect>
<x>320</x>
@ -291,10 +291,35 @@ Takes about 10 seconds.</string>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>Save is only enabled once the calibration is done (&quot;Start&quot; on the left)</string>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
<widget class="QProgressBar" name="calibProgress">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>390</x>
<y>120</y>
<width>201</width>
<height>23</height>
</rect>
</property>
<property name="maximum">
<number>15</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</widget>
</widget>
<resources/>

View File

@ -2,6 +2,7 @@ TEMPLATE = lib
TARGET = Config
QT += svg
include(../../openpilotgcsplugin.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
OTHER_FILES += Config.pluginspec

View File

@ -165,10 +165,7 @@ ConfigAHRSWidget::ConfigAHRSWidget(QWidget *parent) : ConfigTaskWidget(parent)
// Fill the dropdown menus:
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVObject *obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("AHRSSettings")));
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSSettings")));
UAVObjectField *field = obj->getField(QString("Algorithm"));
m_ahrs->algorithm->addItems(field->getOptions());
@ -176,6 +173,10 @@ ConfigAHRSWidget::ConfigAHRSWidget(QWidget *parent) : ConfigTaskWidget(parent)
// Connect the signals
connect(m_ahrs->ahrsCalibStart, SIGNAL(clicked()), this, SLOT(launchAHRSCalibration()));
connect(m_ahrs->ahrsCalibSave, SIGNAL(clicked()), this, SLOT(saveAHRSCalibration()));
connect(m_ahrs->ahrsSettingsRequest, SIGNAL(clicked()), this, SLOT(ahrsSettingsRequest()));
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(ahrsSettingsRequest()));
}
@ -198,35 +199,44 @@ void ConfigAHRSWidget::launchAHRSCalibration()
m_ahrs->calibInstructions->setText("Calibration launched...");
m_ahrs->ahrsCalibStart->setEnabled(false);
m_ahrs->ahrsCalibSave->setEnabled(false);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVObject *obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("AHRSCalibration")));
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->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()));
QTimer::singleShot(15000, this, SLOT(calibPhase2()));
phaseCounter = 0;
progressBarIndex = 0;
connect(&progressBarTimer, SIGNAL(timeout()), this, SLOT(incrementProgress()));
progressBarTimer.start(1000);
}
/**
Increment progress bar
*/
void ConfigAHRSWidget::incrementProgress()
{
m_ahrs->calibProgress->setValue(progressBarIndex++);
if (progressBarIndex > m_ahrs->calibProgress->maximum()) {
progressBarTimer.stop();
progressBarIndex = 0;
}
}
/**
Callback after 15 seconds once calibration is done on the board.
Callback once calibration is done on the board.
Currently we don't have a way to tell if calibration is finished, so we
have to use a timer.
calibPhase2 is also connected to the AHRSCalibration object update signal.
*/
void ConfigAHRSWidget::calibPhase2()
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVObject *obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("AHRSCalibration")));
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSCalibration")));
// This is a bit weird, but it is because we are expecting an update from the
// OP board with the correct calibration values, and those only arrive on the object update
@ -242,58 +252,87 @@ void ConfigAHRSWidget::calibPhase2()
case 1: // this is where we end up with the update just above
phaseCounter++;
break;
case 2: // This is the update with the right values
disconnect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(calibPhase2()));
// Now update size of all the graphs
// I have not found a way to do this elegantly...
UAVObjectField *field = obj->getField(QString("accel_var"));
// The expected range is from 1E-6 to 1E-1
double steps = 6; // 6 bars on the graph
float accel_x_var = -1/steps*(1+steps+log10(field->getValue(0).toFloat()));
accel_x->setTransform(QTransform::fromScale(1,accel_x_var),false);
float accel_y_var = -1/steps*(1+steps+log10(field->getValue(1).toFloat()));
accel_y->setTransform(QTransform::fromScale(1,accel_y_var),false);
float accel_z_var = -1/steps*(1+steps+log10(field->getValue(2).toFloat()));
accel_z->setTransform(QTransform::fromScale(1,accel_z_var),false);
case 2: { // This is the update with the right values (coming from the board)
disconnect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(calibPhase2()));
// Now update size of all the graphs
drawVariancesGraph();
field = obj->getField(QString("gyro_var"));
float gyro_x_var = -1/steps*(1+steps+log10(field->getValue(0).toFloat()));
gyro_x->setTransform(QTransform::fromScale(1,gyro_x_var),false);
float gyro_y_var = -1/steps*(1+steps+log10(field->getValue(1).toFloat()));
gyro_y->setTransform(QTransform::fromScale(1,gyro_y_var),false);
float gyro_z_var = -1/steps*(1+steps+log10(field->getValue(2).toFloat()));
gyro_z->setTransform(QTransform::fromScale(1,gyro_z_var),false);
field = obj->getField(QString("mag_var"));
float mag_x_var = -1/steps*(1+steps+log10(field->getValue(0).toFloat()));
mag_x->setTransform(QTransform::fromScale(1,mag_x_var),false);
float mag_y_var = -1/steps*(1+steps+log10(field->getValue(1).toFloat()));
mag_y->setTransform(QTransform::fromScale(1,mag_y_var),false);
float mag_z_var = -1/steps*(1+steps+log10(field->getValue(2).toFloat()));
mag_z->setTransform(QTransform::fromScale(1,mag_z_var),false);
// Now wait 15 more seconds before re-enabling the "Save" button
QTimer::singleShot(15000, this, SLOT(calibPhase2()));
m_ahrs->calibInstructions->setText(QString("Please review the results..."));
progressBarIndex = 0;
phaseCounter++;
}
break;
case 3: // This step re-enables the "Save" button
m_ahrs->calibInstructions->setText(QString("Press \"Save\" if OK."));
m_ahrs->ahrsCalibStart->setEnabled(true);
m_ahrs->ahrsCalibSave->setEnabled(true);
break;
}
}
/**
Saves the AHRS sensors calibration
Saves the AHRS sensors calibration (to RAM only)
*/
void ConfigAHRSWidget::saveAHRSCalibration()
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVObject *obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("AHRSCalibration")));
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSCalibration")));
UAVObjectField *field = obj->getField(QString("measure_var"));
field->setValue("FALSE");
obj->updated();
}
/**
Draws the sensor variances bargraph
*/
void ConfigAHRSWidget::drawVariancesGraph()
{
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSCalibration")));
// Now update size of all the graphs
// I have not found a way to do this elegantly...
UAVObjectField *field = obj->getField(QString("accel_var"));
// The expected range is from 1E-6 to 1E-1
double steps = 6; // 6 bars on the graph
float accel_x_var = -1/steps*(1+steps+log10(field->getValue(0).toFloat()));
accel_x->setTransform(QTransform::fromScale(1,accel_x_var),false);
float accel_y_var = -1/steps*(1+steps+log10(field->getValue(1).toFloat()));
accel_y->setTransform(QTransform::fromScale(1,accel_y_var),false);
float accel_z_var = -1/steps*(1+steps+log10(field->getValue(2).toFloat()));
accel_z->setTransform(QTransform::fromScale(1,accel_z_var),false);
field = obj->getField(QString("gyro_var"));
float gyro_x_var = -1/steps*(1+steps+log10(field->getValue(0).toFloat()));
gyro_x->setTransform(QTransform::fromScale(1,gyro_x_var),false);
float gyro_y_var = -1/steps*(1+steps+log10(field->getValue(1).toFloat()));
gyro_y->setTransform(QTransform::fromScale(1,gyro_y_var),false);
float gyro_z_var = -1/steps*(1+steps+log10(field->getValue(2).toFloat()));
gyro_z->setTransform(QTransform::fromScale(1,gyro_z_var),false);
field = obj->getField(QString("mag_var"));
float mag_x_var = -1/steps*(1+steps+log10(field->getValue(0).toFloat()));
mag_x->setTransform(QTransform::fromScale(1,mag_x_var),false);
float mag_y_var = -1/steps*(1+steps+log10(field->getValue(1).toFloat()));
mag_y->setTransform(QTransform::fromScale(1,mag_y_var),false);
float mag_z_var = -1/steps*(1+steps+log10(field->getValue(2).toFloat()));
mag_z->setTransform(QTransform::fromScale(1,mag_z_var),false);
}
/**
Request current settings from the AHRS
*/
void ConfigAHRSWidget::ahrsSettingsRequest()
{
UAVObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AHRSSettings")));
obj->requestUpdate();
UAVObjectField *field = obj->getField(QString("Algorithm"));
m_ahrs->algorithm->setCurrentIndex(m_ahrs->algorithm->findText(field->getValue().toString()));
drawVariancesGraph();
}

View File

@ -36,6 +36,7 @@
#include <QtSvg/QSvgRenderer>
#include <QtSvg/QGraphicsSvgItem>
#include <QList>
#include <QTimer>
class ConfigAHRSWidget: public ConfigTaskWidget
@ -47,6 +48,7 @@ public:
~ConfigAHRSWidget();
private:
void drawVariancesGraph();
Ui_AHRSWidget *m_ahrs;
QGraphicsSvgItem *ahrsbargraph;
QGraphicsSvgItem *accel_x;
@ -60,12 +62,18 @@ private:
QGraphicsSvgItem *mag_z;
double maxBarHeight;
int phaseCounter;
int progressBarIndex;
QTimer progressBarTimer;
const static double maxVarValue = 0.1;
private slots:
void launchAHRSCalibration();
void saveAHRSCalibration();
void calibPhase2();
void incrementProgress();
void ahrsSettingsRequest();
void ahrsSettingsSaveRAM();
void ahrsSettingsSaveSD();
protected:
void showEvent(QShowEvent *event);

View File

@ -54,6 +54,8 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p
connect(m_aircraft->saveAircraftToRAM, SIGNAL(clicked()), this, SLOT(sendAircraftUpdate()));
connect(m_aircraft->getAircraftCurrent, SIGNAL(clicked()), this, SLOT(requestAircraftUpdate()));
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestAircraftUpdate()));
}
ConfigAirframeWidget::~ConfigAirframeWidget()

View File

@ -49,15 +49,19 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(ftw);
setLayout(layout);
QWidget *qwd = new ConfigServoWidget();
QWidget *qwd = new ConfigServoWidget(this);
ftw->insertTab(0, qwd,QIcon(":/configgadget/images/Servo.png"),QString("RC Input/Output"));
qwd = new ConfigAirframeWidget();
qwd = new ConfigAirframeWidget(this);
ftw->insertTab(1, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft"));
qwd = new ConfigTelemetryWidget();
qwd = new ConfigTelemetryWidget(this);
ftw->insertTab(2,qwd,QIcon(":/configgadget/images/XBee.svg"), QString("Telemetry"));
qwd = new ConfigAHRSWidget();
qwd = new ConfigAHRSWidget(this);
ftw->insertTab(3,qwd,QIcon(":/core/images/plugin.png"),QString("AHRS"));
// Listen to autopilot connection events
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
TelemetryManager* telMngr = pm->getObject<TelemetryManager>();
connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
}
@ -72,4 +76,7 @@ void ConfigGadgetWidget::resizeEvent(QResizeEvent *event)
QWidget::resizeEvent(event);
}
void ConfigGadgetWidget::onAutopilotConnect() {
emit autopilotConnected();
}

View File

@ -27,6 +27,7 @@
#ifndef CONFIGGADGETWIDGET_H
#define CONFIGGADGETWIDGET_H
#include "uavtalk/telemetrymanager.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
@ -43,6 +44,12 @@ public:
ConfigGadgetWidget(QWidget *parent = 0);
~ConfigGadgetWidget();
public slots:
void onAutopilotConnect();
signals:
void autopilotConnected();
protected:
void resizeEvent(QResizeEvent * event);

View File

@ -135,6 +135,10 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
connect(m_config->ch6OutSlider, SIGNAL(valueChanged(int)), this, SLOT(sendChannelTest(int)));
connect(m_config->ch7OutSlider, SIGNAL(valueChanged(int)), this, SLOT(sendChannelTest(int)));
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestRCInputUpdate()));
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestRCOutputUpdate()));
firstUpdate = true;
}

View File

@ -57,6 +57,11 @@ void ConfigTaskWidget::updateObjectPersistance(ObjectPersistence::OperationOptio
}
}
UAVObjectManager* ConfigTaskWidget::getObjectManager() {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
return pm->getObject<UAVObjectManager>();
}
/**
@}
@}

View File

@ -43,6 +43,7 @@ public:
ConfigTaskWidget(QWidget *parent = 0);
~ConfigTaskWidget();
void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj);
UAVObjectManager* getObjectManager();
};

View File

@ -53,6 +53,8 @@ ConfigTelemetryWidget::ConfigTelemetryWidget(QWidget *parent) : ConfigTaskWidget
connect(m_telemetry->saveTelemetryToRAM, SIGNAL(clicked()), this, SLOT(sendTelemetryUpdate()));
connect(m_telemetry->getTelemetryCurrent, SIGNAL(clicked()), this, SLOT(requestTelemetryUpdate()));
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestTelemetryUpdate()));
}
ConfigTelemetryWidget::~ConfigTelemetryWidget()

View File

@ -286,8 +286,8 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="334.4393"
inkscape:zoom="2.8"
inkscape:cx="574.08216"
inkscape:cy="117.47189"
inkscape:document-units="px"
inkscape:current-layer="background"
@ -311,7 +311,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
<dc:creator>
<cc:Agent>
<dc:title>Edouard Lafargue</dc:title>
@ -330,16 +330,6 @@
id="background"
inkscape:label="#g8543"
transform="matrix(0,-0.72391486,1,0,-8.719326,711.5901)">
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:9.4025631;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect6737"
width="683.69995"
height="354.43222"
x="187.97757"
y="-563.36774"
transform="matrix(0,1,-1,0,0,0)"
rx="3.1741481"
ry="6.0569253" />
<rect
style="fill:#453e3e;fill-opacity:1;stroke:#000000;stroke-width:4.70128155;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2936"

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB