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. 14
      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

14
src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml

@ -17,7 +17,8 @@ import QGroundControl.FactSystem 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
Item { Item {
width: availableWidth width: availableWidth
property bool _autotuningEnabled: true // used to restore setting when switching between tabs
FactPanelController { FactPanelController {
id: controller id: controller
@ -39,6 +40,11 @@ Item {
QGCTabButton { QGCTabButton {
text: qsTr("Position Controller") text: qsTr("Position Controller")
} }
onCurrentIndexChanged: {
if (typeof loader.item.autotuningEnabled !== "undefined") {
_autotuningEnabled = loader.item.autotuningEnabled;
}
}
} }
property var pages: [ property var pages: [
@ -49,10 +55,16 @@ Item {
] ]
Loader { Loader {
id: loader
source: pages[bar.currentIndex] source: pages[bar.currentIndex]
width: parent.width width: parent.width
anchors.top: bar.bottom anchors.top: bar.bottom
anchors.topMargin: ScreenTools.defaultFontPixelWidth anchors.topMargin: ScreenTools.defaultFontPixelWidth
anchors.bottom: parent.bottom 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
ColumnLayout { ColumnLayout {
width: availableWidth width: availableWidth
anchors.fill: parent anchors.fill: parent
property alias autotuningEnabled: pidTuning.autotuningEnabled
PIDTuning { PIDTuning {
width: availableWidth width: availableWidth
id: pidTuning
property var roll: QtObject { property var roll: QtObject {
property string name: qsTr("Roll") property string name: qsTr("Roll")
@ -81,6 +83,7 @@ ColumnLayout {
unit: "deg" unit: "deg"
axis: [ roll, pitch, yaw ] axis: [ roll, pitch, yaw ]
showAutoModeChange: true showAutoModeChange: true
showAutoTuning: true
} }
} }

3
src/AutoPilotPlugins/PX4/PX4TuningComponentCopterRate.qml

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

4
src/QmlControls/PIDTuning.qml

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

Loading…
Cancel
Save