diff --git a/flight/Modules/TxPID/txpid.c b/flight/Modules/TxPID/txpid.c index cff9c1d9e..fd350c0d4 100644 --- a/flight/Modules/TxPID/txpid.c +++ b/flight/Modules/TxPID/txpid.c @@ -275,6 +275,9 @@ static void updatePIDs(UAVObjEvent* ev) case TXPIDSETTINGS_PIDS_YAWATTITUDEILIMIT: needsUpdate |= update(&stab.YawPI[STABILIZATIONSETTINGS_YAWPI_ILIMIT], value); break; + case TXPIDSETTINGS_PIDS_GYROTAU: + needsUpdate |= update(&stab.GyroTau, value); + break; default: PIOS_Assert(0); } diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp index ff0927709..12c81df9d 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp @@ -50,15 +50,10 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren m_config->setupUi(this); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD); - addUAVObject("ActuatorSettings"); UAVSettingsImportExportFactory * importexportplugin = pm->getObject(); connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(stopTests())); - addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD); - addUAVObject("ActuatorSettings"); - // NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10. // Register for ActuatorSettings changes: for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) @@ -73,25 +68,37 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool))); - refreshWidgetsValues(); firstUpdate = true; - connect(m_config->spinningArmed, SIGNAL(toggled(bool)), this, SLOT(setSpinningArmed(bool))); - + // Configure the task widget // Connect the help button connect(m_config->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp())); + + // Add custom handling of displaying things + connect(this,SIGNAL(refreshWidgetsValuesRequested()), this, SLOT(refreshOutputWidgetsValues())); + + addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD); + + // Track the ActuatorSettings object + addUAVObject("ActuatorSettings"); + + // Associate the buttons with their UAVO fields addWidget(m_config->cb_outputRate4); addWidget(m_config->cb_outputRate3); addWidget(m_config->cb_outputRate2); addWidget(m_config->cb_outputRate1); addWidget(m_config->spinningArmed); + disconnect(this, SLOT(refreshWidgetsValues(UAVObject*))); + UAVObjectManager *objManager = pm->getObject(); UAVObject* obj = objManager->getObject(QString("ActuatorCommand")); if(UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE) this->setEnabled(false); connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(disableIfNotMe(UAVObject*))); + + refreshWidgetsValues(); } void ConfigOutputWidget::enableControls(bool enable) { @@ -196,24 +203,6 @@ void ConfigOutputWidget::assignOutputChannel(UAVDataObject *obj, QString str) outputChannelForm->setAssignment(str); } -/** - * Set the "Spin motors at neutral when armed" flag in ActuatorSettings - */ -void ConfigOutputWidget::setSpinningArmed(bool val) -{ - ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager()); - Q_ASSERT(actuatorSettings); - ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData(); - - if(val) - actuatorSettingsData.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_TRUE; - else - actuatorSettingsData.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_FALSE; - - // Apply settings - actuatorSettings->setData(actuatorSettingsData); -} - /** Sends the channel value to the UAV to move the servo. Returns immediately if we are not in testing mode @@ -242,10 +231,8 @@ void ConfigOutputWidget::sendChannelTest(int index, int value) /** Request the current config from the board (RC Output) */ -void ConfigOutputWidget::refreshWidgetsValues(UAVObject *) +void ConfigOutputWidget::refreshOutputWidgetsValues(UAVObject *) { - bool dirty=isDirty(); - // Reset all channel assignements: QList outputChannelForms = findChildren(); foreach(OutputChannelForm *outputChannelForm, outputChannelForms) @@ -338,8 +325,6 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject *) int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()]; outputChannelForm->neutral(neutral); } - - setDirty(dirty); } /** @@ -347,26 +332,36 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject *) */ void ConfigOutputWidget::updateObjectsFromWidgets() { + emit updateObjectsFromWidgetsRequested(); + ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager()); Q_ASSERT(actuatorSettings); - ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData(); + if(actuatorSettings) { + ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData(); - // Set channel ranges - QList outputChannelForms = findChildren(); - foreach(OutputChannelForm *outputChannelForm, outputChannelForms) - { - actuatorSettingsData.ChannelMax[outputChannelForm->index()] = outputChannelForm->max(); - actuatorSettingsData.ChannelMin[outputChannelForm->index()] = outputChannelForm->min(); - actuatorSettingsData.ChannelNeutral[outputChannelForm->index()] = outputChannelForm->neutral(); + // Set channel ranges + QList outputChannelForms = findChildren(); + foreach(OutputChannelForm *outputChannelForm, outputChannelForms) + { + actuatorSettingsData.ChannelMax[outputChannelForm->index()] = outputChannelForm->max(); + actuatorSettingsData.ChannelMin[outputChannelForm->index()] = outputChannelForm->min(); + actuatorSettingsData.ChannelNeutral[outputChannelForm->index()] = outputChannelForm->neutral(); + } + + // Set update rates + actuatorSettingsData.ChannelUpdateFreq[0] = m_config->cb_outputRate1->currentText().toUInt(); + actuatorSettingsData.ChannelUpdateFreq[1] = m_config->cb_outputRate2->currentText().toUInt(); + actuatorSettingsData.ChannelUpdateFreq[2] = m_config->cb_outputRate3->currentText().toUInt(); + actuatorSettingsData.ChannelUpdateFreq[3] = m_config->cb_outputRate4->currentText().toUInt(); + + if(m_config->spinningArmed->isChecked() == true) + actuatorSettingsData.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_TRUE; + else + actuatorSettingsData.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_FALSE; + + // Apply settings + actuatorSettings->setData(actuatorSettingsData); } - - // Set update rates - actuatorSettingsData.ChannelUpdateFreq[0] = m_config->cb_outputRate1->currentText().toUInt(); - actuatorSettingsData.ChannelUpdateFreq[1] = m_config->cb_outputRate2->currentText().toUInt(); - actuatorSettingsData.ChannelUpdateFreq[2] = m_config->cb_outputRate3->currentText().toUInt(); - actuatorSettingsData.ChannelUpdateFreq[3] = m_config->cb_outputRate4->currentText().toUInt(); - // Apply settings - actuatorSettings->setData(actuatorSettingsData); } void ConfigOutputWidget::openHelp() diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h index 4602487ba..e939db7a7 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h @@ -69,11 +69,10 @@ private: private slots: void stopTests(); void disableIfNotMe(UAVObject *obj); - virtual void refreshWidgetsValues(UAVObject * obj = NULL); + void refreshOutputWidgetsValues(UAVObject * obj = NULL); void updateObjectsFromWidgets(); void runChannelTests(bool state); void sendChannelTest(int index, int value); - void setSpinningArmed(bool val); void openHelp(); protected: void enableControls(bool enable); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index cceec4216..7fb8d70c7 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -32,7 +32,7 @@ /** * Constructor */ -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL),allowWidgetUpdates(true) { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject(); @@ -127,7 +127,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel Q_ASSERT(obj); objectUpdates.insert(obj,true); connect(obj, SIGNAL(objectUpdated(UAVObject*)),this, SLOT(objectUpdated(UAVObject*))); - connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*))); + connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)), Qt::UniqueConnection); } if(!field.isEmpty() && obj) _field = obj->getField(QString(field)); @@ -258,6 +258,9 @@ void ConfigTaskWidget::populateWidgets() */ void ConfigTaskWidget::refreshWidgetsValues(UAVObject * obj) { + if (!allowWidgetUpdates) + return; + bool dirtyBack=dirty; emit refreshWidgetsValuesRequested(); foreach(objectToWidget * ow,objOfInterest) @@ -452,10 +455,10 @@ bool ConfigTaskWidget::isDirty() */ void ConfigTaskWidget::disableObjUpdates() { + allowWidgetUpdates = false; foreach(objectToWidget * obj,objOfInterest) { - if(obj->object) - disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + if(obj->object)disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*))); } } /** @@ -463,10 +466,11 @@ void ConfigTaskWidget::disableObjUpdates() */ void ConfigTaskWidget::enableObjUpdates() { + allowWidgetUpdates = true; foreach(objectToWidget * obj,objOfInterest) { if(obj->object) - connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*))); + connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues(UAVObject*)), Qt::UniqueConnection); } } /** diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 3099fa529..76d6b55bd 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -145,6 +145,7 @@ private slots: void reloadButtonClicked(); private: bool isConnected; + bool allowWidgetUpdates; QStringList objectsList; QList objOfInterest; ExtensionSystem::PluginManager *pm; diff --git a/shared/uavobjectdefinition/txpidsettings.xml b/shared/uavobjectdefinition/txpidsettings.xml index bdc05ba33..5b69063e8 100644 --- a/shared/uavobjectdefinition/txpidsettings.xml +++ b/shared/uavobjectdefinition/txpidsettings.xml @@ -16,7 +16,8 @@ Roll Rate.ILimit, Pitch Rate.ILimit, Roll+Pitch Rate.ILimit, Yaw Rate.ILimit, Roll Attitude.Kp, Pitch Attitude.Kp, Roll+Pitch Attitude.Kp, Yaw Attitude.Kp, Roll Attitude.Ki, Pitch Attitude.Ki, Roll+Pitch Attitude.Ki, Yaw Attitude.Ki, - Roll Attitude.ILimit, Pitch Attitude.ILimit, Roll+Pitch Attitude.ILimit, Yaw Attitude.ILimit" + Roll Attitude.ILimit, Pitch Attitude.ILimit, Roll+Pitch Attitude.ILimit, Yaw Attitude.ILimit, + GyroTau" defaultvalue="Disabled"/>