From 0af3d26981633346ed2115d45de26b308f3a3399 Mon Sep 17 00:00:00 2001 From: edouard Date: Tue, 7 Sep 2010 12:26:33 +0000 Subject: [PATCH] OP-38 Ground/Config gadget: AHRS indoor mode works, as well as Home Location saving. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1554 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/config/ahrs.ui | 123 +++++++++++------- .../src/plugins/config/configahrswidget.cpp | 69 ++++++++-- ground/src/plugins/config/configahrswidget.h | 8 +- 3 files changed, 146 insertions(+), 54 deletions(-) diff --git a/ground/src/plugins/config/ahrs.ui b/ground/src/plugins/config/ahrs.ui index b25c9a142..eb134d1a6 100644 --- a/ground/src/plugins/config/ahrs.ui +++ b/ground/src/plugins/config/ahrs.ui @@ -75,7 +75,7 @@ Tip: lower is better! - Press to start a calibration procedure, takes 30 seconds max. + Press to start a calibration procedure, about 15 seconds. Hint: run this with engines at cruising speed. @@ -119,7 +119,9 @@ Hint: run this with engines at cruising speed. - Select the sensor integration algorithm here. + Select the sensor integration algorithm here. +"Simple" only uses accelerometer values +"INSGPS" the full featured algorithm integrating all sensors @@ -131,6 +133,9 @@ Hint: run this with engines at cruising speed. 151 + + Nice paper plane, eh? + @@ -157,6 +162,9 @@ Hint: run this with engines at cruising speed. 27 + + Launch a sensor range and bias calibration. + Start @@ -170,62 +178,35 @@ Hint: run this with engines at cruising speed. 121 + + Six Point Calibration instructions + - + false - 320 - 370 + 380 + 361 201 - 22 + 31 + + Saves the Home Location. This is only enabled +if the Home Location is set, i.e. if the GPS fix is +successful. + Save Home Location to SD - - - - 430 - 430 - 93 - 27 - - - - Save settings to the OP board (RAM only). - -This does not save the calibration settings, this is done using the -specific calibration button on top of the screen. - - - Save to RAM - - - - - - 540 - 430 - 93 - 27 - - - - Send settings to OP board, and save to the microSD card. - - - Save to SD - - - 320 + 260 430 93 27 @@ -242,7 +223,7 @@ specific calibration button on top of the screen. 120 - 350 + 340 411 20 @@ -298,6 +279,9 @@ specific calibration button on top of the screen. 27 + + Save settings (only enabled when calibration is running) + Save Position @@ -305,18 +289,69 @@ specific calibration button on top of the screen. - 320 + 380 400 201 22 + + Check this box if you are flying indoors and have no GPS fix. +Only makes sense with the "INSGPS" algorithm. + Indoor flight mode + + + + 390 + 430 + 111 + 21 + + + + Save settings to the OP board (RAM only). + +This does not save the calibration settings, this is done using the +specific calibration button on top of the screen. + + + Save to RAM + + + buttonGroup + + + + + + 520 + 430 + 101 + 21 + + + + Send settings to OP board, and save to the microSD card. + + + Save to SD + + + true + + + buttonGroup + + + + + diff --git a/ground/src/plugins/config/configahrswidget.cpp b/ground/src/plugins/config/configahrswidget.cpp index defccc3ae..4e3a5dcb1 100644 --- a/ground/src/plugins/config/configahrswidget.cpp +++ b/ground/src/plugins/config/configahrswidget.cpp @@ -181,12 +181,20 @@ ConfigAHRSWidget::ConfigAHRSWidget(QWidget *parent) : ConfigTaskWidget(parent) UAVObjectField *field = obj->getField(QString("Algorithm")); m_ahrs->algorithm->addItems(field->getOptions()); + // Register for Home Location state changes + obj = dynamic_cast(getObjectManager()->getObject(QString("HomeLocation"))); + connect(obj, SIGNAL(objectUpdated(UAVObject*)), this , SLOT(enableHomeLocSave(UAVObject*))); // Connect the signals connect(m_ahrs->ahrsCalibStart, SIGNAL(clicked()), this, SLOT(launchAHRSCalibration())); connect(m_ahrs->ahrsSettingsRequest, SIGNAL(clicked()), this, SLOT(ahrsSettingsRequest())); + connect(m_ahrs->algorithm, SIGNAL(currentIndexChanged(int)), this, SLOT(ahrsSettingsSave())); + connect(m_ahrs->indoorFlight, SIGNAL(stateChanged(int)), this, SLOT(homeLocationSave())); + connect(m_ahrs->homeLocation, SIGNAL(clicked()), this, SLOT(homeLocationSaveSD())); + /* connect(m_ahrs->ahrsSettingsSaveRAM, SIGNAL(clicked()), this, SLOT(ahrsSettingsSaveRAM())); connect(m_ahrs->ahrsSettingsSaveSD, SIGNAL(clicked()), this, SLOT(ahrsSettingsSaveSD())); + */ connect(m_ahrs->sixPointsStart, SIGNAL(clicked()), this, SLOT(sixPointCalibrationMode())); connect(m_ahrs->sixPointsSave, SIGNAL(clicked()), this, SLOT(savePositionData())); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(ahrsSettingsRequest())); @@ -620,6 +628,11 @@ void ConfigAHRSWidget::drawVariancesGraph() */ void ConfigAHRSWidget::ahrsSettingsRequest() { + // First of all, disconnect the autosave signals otherwise the GCS will save + // the settings as soon as it gets them, which is stupid + disconnect(m_ahrs->algorithm, SIGNAL(currentIndexChanged(int)), this, SLOT(ahrsSettingsSave())); + disconnect(m_ahrs->indoorFlight, SIGNAL(stateChanged(int)), this, SLOT(homeLocationSave())); + UAVObject *obj = dynamic_cast(getObjectManager()->getObject(QString("AHRSSettings"))); obj->requestUpdate(); UAVObjectField *field = obj->getField(QString("Algorithm")); @@ -629,38 +642,78 @@ void ConfigAHRSWidget::ahrsSettingsRequest() obj = dynamic_cast(getObjectManager()->getObject(QString("HomeLocation"))); field = obj->getField(QString("Indoor")); + if (field) + m_ahrs->indoorFlight->setChecked(field->getValue().toBool()); + field = obj->getField(QString("Set")); if (field) m_ahrs->homeLocation->setEnabled(field->getValue().toBool()); m_ahrs->ahrsCalibStart->setEnabled(true); m_ahrs->sixPointsStart->setEnabled(true); m_ahrs->calibInstructions->setText(QString("Press \"Start\" above to calibrate.")); + + // ... and reconnect + connect(m_ahrs->algorithm, SIGNAL(currentIndexChanged(int)), this, SLOT(ahrsSettingsSave())); + connect(m_ahrs->indoorFlight, SIGNAL(stateChanged(int)), this, SLOT(homeLocationSave())); + + +} + +/** + Enables/disables the Home Location saving button depending on whether the + home location is set-able + */ +void ConfigAHRSWidget::enableHomeLocSave(UAVObject * obj) +{ + UAVObjectField *field = obj->getField(QString("Set")); + if (field) + m_ahrs->homeLocation->setEnabled(field->getValue().toBool()); + // While we're at it, ensure the 'indoor' flag is consistent: + field = obj->getField(QString("Indoor")); + if (field) + m_ahrs->indoorFlight->setChecked(field->getValue().toBool()); } /** - Save current settings to RAM (besides the Calibration data) + Save current settings to SD or RAM (depending on radio button) */ -void ConfigAHRSWidget::ahrsSettingsSaveRAM() +void ConfigAHRSWidget::ahrsSettingsSave() { - UAVObject *obj = dynamic_cast(getObjectManager()->getObject(QString("AHRSSettings"))); + UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject(QString("AHRSSettings"))); UAVObjectField *field = obj->getField(QString("Algorithm")); field->setValue(m_ahrs->algorithm->currentText()); obj->updated(); - + if (m_ahrs->ahrsSettingsSaveSD->isChecked()) + updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj); } +/** + Save Home Location settings to SD or RAM (depending on radio button) + */ +void ConfigAHRSWidget::homeLocationSave() +{ + UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject(QString("HomeLocation"))); + UAVObjectField *field = obj->getField(QString("Indoor")); + if (m_ahrs->indoorFlight->isChecked()) + field->setValue(QString("TRUE")); + else + field->setValue(QString("FALSE")); + obj->updated(); + if (m_ahrs->ahrsSettingsSaveSD->isChecked()) + updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj); +} /** - Save current settings to SD (besides the Calibration data) + Force save Home Location settings to SD */ -void ConfigAHRSWidget::ahrsSettingsSaveSD() +void ConfigAHRSWidget::homeLocationSaveSD() { - ahrsSettingsSaveRAM(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("AHRSSettings"))); + UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject(QString("HomeLocation"))); updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj); } + /** @} @} diff --git a/ground/src/plugins/config/configahrswidget.h b/ground/src/plugins/config/configahrswidget.h index d206f7d60..bb43f5bdf 100644 --- a/ground/src/plugins/config/configahrswidget.h +++ b/ground/src/plugins/config/configahrswidget.h @@ -50,6 +50,7 @@ public: private: void drawVariancesGraph(); void displayPlane(QString elementID); + Ui_AHRSWidget *m_ahrs; QGraphicsSvgItem *paperplane; QGraphicsSvgItem *ahrsbargraph; @@ -90,14 +91,17 @@ private: QString initialUpdateFiltered; double listMean(QList list); + private slots: + void enableHomeLocSave(UAVObject *obj); void launchAHRSCalibration(); void saveAHRSCalibration(); void calibPhase2(); void incrementProgress(); void ahrsSettingsRequest(); - void ahrsSettingsSaveRAM(); - void ahrsSettingsSaveSD(); + void ahrsSettingsSave(); + void homeLocationSave(); + void homeLocationSaveSD(); // forces save to SD void savePositionData(); void computeScaleBias(); void sixPointCalibrationMode();