diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index cbe554f4e..69b0427e3 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -42,8 +42,7 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa m_stabilization = new Ui_StabilizationWidget(); m_stabilization->setupUi(this); - - setupButtons(m_stabilization->saveStabilizationToRAM,m_stabilization->saveStabilizationToSD); + setupButtons(m_stabilization->saveStabilizationToRAM, m_stabilization->saveStabilizationToSD); addUAVObject("StabilizationSettings"); @@ -71,8 +70,6 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa connect(m_stabilization->pitchKi, SIGNAL(valueChanged(double)), this, SLOT(updatePitchKI(double))); connect(m_stabilization->pitchILimit, SIGNAL(valueChanged(double)), this, SLOT(updatePitchILimit(double))); - // Connect the help button - connect(m_stabilization->stabilizationHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addWidget(m_stabilization->rateRollKp); addWidget(m_stabilization->rateRollKi); addWidget(m_stabilization->rateRollILimit); @@ -102,6 +99,9 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa addWidget(m_stabilization->maximumYaw); addWidget(m_stabilization->lowThrottleZeroIntegral); + // Connect buttons + connect(m_stabilization->stabilizationResetToDefaults, SIGNAL(clicked()), this, SLOT(resetToDefaults())); + connect(m_stabilization->stabilizationHelp, SIGNAL(clicked()), this, SLOT(openHelp())); } ConfigStabilizationWidget::~ConfigStabilizationWidget() @@ -195,21 +195,17 @@ void ConfigStabilizationWidget::updatePitchILimit(double val) } } - /******************************* * Stabilization Settings *****************************/ /** - Request stabilization settings from the board + * Refresh UI with new settings of StabilizationSettings object + * (either from active configuration or just loaded defaults + * to be applied or saved) */ -void ConfigStabilizationWidget::refreshWidgetsValues() +void ConfigStabilizationWidget::refreshUIValues(StabilizationSettings::DataFields &stabData) { - bool dirty=isDirty(); - // Not needed anymore as this slot is only called whenever we get - // a signal that the object was just updated - // stabSettings->requestUpdate(); - StabilizationSettings::DataFields stabData = stabSettings->getData(); // Now fill in all the fields, this is fairly tedious: m_stabilization->rateRollKp->setValue(stabData.RollRatePID[StabilizationSettings::ROLLRATEPID_KP]); m_stabilization->rateRollKi->setValue(stabData.RollRatePID[StabilizationSettings::ROLLRATEPID_KI]); @@ -247,15 +243,25 @@ void ConfigStabilizationWidget::refreshWidgetsValues() m_stabilization->maximumPitch->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_PITCH]); m_stabilization->maximumYaw->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_YAW]); m_stabilization->lowThrottleZeroIntegral->setChecked(stabData.LowThrottleZeroIntegral==StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_TRUE ? true : false); - - setDirty(dirty); } +/** + Request stabilization settings from the board + */ +void ConfigStabilizationWidget::refreshWidgetsValues() +{ + bool dirty=isDirty(); + // Not needed anymore as this slot is only called whenever we get + // a signal that the object was just updated + // stabSettings->requestUpdate(); + StabilizationSettings::DataFields stabData = stabSettings->getData(); + refreshUIValues(stabData); + setDirty(dirty); +} /** Send telemetry settings to the board */ - void ConfigStabilizationWidget::updateObjectsFromWidgets() { StabilizationSettings::DataFields stabData = stabSettings->getData(); @@ -298,7 +304,6 @@ void ConfigStabilizationWidget::updateObjectsFromWidgets() stabData.LowThrottleZeroIntegral = (m_stabilization->lowThrottleZeroIntegral->isChecked() ? StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_TRUE :StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_FALSE); - stabSettings->setData(stabData); // this is atomic } @@ -311,9 +316,16 @@ void ConfigStabilizationWidget::realtimeUpdateToggle(bool state) } } -void ConfigStabilizationWidget::openHelp() +void ConfigStabilizationWidget::resetToDefaults() { - - QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Stabilization+panel", QUrl::StrictMode) ); + StabilizationSettings stabDefaults; + StabilizationSettings::DataFields defaults = stabDefaults.getData(); + bool dirty=isDirty(); + refreshUIValues(defaults); + setDirty(dirty); } +void ConfigStabilizationWidget::openHelp() +{ + QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Stabilization+panel", QUrl::StrictMode) ); +} diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h index e512c5097..b502dd25e 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h @@ -49,11 +49,13 @@ private: Ui_StabilizationWidget *m_stabilization; StabilizationSettings* stabSettings; QTimer updateTimer; + void refreshUIValues(StabilizationSettings::DataFields &stabData); private slots: virtual void refreshWidgetsValues(); void updateObjectsFromWidgets(); void realtimeUpdateToggle(bool); + void resetToDefaults(); void openHelp(); void updateRateRollKP(double); @@ -73,4 +75,4 @@ private slots: void updatePitchILimit(double); }; -#endif // ConfigStabilizationWidget_H +#endif // CONFIGSTABILIZATIONWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 5c2de727e..f99b35b94 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -1,772 +1,829 @@ - - - StabilizationWidget - - - - 0 - 0 - 683 - 685 - - - - Form - - - - - - - 0 - 1 - - - - QFrame::NoFrame - - - true - - - - - 0 - 0 - 665 - 627 - - - - - 0 - 0 - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 150 - - - - Rate Stabilization Coefficients (Inner Loop) - - - - - - Kp - - - Qt::AlignCenter - - - - - - - Ki - - - Qt::AlignCenter - - - - - - - ILimit - - - Qt::AlignCenter - - - - - - - Roll - - - - - - - Slowly raise Kp until you start seeing clear oscillations when you fly. -Then lower the value by 20% or so. - - - 6 - - - 0.000100000000000 - - - - - - - I factor for rate stabilization is usually very low or even zero. - - - 6 - - - 0.000100000000000 - - - - - - - 6 - - - 0.000100000000000 - - - - - - - If checked, the Roll and Pitch factors will be identical. -When you change one, the other is updated. - - - Link - - - - - - - Pitch - - - - - - - Slowly raise Kp until you start seeing clear oscillations when you fly. -Then lower the value by 20% or so. - - - 6 - - - 0.000100000000000 - - - - - - - I factor for rate stabilization is usually very low or even zero. - - - 6 - - - 0.000100000000000 - - - - - - - 6 - - - 0.000100000000000 - - - - - - - Yaw - - - - - - - Slowly raise Kp until you start seeing clear oscillations when you fly. -Then lower the value by 20% or so. - -You can usually go for higher values for Yaw factors. - - - 6 - - - 0.000100000000000 - - - - - - - As a rule of thumb, you can set YawRate Ki at roughly the same -value as YawRate Kp. - - - 6 - - - 0.000100000000000 - - - - - - - 6 - - - 0.000100000000000 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 13 - - - - - - - - - 0 - 0 - - - - - 0 - 150 - - - - Attitude Stabization Coefficients (Outer Loop) - - - - - - Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. - - - - 6 - - - 0.100000000000000 - - - - - - - Ki can usually be almost identical to Kp. - - - 6 - - - 0.100000000000000 - - - - - - - ILimit can be equal to three to four times Ki, but you can adjust -depending on whether your airframe is well balanced, and your -flying style. - - - 6 - - - 0.100000000000000 - - - - - - - Kp - - - Qt::AlignCenter - - - - - - - Ki - - - Qt::AlignCenter - - - - - - - ILimit - - - Qt::AlignCenter - - - - - - - ILimit can be equal to three to four times Ki, but you can adjust -depending on whether your airframe is well balanced, and your -flying style. - - - 6 - - - 0.100000000000000 - - - - - - - Ki can usually be almost identical to Kp. - - - 6 - - - 0.100000000000000 - - - - - - - Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. - - - - 6 - - - 0.100000000000000 - - - - - - - Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. - - - - 6 - - - 0.100000000000000 - - - - - - - Yaw - - - - - - - Pitch - - - - - - - Roll - - - - - - - Ki can usually be almost identical to Kp. - - - 6 - - - 0.100000000000000 - - - - - - - ILimit can be equal to three to four times Ki, but you can adjust -depending on whether your airframe is well balanced, and your -flying style. - - - 6 - - - 0.100000000000000 - - - - - - - If checked, the Roll and Pitch factors will be identical. -When you change one, the other is updated. - - - Link - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 13 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Stick range and limits - - - - QLayout::SetMinAndMaxSize - - - - - Roll - - - Qt::AlignCenter - - - - - - - Pitch - - - Qt::AlignCenter - - - - - - - Yaw - - - Qt::AlignCenter - - - - - - - 180 - - - - - - - 180 - - - - - - - 180 - - - - - - - - 150 - 0 - - - - - 50 - false - - - - Full stick angle (deg) - - - - - - - - 150 - 0 - - - - - 50 - false - - - - Full stick rate (deg/s) - - - - - - - 500 - - - - - - - 500 - - - - - - - 500 - - - - - - - - 150 - 0 - - - - - 50 - false - - - - - - - Maximum rate in attitude mode (deg/s) - - - - - - - 500 - - - - - - - 500 - - - - - - - 500 - - - - - - - - - - Zero the integral when throttle is low - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - - - - If you check this, the GCS will udpate the stabilization factors -automatically every 300ms, which will help for fast tuning. - - - Update in real time - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - - - - :/core/images/helpicon.svg:/core/images/helpicon.svg - - - - 32 - 32 - - - - true - - - - - - - Apply - - - - - - - Save - - - - - - - - - - - - + + + StabilizationWidget + + + + 0 + 0 + 683 + 685 + + + + Form + + + + + + + 0 + 1 + + + + QFrame::NoFrame + + + true + + + + + 0 + 0 + 665 + 627 + + + + + 0 + 0 + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 150 + + + + Rate Stabilization Coefficients (Inner Loop) + + + + + + Kp + + + Qt::AlignCenter + + + + + + + Ki + + + Qt::AlignCenter + + + + + + + ILimit + + + Qt::AlignCenter + + + + + + + Roll + + + + + + + Slowly raise Kp until you start seeing clear oscillations when you fly. +Then lower the value by 20% or so. + + + 6 + + + 0.000100000000000 + + + + + + + I factor for rate stabilization is usually very low or even zero. + + + 6 + + + 0.000100000000000 + + + + + + + 6 + + + 0.000100000000000 + + + + + + + If checked, the Roll and Pitch factors will be identical. +When you change one, the other is updated. + + + Link + + + + + + + Pitch + + + + + + + Slowly raise Kp until you start seeing clear oscillations when you fly. +Then lower the value by 20% or so. + + + 6 + + + 0.000100000000000 + + + + + + + I factor for rate stabilization is usually very low or even zero. + + + 6 + + + 0.000100000000000 + + + + + + + 6 + + + 0.000100000000000 + + + + + + + Yaw + + + + + + + Slowly raise Kp until you start seeing clear oscillations when you fly. +Then lower the value by 20% or so. + +You can usually go for higher values for Yaw factors. + + + 6 + + + 0.000100000000000 + + + + + + + As a rule of thumb, you can set YawRate Ki at roughly the same +value as YawRate Kp. + + + 6 + + + 0.000100000000000 + + + + + + + 6 + + + 0.000100000000000 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 150 + + + + Attitude Stabization Coefficients (Outer Loop) + + + + + + Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. + + + + 6 + + + 0.100000000000000 + + + + + + + Ki can usually be almost identical to Kp. + + + 6 + + + 0.100000000000000 + + + + + + + ILimit can be equal to three to four times Ki, but you can adjust +depending on whether your airframe is well balanced, and your +flying style. + + + 6 + + + 0.100000000000000 + + + + + + + Kp + + + Qt::AlignCenter + + + + + + + Ki + + + Qt::AlignCenter + + + + + + + ILimit + + + Qt::AlignCenter + + + + + + + ILimit can be equal to three to four times Ki, but you can adjust +depending on whether your airframe is well balanced, and your +flying style. + + + 6 + + + 0.100000000000000 + + + + + + + Ki can usually be almost identical to Kp. + + + 6 + + + 0.100000000000000 + + + + + + + Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. + + + + 6 + + + 0.100000000000000 + + + + + + + Once Rate stabilization is done, you should increase the Kp factor until the airframe oscillates again, and go back down 20% or so. + + + + 6 + + + 0.100000000000000 + + + + + + + Yaw + + + + + + + Pitch + + + + + + + Roll + + + + + + + Ki can usually be almost identical to Kp. + + + 6 + + + 0.100000000000000 + + + + + + + ILimit can be equal to three to four times Ki, but you can adjust +depending on whether your airframe is well balanced, and your +flying style. + + + 6 + + + 0.100000000000000 + + + + + + + If checked, the Roll and Pitch factors will be identical. +When you change one, the other is updated. + + + Link + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Stick range and limits + + + + QLayout::SetMinAndMaxSize + + + + + Roll + + + Qt::AlignCenter + + + + + + + Pitch + + + Qt::AlignCenter + + + + + + + Yaw + + + Qt::AlignCenter + + + + + + + 180 + + + + + + + 180 + + + + + + + 180 + + + + + + + + 150 + 0 + + + + + 50 + false + + + + Full stick angle (deg) + + + + + + + + 150 + 0 + + + + + 50 + false + + + + Full stick rate (deg/s) + + + + + + + 500 + + + + + + + 500 + + + + + + + 500 + + + + + + + + 150 + 0 + + + + + 50 + false + + + + + + + Maximum rate in attitude mode (deg/s) + + + + + + + 500 + + + + + + + 500 + + + + + + + 500 + + + + + + + + + + Zero the integral when throttle is low + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + + + + If you check this, the GCS will udpate the stabilization factors +automatically every 300ms, which will help for fast tuning. + + + Update in real time + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + + + + :/core/images/helpicon.svg:/core/images/helpicon.svg + + + + 32 + 32 + + + + true + + + + + + + Load default Stabilization settings + +Loaded settings are not applied automatically. You have to click the +Apply or Save button afterwards. + + + Reset To Defaults + + + + + + + Send settings to the board but do not save to the non-volatile memory + + + Apply + + + + + + + Send settings to the board and save to the non-volatile memory + + + Save + + + + + + + + + scrollArea + rateRollKp + rateRollKi + rateRollILimit + linkRateRP + ratePitchKp + ratePitchKi + ratePitchILimit + rateYawKp + rateYawKi + rateYawILimit + rollKp + rollKi + rollILimit + linkAttitudeRP + pitchKp + pitchKi + pitchILimit + yawKp + yawKi + yawILimit + rollMax + pitchMax + yawMax + manualRoll + manualPitch + manualYaw + maximumRoll + maximumPitch + maximumYaw + lowThrottleZeroIntegral + realTimeUpdates + stabilizationHelp + stabilizationResetToDefaults + saveStabilizationToRAM + saveStabilizationToSD + + + + + +