Browse Source

PX4 PID tuning: save & restore autotuning checkbox when switching between tabs

QGC4.4
Beat Küng 3 years ago committed by Don Gagne
parent
commit
187dfbfd20
  1. 12
      src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml
  2. 3
      src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAttitude.qml
  3. 3
      src/AutoPilotPlugins/PX4/PX4TuningComponentCopterRate.qml
  4. 4
      src/QmlControls/PIDTuning.qml

12
src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml

@ -18,6 +18,7 @@ import QGroundControl.ScreenTools 1.0 @@ -18,6 +18,7 @@ import QGroundControl.ScreenTools 1.0
Item {
width: availableWidth
property bool _autotuningEnabled: true // used to restore setting when switching between tabs
FactPanelController {
id: controller
@ -39,6 +40,11 @@ Item { @@ -39,6 +40,11 @@ Item {
QGCTabButton {
text: qsTr("Position Controller")
}
onCurrentIndexChanged: {
if (typeof loader.item.autotuningEnabled !== "undefined") {
_autotuningEnabled = loader.item.autotuningEnabled;
}
}
}
property var pages: [
@ -49,10 +55,16 @@ Item { @@ -49,10 +55,16 @@ Item {
]
Loader {
id: loader
source: pages[bar.currentIndex]
width: parent.width
anchors.top: bar.bottom
anchors.topMargin: ScreenTools.defaultFontPixelWidth
anchors.bottom: parent.bottom
onLoaded: {
if (typeof loader.item.autotuningEnabled !== "undefined") {
loader.item.autotuningEnabled = _autotuningEnabled;
}
}
}
}

3
src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAttitude.qml

@ -21,9 +21,11 @@ import QGroundControl.Vehicle 1.0 @@ -21,9 +21,11 @@ import QGroundControl.Vehicle 1.0
ColumnLayout {
width: availableWidth
anchors.fill: parent
property alias autotuningEnabled: pidTuning.autotuningEnabled
PIDTuning {
width: availableWidth
id: pidTuning
property var roll: QtObject {
property string name: qsTr("Roll")
@ -81,6 +83,7 @@ ColumnLayout { @@ -81,6 +83,7 @@ ColumnLayout {
unit: "deg"
axis: [ roll, pitch, yaw ]
showAutoModeChange: true
showAutoTuning: true
}
}

3
src/AutoPilotPlugins/PX4/PX4TuningComponentCopterRate.qml

@ -23,6 +23,7 @@ ColumnLayout { @@ -23,6 +23,7 @@ ColumnLayout {
anchors.fill: parent
property Fact _airmode: controller.getParameterFact(-1, "MC_AIRMODE", false)
property Fact _thrustModelFactor: controller.getParameterFact(-1, "THR_MDL_FAC", false)
property alias autotuningEnabled: pidTuning.autotuningEnabled
GridLayout {
columns: 2
@ -52,6 +53,7 @@ ColumnLayout { @@ -52,6 +53,7 @@ ColumnLayout {
}
PIDTuning {
width: availableWidth
id: pidTuning
property var roll: QtObject {
property string name: qsTr("Roll")
@ -150,6 +152,7 @@ ColumnLayout { @@ -150,6 +152,7 @@ ColumnLayout {
axis: [ roll, pitch, yaw ]
chartDisplaySec: 3
showAutoModeChange: true
showAutoTuning: true
}
}

4
src/QmlControls/PIDTuning.qml

@ -28,6 +28,8 @@ RowLayout { @@ -28,6 +28,8 @@ RowLayout {
property var tuningMode
property double chartDisplaySec: 8 // number of seconds to display
property bool showAutoModeChange: false
property bool showAutoTuning: false
property alias autotuningEnabled: autotuningEnabled.checked
property real _margins: ScreenTools.defaultFontPixelHeight / 2
property int _currentAxis: 0
@ -188,7 +190,7 @@ RowLayout { @@ -188,7 +190,7 @@ RowLayout {
Row {
id: _autotuneSelectRow
spacing: _margins
visible: tuningMode === Vehicle.ModeRateAndAttitude
visible: showAutoTuning
Switch {
id: autotuningEnabled

Loading…
Cancel
Save