diff --git a/src/ui/configuration/ApmSoftwareConfig.cc b/src/ui/configuration/ApmSoftwareConfig.cc index c0010ad8e0c6ba8768ad57fb930e321cf53bc650..a12719cf74d1809889a7a09802846a3fd86a4aaf 100644 --- a/src/ui/configuration/ApmSoftwareConfig.cc +++ b/src/ui/configuration/ApmSoftwareConfig.cc @@ -15,7 +15,7 @@ ApmSoftwareConfig::ApmSoftwareConfig(QWidget *parent) : QWidget(parent) ui.failSafeButton->setVisible(false); ui.advancedParamButton->setVisible(false); ui.advParamListButton->setVisible(false); - ui.arduCoperPidButton->setVisible(false); + ui.arduCopterPidButton->setVisible(false); /*basicPidConfig = new BasicPidConfig(this); ui.stackedWidget->addWidget(basicPidConfig); @@ -47,10 +47,18 @@ ApmSoftwareConfig::ApmSoftwareConfig(QWidget *parent) : QWidget(parent) buttonToConfigWidgetMap[ui.advancedParamButton] = advancedParamConfig; connect(ui.advancedParamButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget())); - arduCoperPidConfig = new ArduCopterPidConfig(this); - ui.stackedWidget->addWidget(arduCoperPidConfig); - buttonToConfigWidgetMap[ui.arduCoperPidButton] = arduCoperPidConfig; - connect(ui.arduCoperPidButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget())); + arduCopterPidConfig = new ArduCopterPidConfig(this); + ui.stackedWidget->addWidget(arduCopterPidConfig); + buttonToConfigWidgetMap[ui.arduCopterPidButton] = arduCopterPidConfig; + connect(ui.arduCopterPidButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget())); + + + arduPlanePidConfig = new ArduPlanePidConfig(this); + ui.stackedWidget->addWidget(arduPlanePidConfig); + buttonToConfigWidgetMap[ui.arduPlanePidButton] = arduPlanePidConfig; + connect(ui.arduPlanePidButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget())); + + connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUASSet(UASInterface*))); if (UASManager::instance()->getActiveUAS()) @@ -84,7 +92,16 @@ void ApmSoftwareConfig::activeUASSet(UASInterface *uas) ui.advancedParamButton->setVisible(true); ui.advParamListButton->setVisible(true); - ui.arduCoperPidButton->setVisible(true); + if (uas->getSystemType() == MAV_TYPE_FIXED_WING) + { + ui.arduPlanePidButton->setVisible(true); + ui.arduCopterPidButton->setVisible(false); + } + else if (uas->getSystemType() == MAV_TYPE_QUADROTOR) + { + ui.arduCopterPidButton->setVisible(true); + ui.arduPlanePidButton->setVisible(false); + } QDir autopilotdir(qApp->applicationDirPath() + "/files/" + uas->getAutopilotTypeName().toLower()); diff --git a/src/ui/configuration/ApmSoftwareConfig.h b/src/ui/configuration/ApmSoftwareConfig.h index c28d366b0ecaf9a90e9a8d2774995cb12eb3747c..d314450e25ab3a25225b6bc05b108db77deb0b6a 100644 --- a/src/ui/configuration/ApmSoftwareConfig.h +++ b/src/ui/configuration/ApmSoftwareConfig.h @@ -10,6 +10,7 @@ #include "FailSafeConfig.h" #include "AdvancedParamConfig.h" #include "ArduCopterPidConfig.h" +#include "ArduPlanePidConfig.h" #include "UASInterface.h" #include "UASManager.h" @@ -32,7 +33,8 @@ private: GeoFenceConfig *geoFenceConfig; FailSafeConfig *failSafeConfig; AdvancedParamConfig *advancedParamConfig; - ArduCopterPidConfig *arduCoperPidConfig; + ArduCopterPidConfig *arduCopterPidConfig; + ArduPlanePidConfig *arduPlanePidConfig; QMap buttonToConfigWidgetMap; }; diff --git a/src/ui/configuration/ApmSoftwareConfig.ui b/src/ui/configuration/ApmSoftwareConfig.ui index e6fc845632bd40d7d62e3bfaaefb6cd8f0b9f691..b25f61577e07416ce25c05edccb714e3adbd108b 100644 --- a/src/ui/configuration/ApmSoftwareConfig.ui +++ b/src/ui/configuration/ApmSoftwareConfig.ui @@ -172,7 +172,7 @@ - + 0 @@ -180,13 +180,26 @@ - ArduCoper Pids + ArduCopter Pids false + + + + + 0 + 35 + + + + ArduPlane Pids + + + diff --git a/src/ui/configuration/ArduPlanePidConfig.cc b/src/ui/configuration/ArduPlanePidConfig.cc index 276a689b49612bef400200c7d561ff1d214463b5..ac6d4da28d8a8da7160376eb0c326993a72d6044 100644 --- a/src/ui/configuration/ArduPlanePidConfig.cc +++ b/src/ui/configuration/ArduPlanePidConfig.cc @@ -4,15 +4,91 @@ ArduPlanePidConfig::ArduPlanePidConfig(QWidget *parent) : AP2ConfigWidget(parent) { ui.setupUi(this); + + nameToBoxMap["RLL2SRV_P"] = ui.servoRollPSpinBox; + nameToBoxMap["RLL2SRV_I"] = ui.servoRollISpinBox; + nameToBoxMap["RLL2SRV_D"] = ui.servoRollDSpinBox; + nameToBoxMap["RLL2SRV_IMAX"] = ui.servoRollIMAXSpinBox; + + nameToBoxMap["PTCH2SRV_P"] = ui.servoPitchPSpinBox; + nameToBoxMap["PTCH2SRV_I"] = ui.servoPitchISpinBox; + nameToBoxMap["PTCH2SRV_D"] = ui.servoPitchDSpinBox; + nameToBoxMap["PTCH2SRV_IMAX"] = ui.servoPitchIMAXSpinBox; + + nameToBoxMap["YW2SRV_P"] = ui.servoYawPSpinBox; + nameToBoxMap["YW2SRV_I"] = ui.servoYawISpinBox; + nameToBoxMap["YW2SRV_D"] = ui.servoYawDSpinBox; + nameToBoxMap["YW2SRV_IMAX"] = ui.servoYawIMAXSpinBox; + + nameToBoxMap["ALT2PTCH_P"] = ui.navAltPSpinBox; + nameToBoxMap["ALT2PTCH_I"] = ui.navAltISpinBox; + nameToBoxMap["ALT2PTCH_D"] = ui.navAltDSpinBox; + nameToBoxMap["ALT2PTCH_IMAX"] = ui.navAltIMAXSpinBox; + + nameToBoxMap["ARSP2PTCH_P"] = ui.navASPSpinBox; + nameToBoxMap["ARSP2PTCH_I"] = ui.navASISpinBox; + nameToBoxMap["ARSP2PTCH_D"] = ui.navASDSpinBox; + nameToBoxMap["ARSP2PTCH_IMAX"] = ui.navASIMAXSpinBox; + + nameToBoxMap["ENRGY2THR_P"] = ui.energyPSpinBox; + nameToBoxMap["ENRGY2THR_I"] = ui.energyISpinBox; + nameToBoxMap["ENRGY2THR_D"] = ui.energyDSpinBox; + nameToBoxMap["ENRGY2THR_IMAX"] = ui.energyIMAXSpinBox; + + nameToBoxMap["KFF_PTCH2THR"] = ui.otherPitchCompSpinBox; + nameToBoxMap["KFF_PTCHCOMP"] = ui.otherPtTSpinBox; + nameToBoxMap["KFF_RDDRMIX"] = ui.otherRudderMixSpinBox; + + nameToBoxMap["TRIM_THROTTLE"] = ui.throttleCruiseSpinBox; + nameToBoxMap["THR_FS_VALUE"] = ui.throttleFSSpinBox; + nameToBoxMap["THR_MAX"] = ui.throttleMaxSpinBox; + nameToBoxMap["THR_MIN"] = ui.throttleMinSpinBox; + + nameToBoxMap["TRIM_ARSPD_CM"] = ui.airspeedCruiseSpinBox; + nameToBoxMap["ARSPD_FBW_MAX"] = ui.airspeedFBWMaxSpinBox; + nameToBoxMap["ARSPD_FBW_MIN"] = ui.airspeedFBWMinSpinBox; + nameToBoxMap["ARSPD_RATIO"] = ui.airspeedRatioSpinBox; + + nameToBoxMap["NAVL1_DAMPING"] = ui.l1DampingSpinBox; + nameToBoxMap["NAVL1_PERIOD"] = ui.l1PeriodSpinBox; + + nameToBoxMap["LIM_ROLL_CD"] = ui.navBankMaxSpinBox; + nameToBoxMap["LIM_PITCH_MAX"] = ui.navPitchMaxSpinBox; + nameToBoxMap["LIM_PITCH_MIN"] = ui.navPitchMinSpinBox; + } ArduPlanePidConfig::~ArduPlanePidConfig() { } -void ArduPlanePidconfig::parameterChanged(int uas, int component, QString parameterName, QVariant value) +void ArduPlanePidConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value) { - if (parameterName == "") + if (nameToBoxMap.contains(parameterName)) { + nameToBoxMap[parameterName]->setValue(value.toDouble()); + } +} +void ArduPlanePidConfig::writeButtonClicked() +{ + if (!m_uas) + { + return; + } + for (QMap::const_iterator i=nameToBoxMap.constBegin();i!=nameToBoxMap.constEnd();i++) + { + m_uas->getParamManager()->setParameter(1,i.key(),i.value()->value()); + } +} +void ArduPlanePidConfig::refreshButtonClicked() +{ + if (!m_uas) + { + return; } + for (QMap::const_iterator i=nameToBoxMap.constBegin();i!=nameToBoxMap.constEnd();i++) + { + m_uas->getParamManager()->requestParameterUpdate(1,i.key()); + } + } diff --git a/src/ui/configuration/ArduPlanePidConfig.h b/src/ui/configuration/ArduPlanePidConfig.h index dcb75eef000855ed765d273767cbb72a22034e23..b0f12c4b8d1623eebcfaba037663622a7e27302c 100644 --- a/src/ui/configuration/ArduPlanePidConfig.h +++ b/src/ui/configuration/ArduPlanePidConfig.h @@ -14,7 +14,10 @@ public: ~ArduPlanePidConfig(); private slots: void parameterChanged(int uas, int component, QString parameterName, QVariant value); + void writeButtonClicked(); + void refreshButtonClicked(); private: + QMap nameToBoxMap; Ui::ArduPlanePidConfig ui; }; diff --git a/src/ui/configuration/ArduPlanePidConfig.ui b/src/ui/configuration/ArduPlanePidConfig.ui index b1cb38fd2f6a7d36ba376f9c457f6d20fe4b79ab..4ee4c406b15f97f025969bdefc401c22fe9a3fd6 100644 --- a/src/ui/configuration/ArduPlanePidConfig.ui +++ b/src/ui/configuration/ArduPlanePidConfig.ui @@ -164,9 +164,9 @@ - + - 100.000000000000000 + 10000.000000000000000 @@ -252,7 +252,7 @@ - 100.000000000000000 + 10000.000000000000000 @@ -338,7 +338,7 @@ - 100.000000000000000 + 10000.000000000000000 @@ -424,7 +424,7 @@ - 100.000000000000000 + 10000.000000000000000 @@ -510,7 +510,7 @@ - 100.000000000000000 + 10000.000000000000000 @@ -596,7 +596,7 @@ - 100.000000000000000 + 10000.000000000000000 @@ -815,8 +815,11 @@ 3 + + -10000.000000000000000 + - 100.000000000000000 + 10000.000000000000000 @@ -826,7 +829,10 @@ 3 - 100.000000000000000 + 10000.000000000000000 + + + 0.000000000000000