6import QGroundControl.FactControls
7import QGroundControl.Controls
11 pageComponent: tuningPageComponent
14 id: tuningPageComponent
19 FactPanelController { id: controller; }
21 property bool _atcInputTCAvailable: controller.parameterExists(-1, "ATC_INPUT_TC")
22 property Fact _atcInputTC: controller.getParameterFact(-1, "ATC_INPUT_TC", false)
23 property Fact _rateRollP: controller.getParameterFact(-1, "ATC_RAT_RLL_P")
24 property Fact _rateRollI: controller.getParameterFact(-1, "ATC_RAT_RLL_I")
25 property Fact _ratePitchP: controller.getParameterFact(-1, "ATC_RAT_PIT_P")
26 property Fact _ratePitchI: controller.getParameterFact(-1, "ATC_RAT_PIT_I")
27 property Fact _rateClimbP: controller.getParameterFact(-1, "PSC_ACCZ_P")
28 property Fact _rateClimbI: controller.getParameterFact(-1, "PSC_ACCZ_I")
29 property Fact _motSpinArm: controller.getParameterFact(-1, "MOT_SPIN_ARM")
30 property Fact _motSpinMin: controller.getParameterFact(-1, "MOT_SPIN_MIN")
32 property Fact _ch7Opt: controller.getParameterFact(-1, "r.RC7_OPTION")
33 property Fact _ch8Opt: controller.getParameterFact(-1, "r.RC8_OPTION")
34 property Fact _ch9Opt: controller.getParameterFact(-1, "r.RC9_OPTION")
35 property Fact _ch10Opt: controller.getParameterFact(-1, "r.RC10_OPTION")
36 property Fact _ch11Opt: controller.getParameterFact(-1, "r.RC11_OPTION")
37 property Fact _ch12Opt: controller.getParameterFact(-1, "r.RC12_OPTION")
39 readonly property int _firstOptionChannel: 7
40 readonly property int _lastOptionChannel: 12
42 property Fact _autoTuneAxes: controller.getParameterFact(-1, "AUTOTUNE_AXES")
43 property int _autoTuneSwitchChannelIndex: 0
44 readonly property int _autoTuneOption: 17
46 property real _margins: ScreenTools.defaultFontPixelHeight
48 property bool _loadComplete: false
50 Component.onCompleted: {
51 // We use QtCharts only on Desktop platforms
52 showAdvanced = !ScreenTools.isMobile
57 /// The AutoTune switch is stored in one of the RC#_OPTION parameters. We need to loop through those
58 /// to find them and setup the ui accordindly.
59 function calcAutoTuneChannel() {
60 _autoTuneSwitchChannelIndex = 0
61 for (var channel=_firstOptionChannel; channel<=_lastOptionChannel; channel++) {
62 var optionFact = controller.getParameterFact(-1, "r.RC" + channel + "_OPTION")
63 if (optionFact.value == _autoTuneOption) {
64 _autoTuneSwitchChannelIndex = channel - _firstOptionChannel + 1
70 /// We need to clear AutoTune from any previous channel before setting it to a new one
71 function setChannelAutoTuneOption(channel) {
72 // First clear any previous settings for AutTune
73 for (var optionChannel=_firstOptionChannel; optionChannel<=_lastOptionChannel; optionChannel++) {
74 var optionFact = controller.getParameterFact(-1, "r.RC" + optionChannel + "_OPTION")
75 if (optionFact.value == _autoTuneOption) {
80 // Now set the function into the new channel
82 var optionFact = controller.getParameterFact(-1, "r.RC" + channel + "_OPTION")
83 optionFact.value = _autoTuneOption
87 Connections { target: _ch7Opt; function onValueChanged(value) { calcAutoTuneChannel() } }
88 Connections { target: _ch8Opt; function onValueChanged(value) { calcAutoTuneChannel() } }
89 Connections { target: _ch9Opt; function onValueChanged(value) { calcAutoTuneChannel() } }
90 Connections { target: _ch10Opt; function onValueChanged(value) { calcAutoTuneChannel() } }
91 Connections { target: _ch11Opt; function onValueChanged(value) { calcAutoTuneChannel() } }
92 Connections { target: _ch12Opt; function onValueChanged(value) { calcAutoTuneChannel() } }
95 Layout.fillWidth: true
100 Layout.fillWidth: true
101 heading: qsTr("Roll/Pitch Sensitivity")
102 headingDescription: qsTr("Slide to the right if the copter is sluggish or slide to the left if the copter is twitchy")
106 Layout.fillWidth: true
109 majorTickStepSize: 0.02
114 _rateRollI.rawValue = value
115 _ratePitchP.rawValue = value
116 _ratePitchI.rawValue = value
121 SettingsGroupLayout {
122 Layout.fillWidth: true
123 heading: qsTr("Climb Sensitivity")
124 headingDescription: qsTr("Slide to the right to climb more aggressively or slide to the left to climb more gently")
128 Layout.fillWidth: true
131 majorTickStepSize: 0.05
134 onValueChanged: _rateClimbI.rawValue = value * 2
138 SettingsGroupLayout {
139 Layout.fillWidth: true
140 heading: qsTr("RC Roll/Pitch Feel")
141 headingDescription: qsTr("Slide to the left for soft control, slide to the right for crisp control")
145 Layout.fillWidth: true
146 from: _atcInputTC.min
148 majorTickStepSize: _atcInputTC.increment
155 SettingsGroupLayout {
156 Layout.fillWidth: true
157 heading: qsTr("Spin While Armed")
158 headingDescription: qsTr("Adjust the amount the motors spin to indicate armed. Should be lower than 'Minimum Thrust'")
161 Layout.fillWidth: true
164 majorTickStepSize: 0.1
170 SettingsGroupLayout {
171 Layout.fillWidth: true
172 heading: qsTr("Minimum Thrust")
173 headingDescription: qsTr("Adjust the minimum amount of thrust require for the vehicle to move. Should be higher than 'Spin While Armed")
176 Layout.fillWidth: true
179 majorTickStepSize: 0.1
187 Layout.fillWidth: true
190 SettingsGroupLayout {
191 heading: qsTr("AutoTune")
197 QGCLabel { text: qsTr("Axes to AutoTune:") }
198 FactBitmask { fact: _autoTuneAxes }
202 id: autoTuneChannelCombo
203 width: ScreenTools.defaultFontPixelWidth * 14
204 label: qsTr("Channel for AutoTune switch:")
205 model: [qsTr("None"), qsTr("Channel 7"), qsTr("Channel 8"), qsTr("Channel 9"), qsTr("Channel 10"), qsTr("Channel 11"), qsTr("Channel 12") ]
206 currentIndex: _autoTuneSwitchChannelIndex
208 onActivated: (index) => {
214 setChannelAutoTuneOption(channel)
220 SettingsGroupLayout {
221 heading: qsTr("In Flight Tuning")
224 id: channel6TuningOptColumn
225 spacing: ScreenTools.defaultFontPixelHeight
227 LabelledFactComboBox {
229 width: ScreenTools.defaultFontPixelWidth * 15
230 label: qsTr("RC Channel 6 Option (Tuning):")
231 fact: controller.getParameterFact(-1, "TUNE")
236 spacing: ScreenTools.defaultFontPixelWidth
238 LabelledFactTextField {
240 textField.validator: DoubleValidator {bottom: 0; top: 32767;}
242 fact: controller.getParameterFact(-1, "r.TUNE_MIN")
245 LabelledFactTextField {
247 textField.validator: DoubleValidator {bottom: 0; top: 32767;}
249 fact: controller.getParameterFact(-1, "r.TUNE_MAX")
258 Layout.fillWidth: true
259 sourceComponent: advanced ? advancePageComponent : undefined
263 id: advancePageComponent
266 property bool useAutoTuning: false
268 property var roll: QtObject {
269 property string name: qsTr("Roll")
271 { name: "Response", value: globals.activeVehicle.rollRate.value },
272 { name: "Setpoint", value: globals.activeVehicle.setpoint.rollRate.value }
274 property var params: ListModel {
276 title: qsTr("Roll axis angle controller P gain")
277 param: "ATC_ANG_RLL_P"
284 title: qsTr("Roll axis rate controller P gain")
285 param: "ATC_RAT_RLL_P"
292 title: qsTr("Roll axis rate controller I gain")
293 param: "ATC_RAT_RLL_I"
300 title: qsTr("Roll axis rate controller D gain")
301 param: "ATC_RAT_RLL_D"
309 property var pitch: QtObject {
310 property string name: qsTr("Pitch")
312 { name: "Response", value: globals.activeVehicle.pitchRate.value },
313 { name: "Setpoint", value: globals.activeVehicle.setpoint.pitchRate.value }
315 property var params: ListModel {
317 title: qsTr("Pitch axis angle controller P gain")
318 param: "ATC_ANG_PIT_P"
325 title: qsTr("Pitch axis rate controller P gain")
326 param: "ATC_RAT_PIT_P"
333 title: qsTr("Pitch axis rate controller I gain")
334 param: "ATC_RAT_PIT_I"
341 title: qsTr("Pitch axis rate controller D gain")
342 param: "ATC_RAT_PIT_D"
350 property var yaw: QtObject {
351 property string name: qsTr("Yaw")
353 { name: "Response", value: globals.activeVehicle.yawRate.value },
354 { name: "Setpoint", value: globals.activeVehicle.setpoint.yawRate.value }
356 property var params: ListModel {
358 title: qsTr("Yaw axis angle controller P gain")
359 param: "ATC_ANG_YAW_P"
366 title: qsTr("Yaw axis rate controller P gain")
367 param: "ATC_RAT_YAW_P"
374 title: qsTr("Yaw axis rate controller I gain")
375 param: "ATC_RAT_YAW_I"
384 tuningMode: Vehicle.ModeDisabled
386 axis: [ roll, pitch, yaw ]
389 } // Component - Advanced Page