mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Add "Reset To Defaults" button to Stabilization configuration tab
Also add tootips to Reset/Apply/Save buttons.
This commit is contained in:
parent
c5a2afcc2c
commit
369629ad34
@ -42,7 +42,6 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa
|
|||||||
m_stabilization = new Ui_StabilizationWidget();
|
m_stabilization = new Ui_StabilizationWidget();
|
||||||
m_stabilization->setupUi(this);
|
m_stabilization->setupUi(this);
|
||||||
|
|
||||||
|
|
||||||
setupButtons(m_stabilization->saveStabilizationToRAM, m_stabilization->saveStabilizationToSD);
|
setupButtons(m_stabilization->saveStabilizationToRAM, m_stabilization->saveStabilizationToSD);
|
||||||
|
|
||||||
addUAVObject("StabilizationSettings");
|
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->pitchKi, SIGNAL(valueChanged(double)), this, SLOT(updatePitchKI(double)));
|
||||||
connect(m_stabilization->pitchILimit, SIGNAL(valueChanged(double)), this, SLOT(updatePitchILimit(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->rateRollKp);
|
||||||
addWidget(m_stabilization->rateRollKi);
|
addWidget(m_stabilization->rateRollKi);
|
||||||
addWidget(m_stabilization->rateRollILimit);
|
addWidget(m_stabilization->rateRollILimit);
|
||||||
@ -102,6 +99,9 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa
|
|||||||
addWidget(m_stabilization->maximumYaw);
|
addWidget(m_stabilization->maximumYaw);
|
||||||
addWidget(m_stabilization->lowThrottleZeroIntegral);
|
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()
|
ConfigStabilizationWidget::~ConfigStabilizationWidget()
|
||||||
@ -195,21 +195,17 @@ void ConfigStabilizationWidget::updatePitchILimit(double val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* Stabilization Settings
|
* 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:
|
// Now fill in all the fields, this is fairly tedious:
|
||||||
m_stabilization->rateRollKp->setValue(stabData.RollRatePID[StabilizationSettings::ROLLRATEPID_KP]);
|
m_stabilization->rateRollKp->setValue(stabData.RollRatePID[StabilizationSettings::ROLLRATEPID_KP]);
|
||||||
m_stabilization->rateRollKi->setValue(stabData.RollRatePID[StabilizationSettings::ROLLRATEPID_KI]);
|
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->maximumPitch->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_PITCH]);
|
||||||
m_stabilization->maximumYaw->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_YAW]);
|
m_stabilization->maximumYaw->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_YAW]);
|
||||||
m_stabilization->lowThrottleZeroIntegral->setChecked(stabData.LowThrottleZeroIntegral==StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_TRUE ? true : false);
|
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
|
Send telemetry settings to the board
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ConfigStabilizationWidget::updateObjectsFromWidgets()
|
void ConfigStabilizationWidget::updateObjectsFromWidgets()
|
||||||
{
|
{
|
||||||
StabilizationSettings::DataFields stabData = stabSettings->getData();
|
StabilizationSettings::DataFields stabData = stabSettings->getData();
|
||||||
@ -298,7 +304,6 @@ void ConfigStabilizationWidget::updateObjectsFromWidgets()
|
|||||||
|
|
||||||
stabData.LowThrottleZeroIntegral = (m_stabilization->lowThrottleZeroIntegral->isChecked() ? StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_TRUE :StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_FALSE);
|
stabData.LowThrottleZeroIntegral = (m_stabilization->lowThrottleZeroIntegral->isChecked() ? StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_TRUE :StabilizationSettings::LOWTHROTTLEZEROINTEGRAL_FALSE);
|
||||||
|
|
||||||
|
|
||||||
stabSettings->setData(stabData); // this is atomic
|
stabSettings->setData(stabData); // this is atomic
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,9 +316,16 @@ void ConfigStabilizationWidget::realtimeUpdateToggle(bool state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigStabilizationWidget::openHelp()
|
void ConfigStabilizationWidget::resetToDefaults()
|
||||||
{
|
{
|
||||||
|
StabilizationSettings stabDefaults;
|
||||||
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Stabilization+panel", QUrl::StrictMode) );
|
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) );
|
||||||
|
}
|
||||||
|
@ -49,11 +49,13 @@ private:
|
|||||||
Ui_StabilizationWidget *m_stabilization;
|
Ui_StabilizationWidget *m_stabilization;
|
||||||
StabilizationSettings* stabSettings;
|
StabilizationSettings* stabSettings;
|
||||||
QTimer updateTimer;
|
QTimer updateTimer;
|
||||||
|
void refreshUIValues(StabilizationSettings::DataFields &stabData);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
virtual void refreshWidgetsValues();
|
virtual void refreshWidgetsValues();
|
||||||
void updateObjectsFromWidgets();
|
void updateObjectsFromWidgets();
|
||||||
void realtimeUpdateToggle(bool);
|
void realtimeUpdateToggle(bool);
|
||||||
|
void resetToDefaults();
|
||||||
void openHelp();
|
void openHelp();
|
||||||
|
|
||||||
void updateRateRollKP(double);
|
void updateRateRollKP(double);
|
||||||
@ -73,4 +75,4 @@ private slots:
|
|||||||
void updatePitchILimit(double);
|
void updatePitchILimit(double);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ConfigStabilizationWidget_H
|
#endif // CONFIGSTABILIZATIONWIDGET_H
|
||||||
|
@ -747,8 +747,24 @@ automatically every 300ms, which will help for fast tuning.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="stabilizationResetToDefaults">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Load default Stabilization settings
|
||||||
|
|
||||||
|
Loaded settings are not applied automatically. You have to click the
|
||||||
|
Apply or Save button afterwards.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset To Defaults</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="saveStabilizationToRAM">
|
<widget class="QPushButton" name="saveStabilizationToRAM">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Send settings to the board but do not save to the non-volatile memory</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Apply</string>
|
<string>Apply</string>
|
||||||
</property>
|
</property>
|
||||||
@ -756,6 +772,9 @@ automatically every 300ms, which will help for fast tuning.</string>
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="saveStabilizationToSD">
|
<widget class="QPushButton" name="saveStabilizationToSD">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Send settings to the board and save to the non-volatile memory</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>Save</string>
|
||||||
</property>
|
</property>
|
||||||
@ -765,6 +784,44 @@ automatically every 300ms, which will help for fast tuning.</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>scrollArea</tabstop>
|
||||||
|
<tabstop>rateRollKp</tabstop>
|
||||||
|
<tabstop>rateRollKi</tabstop>
|
||||||
|
<tabstop>rateRollILimit</tabstop>
|
||||||
|
<tabstop>linkRateRP</tabstop>
|
||||||
|
<tabstop>ratePitchKp</tabstop>
|
||||||
|
<tabstop>ratePitchKi</tabstop>
|
||||||
|
<tabstop>ratePitchILimit</tabstop>
|
||||||
|
<tabstop>rateYawKp</tabstop>
|
||||||
|
<tabstop>rateYawKi</tabstop>
|
||||||
|
<tabstop>rateYawILimit</tabstop>
|
||||||
|
<tabstop>rollKp</tabstop>
|
||||||
|
<tabstop>rollKi</tabstop>
|
||||||
|
<tabstop>rollILimit</tabstop>
|
||||||
|
<tabstop>linkAttitudeRP</tabstop>
|
||||||
|
<tabstop>pitchKp</tabstop>
|
||||||
|
<tabstop>pitchKi</tabstop>
|
||||||
|
<tabstop>pitchILimit</tabstop>
|
||||||
|
<tabstop>yawKp</tabstop>
|
||||||
|
<tabstop>yawKi</tabstop>
|
||||||
|
<tabstop>yawILimit</tabstop>
|
||||||
|
<tabstop>rollMax</tabstop>
|
||||||
|
<tabstop>pitchMax</tabstop>
|
||||||
|
<tabstop>yawMax</tabstop>
|
||||||
|
<tabstop>manualRoll</tabstop>
|
||||||
|
<tabstop>manualPitch</tabstop>
|
||||||
|
<tabstop>manualYaw</tabstop>
|
||||||
|
<tabstop>maximumRoll</tabstop>
|
||||||
|
<tabstop>maximumPitch</tabstop>
|
||||||
|
<tabstop>maximumYaw</tabstop>
|
||||||
|
<tabstop>lowThrottleZeroIntegral</tabstop>
|
||||||
|
<tabstop>realTimeUpdates</tabstop>
|
||||||
|
<tabstop>stabilizationHelp</tabstop>
|
||||||
|
<tabstop>stabilizationResetToDefaults</tabstop>
|
||||||
|
<tabstop>saveStabilizationToRAM</tabstop>
|
||||||
|
<tabstop>saveStabilizationToSD</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../coreplugin/core.qrc"/>
|
<include location="../coreplugin/core.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user