From b53f19dc0332e08c7c37483a2db2a035cc5b4cdf Mon Sep 17 00:00:00 2001 From: edouard Date: Tue, 7 Sep 2010 20:08:29 +0000 Subject: [PATCH] OP-38 Ground/Config Gadget : another try at making AHRS settings more intuitive. And the Object queue now works (...) git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1558 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/config/ahrs.ui | 65 +++++++++++++++---- .../src/plugins/config/configahrswidget.cpp | 56 +++++++--------- ground/src/plugins/config/configahrswidget.h | 5 +- .../src/plugins/config/configtaskwidget.cpp | 3 +- 4 files changed, 79 insertions(+), 50 deletions(-) diff --git a/ground/src/plugins/config/ahrs.ui b/ground/src/plugins/config/ahrs.ui index eb134d1a6..d36191e3c 100644 --- a/ground/src/plugins/config/ahrs.ui +++ b/ground/src/plugins/config/ahrs.ui @@ -182,31 +182,39 @@ Hint: run this with engines at cruising speed. Six Point Calibration instructions - + false - 380 + 480 361 - 201 + 51 31 Saves the Home Location. This is only enabled if the Home Location is set, i.e. if the GPS fix is -successful. +successful. + +Disabled if there is no GPS fix. - Save Home Location to SD + Set + + true + + + buttonGroup + - 260 + 280 430 93 27 @@ -303,13 +311,13 @@ Only makes sense with the "INSGPS" algorithm. Indoor flight mode - + 390 430 111 - 21 + 27 @@ -321,17 +329,14 @@ specific calibration button on top of the screen. Save to RAM - - buttonGroup - - + 520 430 101 - 21 + 27 @@ -341,12 +346,46 @@ specific calibration button on top of the screen. Save to SD + false + + + + true + + + 550 + 360 + 71 + 31 + + + + Clears the HomeLocation: only makes sense if you save +to SD. This will force the AHRS to use the next GPS fix as the +new home location unless it is in indoor mode. + + + Clear + buttonGroup + + + + 370 + 360 + 101 + 31 + + + + Home Location: + + diff --git a/ground/src/plugins/config/configahrswidget.cpp b/ground/src/plugins/config/configahrswidget.cpp index 194c90d4f..8fd6549ef 100644 --- a/ground/src/plugins/config/configahrswidget.cpp +++ b/ground/src/plugins/config/configahrswidget.cpp @@ -188,13 +188,13 @@ ConfigAHRSWidget::ConfigAHRSWidget(QWidget *parent) : ConfigTaskWidget(parent) // 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())); @@ -628,10 +628,6 @@ 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(); @@ -646,17 +642,12 @@ void ConfigAHRSWidget::ahrsSettingsRequest() m_ahrs->indoorFlight->setChecked(field->getValue().toBool()); field = obj->getField(QString("Set")); if (field) - m_ahrs->homeLocation->setEnabled(field->getValue().toBool()); + m_ahrs->homeLocationSet->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())); - - } /** @@ -666,8 +657,9 @@ void ConfigAHRSWidget::ahrsSettingsRequest() void ConfigAHRSWidget::enableHomeLocSave(UAVObject * obj) { UAVObjectField *field = obj->getField(QString("Set")); - if (field) - m_ahrs->homeLocation->setEnabled(field->getValue().toBool()); + if (field) { + m_ahrs->homeLocationSet->setEnabled(field->getValue().toBool()); + } // While we're at it, ensure the 'indoor' flag is consistent: field = obj->getField(QString("Indoor")); if (field) @@ -676,42 +668,40 @@ void ConfigAHRSWidget::enableHomeLocSave(UAVObject * obj) /** - Save current settings to SD or RAM (depending on radio button) + Save current settings to RAM */ -void ConfigAHRSWidget::ahrsSettingsSave() +void ConfigAHRSWidget::ahrsSettingsSaveRAM() { 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")); + obj = dynamic_cast(getObjectManager()->getObject(QString("HomeLocation"))); + field = obj->getField(QString("Indoor")); if (m_ahrs->indoorFlight->isChecked()) field->setValue(QString("TRUE")); else field->setValue(QString("FALSE")); + field = obj->getField(QString("Set")); + if (m_ahrs->homeLocationSet->isChecked()) + field->setValue(QString("TRUE")); + else + field->setValue(QString("FALSE")); obj->updated(); - if (m_ahrs->ahrsSettingsSaveSD->isChecked()) - saveObjectToSD(obj); -// updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj); + } /** - Force save Home Location settings to SD +Save AHRS Settings and home location to SD */ -void ConfigAHRSWidget::homeLocationSaveSD() +void ConfigAHRSWidget::ahrsSettingsSaveSD() { + ahrsSettingsSaveRAM(); UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject(QString("HomeLocation"))); - updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj); + saveObjectToSD(obj); + obj = dynamic_cast(getObjectManager()->getObject(QString("AHRSSettings"))); + saveObjectToSD(obj); + } diff --git a/ground/src/plugins/config/configahrswidget.h b/ground/src/plugins/config/configahrswidget.h index bb43f5bdf..3b3588628 100644 --- a/ground/src/plugins/config/configahrswidget.h +++ b/ground/src/plugins/config/configahrswidget.h @@ -99,9 +99,8 @@ private slots: void calibPhase2(); void incrementProgress(); void ahrsSettingsRequest(); - void ahrsSettingsSave(); - void homeLocationSave(); - void homeLocationSaveSD(); // forces save to SD + void ahrsSettingsSaveRAM(); + void ahrsSettingsSaveSD(); void savePositionData(); void computeScaleBias(); void sixPointCalibrationMode(); diff --git a/ground/src/plugins/config/configtaskwidget.cpp b/ground/src/plugins/config/configtaskwidget.cpp index 44dbf68f4..90c89be92 100644 --- a/ground/src/plugins/config/configtaskwidget.cpp +++ b/ground/src/plugins/config/configtaskwidget.cpp @@ -57,7 +57,7 @@ void ConfigTaskWidget::saveNextObject() return; } // Get next object from the queue - UAVObject* obj = queue.dequeue(); + UAVObject* obj = queue.head(); ObjectPersistence* objper = dynamic_cast( getObjectManager()->getObject(ObjectPersistence::NAME) ); connect(objper, SIGNAL(transactionCompleted(UAVObject*,bool)), this, SLOT(transactionCompleted(UAVObject*,bool))); if (obj != NULL) @@ -77,6 +77,7 @@ void ConfigTaskWidget::transactionCompleted(UAVObject* obj, bool success) Q_UNUSED(success); // Disconnect from sending object obj->disconnect(this); + queue.dequeue(); // We can now remove the object, it's done. saveNextObject(); }