QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMSensorsComponent.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.FactControls
8import QGroundControl.Controls
9
10SetupPage {
11 id: sensorsPage
12 pageComponent: sensorsPageComponent
13
14 Component {
15 id: sensorsPageComponent
16
17 Item {
18 width: availableWidth
19 height: availableHeight
20
21 // Help text which is shown both in the status text area prior to pressing a cal button and in the
22 // pre-calibration dialog.
23
24 readonly property string orientationHelpSet: qsTr("If mounted in the direction of flight, select None.")
25 readonly property string orientationHelpCal: qsTr("Before calibrating make sure rotation settings are correct. ") + orientationHelpSet
26 readonly property string compassRotationText: qsTr("If the compass or GPS module is mounted in flight direction, leave the default value (None)")
27
28 readonly property string compassHelp: qsTr("For Compass calibration you will need to rotate your vehicle through a number of positions.")
29 readonly property string gyroHelp: qsTr("For Gyroscope calibration you will need to place your vehicle on a surface and leave it still.")
30 readonly property string accelHelp: qsTr("For Accelerometer calibration you will need to place your vehicle on all six sides on a perfectly level surface and hold it still in each orientation for a few seconds.")
31 readonly property string levelHelp: qsTr("To level the horizon you need to place the vehicle in its level flight position and press OK.")
32
33 readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons to the left.")
34
35 // Used to pass help text to the preCalibrationDialog dialog
36 property string preCalibrationDialogHelp
37
38 property string _postCalibrationDialogText
39 property var _postCalibrationDialogParams
40
41 readonly property string _badCompassCalText: qsTr("The calibration for Compass %1 appears to be poor. ") +
42 qsTr("Check the compass position within your vehicle and re-do the calibration.")
43
44 readonly property int sideBarH1PointSize: ScreenTools.mediumFontPointSize
45 readonly property int mainTextH1PointSize: ScreenTools.mediumFontPointSize // Seems to be unused
46
47 readonly property int rotationColumnWidth: 250
48
49 property Fact noFact: Fact { }
50
51 property bool accelCalNeeded: controller.accelSetupNeeded
52 property bool compassCalNeeded: controller.compassSetupNeeded
53
54 property Fact boardRot: controller.getParameterFact(-1, "AHRS_ORIENTATION")
55
56 readonly property int _calTypeCompass: 1 ///< Calibrate compass
57 readonly property int _calTypeAccel: 2 ///< Calibrate accel
58 readonly property int _calTypeSet: 3 ///< Set orientations only
59 readonly property int _buttonWidth: ScreenTools.defaultFontPixelWidth * 15
60
61 property bool _orientationsDialogShowCompass: true
62 property string _orientationDialogHelp: orientationHelpSet
63 property int _orientationDialogCalType
64 property real _margins: ScreenTools.defaultFontPixelHeight / 2
65 property bool _compassAutoRotAvailable: controller.parameterExists(-1, "COMPASS_AUTO_ROT")
66 property Fact _compassAutoRotFact: controller.getParameterFact(-1, "COMPASS_AUTO_ROT", false /* reportMissing */)
67 property bool _compassAutoRot: _compassAutoRotAvailable ? _compassAutoRotFact.rawValue == 2 : false
68 property bool _showSimpleAccelCalOption: false
69 property bool _doSimpleAccelCal: false
70 property var _gcsPosition: QGroundControl.positionManager.gcsPosition
71 property var _mapPosition: QGroundControl.flightMapPosition
72
73 function showOrientationsDialog(calType) {
74 let dialogTitle
75 let dialogButtons = Dialog.Ok
76 _showSimpleAccelCalOption = false
77
78 _orientationDialogCalType = calType
79 switch (calType) {
80 case _calTypeCompass:
81 _orientationsDialogShowCompass = true
82 _orientationDialogHelp = orientationHelpCal
83 dialogTitle = qsTr("Calibrate Compass")
84 dialogButtons |= Dialog.Cancel
85 break
86 case _calTypeAccel:
87 _orientationsDialogShowCompass = false
88 _orientationDialogHelp = orientationHelpCal
89 dialogTitle = qsTr("Calibrate Accelerometer")
90 dialogButtons |= Dialog.Cancel
91 break
92 case _calTypeSet:
93 _orientationsDialogShowCompass = true
94 _orientationDialogHelp = orientationHelpSet
95 dialogTitle = qsTr("Sensor Settings")
96 break
97 }
98
99 orientationsDialogFactory.open({ title: dialogTitle, buttons: dialogButtons })
100 }
101
102 function showSimpleAccelCalOption() {
103 _showSimpleAccelCalOption = true
104 }
105
106 // Maps the APM controller per-side done/inProgress bools to a VehicleRotationCal.CalState
107 function sideCalState(done, inProgress) {
108 if (inProgress) {
109 return VehicleRotationCal.CalState.InProgress
110 }
111 return done ? VehicleRotationCal.CalState.Completed : VehicleRotationCal.CalState.Incomplete
112 }
113
114 function compassLabel(index) {
115 let label = qsTr("Compass %1 ").arg(index+1)
116 let addOpenParan = true
117 let addComma = false
118 if (sensorParams.compassPrimaryFactAvailable) {
119 label += sensorParams.rgCompassPrimary[index] ? qsTr("(primary") : qsTr("(secondary")
120 addComma = true
121 addOpenParan = false
122 }
123 if (sensorParams.rgCompassExternalParamAvailable[index]) {
124 if (addOpenParan) {
125 label += "("
126 }
127 if (addComma) {
128 label += qsTr(", ")
129 }
130 label += sensorParams.rgCompassExternal[index] ? qsTr("external") : qsTr("internal")
131 }
132 label += ")"
133 return label
134 }
135
136 APMSensorParams {
137 id: sensorParams
138 factPanelController: controller
139 }
140
141 APMSensorsComponentController {
142 id: controller
143 statusLog: statusTextArea
144 progressBar: progressBar
145 nextButton: nextButton
146 cancelButton: cancelButton
147 orientationCalAreaHelpText: orientationCalAreaHelpText
148
149 property var rgCompassCalFitness: [ controller.compass1CalFitness, controller.compass2CalFitness, controller.compass3CalFitness ]
150
151 onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText
152
153 onWaitingForCancelChanged: {
154 if (controller.waitingForCancel) {
155 waitForCancelDialogFactory.open()
156 }
157 }
158
159 onCalibrationComplete: (calType) => {
160 switch (calType) {
161 case MAVLink.CalibrationMag:
162 _singleCompassSettingsComponentShowPriority = true
163 postOnboardCompassCalibrationFactory.open()
164 break
165 case MAVLink.CalibrationAccel:
166 postCalibrationFactory.open()
167 break
168 }
169 }
170
171 onSetAllCalButtonsEnabled: (enabled) => {
172 buttonColumn.enabled = enabled
173 }
174
175 onCalibrationActiveChanged: {
176 if (controller.calibrationActive) {
177 globals.navigationBlockedReason = qsTr("Complete or cancel the current calibration first")
178 } else {
179 globals.navigationBlockedReason = ""
180 }
181 }
182 }
183
184 Component.onDestruction: globals.navigationBlockedReason = ""
185
186 QGCPalette { id: qgcPal; colorGroupEnabled: true }
187
188 QGCPopupDialogFactory {
189 id: waitForCancelDialogFactory
190
191 dialogComponent: waitForCancelDialogComponent
192 }
193
194 Component {
195 id: waitForCancelDialogComponent
196
197 QGCSimpleMessageDialog {
198 title: qsTr("Calibration Cancel")
199 text: qsTr("Waiting for Vehicle to response to Cancel. This may take a few seconds.")
200 buttons: 0
201
202 Connections {
203 target: controller
204
205 onWaitingForCancelChanged: {
206 if (!controller.waitingForCancel) {
207 close()
208 }
209 }
210 }
211 }
212 }
213
214 Component {
215 id: singleCompassOnboardResultsComponent
216
217 Column {
218 anchors.left: parent ? parent.left : undefined
219 anchors.right: parent ? parent.right : undefined
220 spacing: Math.round(ScreenTools.defaultFontPixelHeight / 2)
221 visible: sensorParams.rgCompassAvailable[index] && sensorParams.rgCompassUseFact[index].value
222
223 property int _index: index
224
225 property real greenMaxThreshold: 8 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
226 property real yellowMaxThreshold: 15 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
227 property real fitnessRange: 25 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
228
229 Item {
230 anchors.left: parent.left
231 anchors.right: parent.right
232 height: ScreenTools.defaultFontPixelHeight
233
234 Row {
235 id: fitnessRow
236 anchors.fill: parent
237
238 Rectangle {
239 width: parent.width * (greenMaxThreshold / fitnessRange)
240 height: parent.height
241 color: "green"
242 }
243 Rectangle {
244 width: parent.width * ((yellowMaxThreshold - greenMaxThreshold) / fitnessRange)
245 height: parent.height
246 color: "yellow"
247 }
248 Rectangle {
249 width: parent.width * ((fitnessRange - yellowMaxThreshold) / fitnessRange)
250 height: parent.height
251 color: "red"
252 }
253 }
254
255 Rectangle {
256 height: fitnessRow.height * 0.66
257 width: height
258 anchors.verticalCenter: fitnessRow.verticalCenter
259 x: (fitnessRow.width * (Math.min(Math.max(controller.rgCompassCalFitness[index], 0.0), fitnessRange) / fitnessRange)) - (width / 2)
260 radius: height / 2
261 color: "white"
262 border.color: "black"
263 }
264 }
265
266 Loader {
267 anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
268 anchors.left: parent.left
269 anchors.right: parent.right
270 sourceComponent: singleCompassSettingsComponent
271
272 property int index: _index
273 }
274 }
275 }
276
277 QGCPopupDialogFactory {
278 id: postOnboardCompassCalibrationFactory
279
280 dialogComponent: postOnboardCompassCalibrationComponent
281 }
282
283 Component {
284 id: postOnboardCompassCalibrationComponent
285
286 QGCPopupDialog {
287 id: postOnboardCompassCalibrationDialog
288 title: qsTr("Calibration complete")
289 buttons: Dialog.Ok
290
291 Column {
292 objectName: "postOnboardCompassCalibrationDialog"
293 width: 40 * ScreenTools.defaultFontPixelWidth
294 spacing: ScreenTools.defaultFontPixelHeight
295
296 Repeater {
297 model: 3
298 delegate: singleCompassOnboardResultsComponent
299 }
300
301 QGCLabel {
302 anchors.left: parent.left
303 anchors.right: parent.right
304 wrapMode: Text.WordWrap
305 text: qsTr("Shown in the indicator bars is the quality of the calibration for each compass.\n\n") +
306 qsTr("- Green indicates a well functioning compass.\n") +
307 qsTr("- Yellow indicates a questionable compass or calibration.\n") +
308 qsTr("- Red indicates a compass which should not be used.\n\n") +
309 qsTr("YOU MUST REBOOT YOUR VEHICLE AFTER EACH CALIBRATION.")
310 }
311 }
312 }
313 }
314
315 QGCPopupDialogFactory {
316 id: postCalibrationFactory
317
318 dialogComponent: postCalibrationComponent
319 }
320
321 Component {
322 id: postCalibrationComponent
323
324 QGCPopupDialog {
325 id: postCalibrationDialog
326 title: qsTr("Calibration complete")
327
328 Column {
329 objectName: "postCalibrationDialog"
330 width: 40 * ScreenTools.defaultFontPixelWidth
331 spacing: ScreenTools.defaultFontPixelHeight
332
333 QGCLabel {
334 anchors.left: parent.left
335 anchors.right: parent.right
336 wrapMode: Text.WordWrap
337 text: qsTr("YOU MUST REBOOT YOUR VEHICLE AFTER EACH CALIBRATION.")
338 }
339 }
340 }
341 }
342
343 property bool _singleCompassSettingsComponentShowPriority: true
344 Component {
345 id: singleCompassSettingsComponent
346
347 Column {
348 spacing: Math.round(ScreenTools.defaultFontPixelHeight / 2)
349 visible: sensorParams.rgCompassAvailable[index]
350
351 QGCLabel {
352 text: compassLabel(index)
353 }
354 APMSensorIdDecoder {
355 fact: sensorParams.rgCompassId[index]
356 }
357
358 Column {
359 anchors.margins: ScreenTools.defaultFontPixelWidth * 2
360 anchors.left: parent.left
361 spacing: Math.round(ScreenTools.defaultFontPixelHeight / 4)
362
363 RowLayout {
364 spacing: ScreenTools.defaultFontPixelWidth
365
366 FactCheckBox {
367 id: useCompassCheckBox
368 text: qsTr("Use Compass")
369 fact: sensorParams.rgCompassUseFact[index]
370 visible: sensorParams.rgCompassUseParamAvailable[index] && !sensorParams.rgCompassPrimary[index]
371 }
372
373 QGCComboBox {
374 model: [ qsTr("Priority 1"), qsTr("Priority 2"), qsTr("Priority 3"), qsTr("Not Set") ]
375 visible: _singleCompassSettingsComponentShowPriority && sensorParams.compassPrioFactsAvailable && useCompassCheckBox.visible && useCompassCheckBox.checked
376
377 property int _compassIndex: index
378
379 function selectPriorityfromParams() {
380 currentIndex = 3
381 let compassId = sensorParams.rgCompassId[_compassIndex].rawValue
382 for (let prioIndex=0; prioIndex<3; prioIndex++) {
383 if (compassId == sensorParams.rgCompassPrio[prioIndex].rawValue) {
384 currentIndex = prioIndex
385 break
386 }
387 }
388 }
389
390 Component.onCompleted: selectPriorityfromParams()
391
392 onActivated: (index) => {
393 if (index == 3) {
394 // User cannot select Not Set
395 selectPriorityfromParams()
396 } else {
397 sensorParams.rgCompassPrio[index].rawValue = sensorParams.rgCompassId[_compassIndex].rawValue
398 }
399 }
400 }
401 }
402
403 Column {
404 visible: !_compassAutoRot && sensorParams.rgCompassExternal[index] && sensorParams.rgCompassRotParamAvailable[index]
405
406 QGCLabel { text: qsTr("Orientation:") }
407
408 FactComboBox {
409 width: rotationColumnWidth
410 indexModel: false
411 fact: sensorParams.rgCompassRotFact[index]
412 }
413 }
414 }
415 }
416 }
417
418 QGCPopupDialogFactory {
419 id: orientationsDialogFactory
420
421 dialogComponent: orientationsDialogComponent
422 }
423
424 Component {
425 id: orientationsDialogComponent
426
427 QGCPopupDialog {
428 function compassMask () {
429 let mask = 0
430 mask |= (0 + (sensorParams.rgCompassPrio[0].rawValue !== 0)) << 0
431 mask |= (0 + (sensorParams.rgCompassPrio[1].rawValue !== 0)) << 1
432 mask |= (0 + (sensorParams.rgCompassPrio[2].rawValue !== 0)) << 2
433 return mask
434 }
435
436 onAccepted: {
437 if (_orientationDialogCalType == _calTypeAccel) {
438 controller.calibrateAccel(_doSimpleAccelCal)
439 } else if (_orientationDialogCalType == _calTypeCompass) {
440 if (!northCalibrationCheckBox.checked) {
441 controller.calibrateCompass()
442 } else {
443 let lat = parseFloat(northCalLat.text)
444 let lon = parseFloat(northCalLon.text)
445 if (useMapPositionCheckbox.checked) {
446 lat = _mapPosition.latitude
447 lon = _mapPosition.longitude
448 }
449 if (useGcsPositionCheckbox.checked) {
450 lat = _gcsPosition.latitude
451 lon = _gcsPosition.longitude
452 }
453 if (isNaN(lat) || isNaN(lon)) {
454 return
455 }
456 controller.calibrateCompassNorth(lat, lon, compassMask())
457 }
458 }
459 }
460
461 Column {
462 width: 40 * ScreenTools.defaultFontPixelWidth
463 spacing: ScreenTools.defaultFontPixelHeight
464
465 QGCLabel {
466 width: parent.width
467 wrapMode: Text.WordWrap
468 text: _orientationDialogHelp
469 }
470
471 Column {
472 QGCLabel { text: qsTr("Autopilot Rotation:") }
473
474 FactComboBox {
475 width: rotationColumnWidth
476 indexModel: false
477 fact: boardRot
478 }
479 }
480
481 Column {
482
483 visible: _orientationDialogCalType == _calTypeAccel
484 spacing: ScreenTools.defaultFontPixelHeight
485
486 QGCLabel {
487 width: parent.width
488 wrapMode: Text.WordWrap
489 text: qsTr("Simple accelerometer calibration is less precise but allows calibrating without rotating the vehicle. Check this if you have a large/heavy vehicle.")
490 }
491
492 QGCCheckBox {
493 text: qsTr("Simple Accelerometer Calibration")
494 onClicked: _doSimpleAccelCal = this.checked
495 }
496 }
497
498 Repeater {
499 model: _orientationsDialogShowCompass ? 3 : 0
500 delegate: singleCompassSettingsComponent
501 }
502
503 QGCLabel {
504 id: magneticDeclinationLabel
505 width: parent.width
506 visible: globals.activeVehicle.sub && _orientationsDialogShowCompass
507 text: qsTr("Magnetic Declination")
508 }
509
510 Column {
511 visible: magneticDeclinationLabel.visible
512 anchors.margins: ScreenTools.defaultFontPixelWidth
513 anchors.left: parent.left
514 anchors.right: parent.right
515 spacing: ScreenTools.defaultFontPixelHeight
516
517 QGCCheckBox {
518 id: manualMagneticDeclinationCheckBox
519 text: qsTr("Manual Magnetic Declination")
520 property Fact autoDecFact: controller.getParameterFact(-1, "COMPASS_AUTODEC")
521 property int manual: 0
522 property int automatic: 1
523
524 checked: autoDecFact.rawValue === manual
525 onClicked: autoDecFact.value = (checked ? manual : automatic)
526 }
527
528 FactTextField {
529 fact: sensorParams.declinationFact
530 enabled: manualMagneticDeclinationCheckBox.checked
531 }
532 }
533
534 Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer
535
536 QGCLabel {
537 id: northCalibrationLabel
538 width: parent.width
539 visible: _orientationsDialogShowCompass
540 wrapMode: Text.WordWrap
541 text: qsTr("Fast compass calibration given vehicle position and yaw. This ") +
542 qsTr("results in zero diagonal and off-diagonal elements, so is only ") +
543 qsTr("suitable for vehicles where the field is close to spherical. It is ") +
544 qsTr("useful for large vehicles where moving the vehicle to calibrate it ") +
545 qsTr("is difficult. Point the vehicle North before using it.")
546 }
547
548 Column {
549 visible: northCalibrationLabel.visible
550 anchors.margins: ScreenTools.defaultFontPixelWidth
551 anchors.left: parent.left
552 anchors.right: parent.right
553 spacing: ScreenTools.defaultFontPixelHeight
554
555 QGCCheckBox {
556 id: northCalibrationCheckBox
557 visible: northCalibrationLabel.visible
558 text: qsTr("Fast Calibration")
559 }
560
561 QGCLabel {
562 id: northCalibrationManualPosition
563 width: parent.width
564 visible: northCalibrationCheckBox.checked && !globals.activeVehicle.coordinate.isValid
565 wrapMode: Text.WordWrap
566 text: qsTr("Vehicle has no Valid positon, please provide it")
567 }
568
569 QGCCheckBox {
570 visible: northCalibrationManualPosition.visible && _gcsPosition.isValid
571 id: useGcsPositionCheckbox
572 text: qsTr("Use GCS position instead")
573 checked: _gcsPosition.isValid
574 }
575 QGCCheckBox {
576 visible: northCalibrationManualPosition.visible && !_gcsPosition.isValid
577 id: useMapPositionCheckbox
578 text: qsTr("Use current map position instead")
579 }
580
581 QGCLabel {
582 width: parent.width
583 visible: useMapPositionCheckbox.checked
584 wrapMode: Text.WordWrap
585 //: %1 is latitude, %2 is longitude
586 text: qsTr("Lat: %1 Lon: %2").arg(_mapPosition.latitude.toFixed(4)).arg(_mapPosition.longitude.toFixed(4))
587 }
588
589 FactTextField {
590 id: northCalLat
591 visible: !useGcsPositionCheckbox.checked && !useMapPositionCheckbox.checked && northCalibrationCheckBox.checked
592 text: "0.00"
593 textColor: isNaN(parseFloat(text)) ? qgcPal.warningText: qgcPal.textFieldText
594 enabled: !useGcsPositionCheckbox.checked
595 }
596 FactTextField {
597 id: northCalLon
598 visible: !useGcsPositionCheckbox.checked && !useMapPositionCheckbox.checked && northCalibrationCheckBox.checked
599 text: "0.00"
600 textColor: isNaN(parseFloat(text)) ? qgcPal.warningText: qgcPal.textFieldText
601 enabled: !useGcsPositionCheckbox.checked
602 }
603
604 }
605 }
606 }
607 }
608
609 QGCPopupDialogFactory {
610 id: compassMotDialogFactory
611
612 dialogComponent: compassMotDialogComponent
613 }
614
615 Component {
616 id: compassMotDialogComponent
617
618 QGCPopupDialog {
619 title: qsTr("Compass Motor Interference Calibration")
620 buttons: Dialog.Cancel | Dialog.Ok
621
622 onAccepted: controller.calibrateMotorInterference()
623
624 Column {
625 width: 40 * ScreenTools.defaultFontPixelWidth
626 spacing: ScreenTools.defaultFontPixelHeight
627
628 QGCLabel {
629 anchors.left: parent.left
630 anchors.right: parent.right
631 wrapMode: Text.WordWrap
632 text: qsTr("This is recommended for vehicles that have only an internal compass and on vehicles where there is significant interference on the compass from the motors, power wires, etc. ") +
633 qsTr("CompassMot only works well if you have a battery current monitor because the magnetic interference is linear with current drawn. ") +
634 qsTr("It is technically possible to set-up CompassMot using throttle but this is not recommended.")
635 }
636
637 QGCLabel {
638 anchors.left: parent.left
639 anchors.right: parent.right
640 wrapMode: Text.WordWrap
641 text: qsTr("Disconnect your props, flip them over and rotate them one position around the frame. ") +
642 qsTr("In this configuration they should push the copter down into the ground when the throttle is raised.")
643 }
644
645 QGCLabel {
646 anchors.left: parent.left
647 anchors.right: parent.right
648 wrapMode: Text.WordWrap
649 text: qsTr("Secure the copter (perhaps with tape) so that it does not move.")
650 }
651
652 QGCLabel {
653 anchors.left: parent.left
654 anchors.right: parent.right
655 wrapMode: Text.WordWrap
656 text: qsTr("Turn on your transmitter and keep throttle at zero.")
657 }
658
659 QGCLabel {
660 anchors.left: parent.left
661 anchors.right: parent.right
662 wrapMode: Text.WordWrap
663 text: qsTr("Click Ok to start CompassMot calibration.")
664 }
665 }
666 }
667 }
668
669 QGCFlickable {
670 id: buttonFlickable
671 anchors.left: parent.left
672 anchors.top: parent.top
673 anchors.bottom: parent.bottom
674 width: _buttonWidth
675 contentHeight: nextCancelColumn.y + nextCancelColumn.height + _margins
676
677 // Calibration button column - Calibratin buttons are kept in a separate column from Next/Cancel buttons
678 // so we can enable/disable them all as a group
679 Column {
680 id: buttonColumn
681 spacing: _margins
682 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
683
684 IndicatorButton {
685 objectName: "sensorsSetup_calibrateAccel"
686 width: _buttonWidth
687 text: qsTr("Accelerometer")
688 indicatorGreen: !accelCalNeeded
689
690 onClicked: function () {
691 showOrientationsDialog(_calTypeAccel);
692 showSimpleAccelCalOption();
693 }
694 }
695
696 IndicatorButton {
697 objectName: "sensorsSetup_calibrateCompass"
698 width: _buttonWidth
699 text: qsTr("Compass")
700 indicatorGreen: !compassCalNeeded
701
702 onClicked: {
703 if (controller.accelSetupNeeded) {
704 QGroundControl.showMessageDialog(sensorsPage, qsTr("Calibrate Compass"), qsTr("Accelerometer must be calibrated prior to Compass."))
705 } else {
706 showOrientationsDialog(_calTypeCompass)
707 }
708 }
709 }
710
711 QGCButton {
712 width: _buttonWidth
713 text: _levelHorizonText
714
715 readonly property string _levelHorizonText: qsTr("Level Horizon")
716
717 onClicked: {
718 if (controller.accelSetupNeeded) {
719 QGroundControl.showMessageDialog(sensorsPage, _levelHorizonText, qsTr("Accelerometer must be calibrated prior to Level Horizon."))
720 } else {
721 QGroundControl.showMessageDialog(sensorsPage, _levelHorizonText,
722 qsTr("To level the horizon you need to place the vehicle in its level flight position and press Ok."),
723 Dialog.Cancel | Dialog.Ok,
724 function() { controller.levelHorizon() })
725 }
726 }
727 }
728
729 QGCButton {
730 width: _buttonWidth
731 text: qsTr("Gyro")
732 visible: globals.activeVehicle && (globals.activeVehicle.multiRotor | globals.activeVehicle.rover | globals.activeVehicle.sub)
733 onClicked: QGroundControl.showMessageDialog(sensorsPage, qsTr("Calibrate Gyro"),
734 qsTr("For Gyroscope calibration you will need to place your vehicle on a surface and leave it still.\n\nClick Ok to start calibration."),
735 Dialog.Cancel | Dialog.Ok,
736 function() { controller.calibrateGyro() })
737 }
738
739 QGCButton {
740 width: _buttonWidth
741 text: _calibratePressureText
742 onClicked: QGroundControl.showMessageDialog(sensorsPage, _calibratePressureText,
743 qsTr("Pressure calibration will set the %1 to zero at the current pressure reading. %2").arg(_altText).arg(_helpTextFW),
744 Dialog.Cancel | Dialog.Ok,
745 function() { controller.calibratePressure() })
746
747 readonly property string _altText: globals.activeVehicle.sub ? qsTr("depth") : qsTr("altitude")
748 readonly property string _helpTextFW: globals.activeVehicle.fixedWing ? qsTr("To calibrate the airspeed sensor shield it from the wind. Do not touch the sensor or obstruct any holes during the calibration.") : ""
749 readonly property string _calibratePressureText: globals.activeVehicle.fixedWing ? qsTr("Baro/Airspeed") : qsTr("Pressure")
750 }
751
752 QGCButton {
753 width: _buttonWidth
754 text: qsTr("CompassMot")
755 visible: globals.activeVehicle ? globals.activeVehicle.supports.motorInterference : false
756 onClicked: compassMotDialogFactory.open()
757 }
758
759 QGCButton {
760 width: _buttonWidth
761 text: qsTr("Sensor Settings")
762 onClicked: showOrientationsDialog(_calTypeSet)
763 }
764 } // Column - Cal Buttons
765
766 Column {
767 id: nextCancelColumn
768 anchors.topMargin: buttonColumn.spacing
769 anchors.top: buttonColumn.bottom
770 anchors.left: buttonColumn.left
771 spacing: buttonColumn.spacing
772
773 QGCButton {
774 id: nextButton
775 objectName: "sensorsSetup_nextButton"
776 width: _buttonWidth
777 text: qsTr("Next")
778 enabled: false
779 onClicked: controller.nextClicked()
780 }
781
782 QGCButton {
783 id: cancelButton
784 objectName: "sensorsSetup_cancelButton"
785 width: _buttonWidth
786 text: qsTr("Cancel")
787 enabled: false
788 onClicked: controller.cancelCalibration()
789 }
790 }
791 } // QGCFlickable - buttons
792
793 /// Right column - cal area
794 Column {
795 anchors.leftMargin: _margins
796 anchors.top: parent.top
797 anchors.bottom: parent.bottom
798 anchors.left: buttonFlickable.right
799 anchors.right: parent.right
800
801 ProgressBar {
802 id: progressBar
803 objectName: "sensorsSetup_progressBar"
804 anchors.left: parent.left
805 anchors.right: parent.right
806 }
807
808 Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer
809
810 Item {
811 id: centerPanel
812 width: parent.width
813 height: parent.height - y
814
815 TextArea {
816 id: statusTextArea
817 anchors.fill: parent
818 readOnly: true
819 text: statusTextAreaDefaultText
820 color: qgcPal.text
821 background: Rectangle { color: qgcPal.windowShade }
822 }
823
824 Rectangle {
825 id: orientationCalArea
826 anchors.fill: parent
827 visible: controller.showOrientationCalArea
828 color: qgcPal.windowShade
829
830 QGCLabel {
831 id: orientationCalAreaHelpText
832 anchors.margins: ScreenTools.defaultFontPixelWidth
833 anchors.top: orientationCalArea.top
834 anchors.left: orientationCalArea.left
835 width: parent.width
836 wrapMode: Text.WordWrap
837 font.pointSize: ScreenTools.mediumFontPointSize
838 }
839
840 Flow {
841 anchors.topMargin: ScreenTools.defaultFontPixelWidth
842 anchors.top: orientationCalAreaHelpText.bottom
843 anchors.bottom: parent.bottom
844 anchors.left: parent.left
845 anchors.right: parent.right
846 spacing: ScreenTools.defaultFontPixelWidth
847
848 property real indicatorWidth: (width / 3) - (spacing * 2)
849 property real indicatorHeight: (height / 2) - spacing
850
851 VehicleRotationCal {
852 objectName: "sensorsCal_downSide"
853 width: parent.indicatorWidth
854 height: parent.indicatorHeight
855 visible: controller.orientationCalDownSideVisible
856 calState: sideCalState(controller.orientationCalDownSideDone, controller.orientationCalDownSideInProgress)
857 calInProgressText: controller.orientationCalDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
858 imageSource: "qrc:///qmlimages/VehicleDown.png"
859 }
860 VehicleRotationCal {
861 objectName: "sensorsCal_leftSide"
862 width: parent.indicatorWidth
863 height: parent.indicatorHeight
864 visible: controller.orientationCalLeftSideVisible
865 calState: sideCalState(controller.orientationCalLeftSideDone, controller.orientationCalLeftSideInProgress)
866 calInProgressText: controller.orientationCalLeftSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
867 imageSource: "qrc:///qmlimages/VehicleLeft.png"
868 }
869 VehicleRotationCal {
870 objectName: "sensorsCal_rightSide"
871 width: parent.indicatorWidth
872 height: parent.indicatorHeight
873 visible: controller.orientationCalRightSideVisible
874 calState: sideCalState(controller.orientationCalRightSideDone, controller.orientationCalRightSideInProgress)
875 calInProgressText: controller.orientationCalRightSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
876 imageSource: "qrc:///qmlimages/VehicleRight.png"
877 }
878 VehicleRotationCal {
879 objectName: "sensorsCal_noseDownSide"
880 width: parent.indicatorWidth
881 height: parent.indicatorHeight
882 visible: controller.orientationCalNoseDownSideVisible
883 calState: sideCalState(controller.orientationCalNoseDownSideDone, controller.orientationCalNoseDownSideInProgress)
884 calInProgressText: controller.orientationCalNoseDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
885 imageSource: "qrc:///qmlimages/VehicleNoseDown.png"
886 }
887 VehicleRotationCal {
888 objectName: "sensorsCal_tailDownSide"
889 width: parent.indicatorWidth
890 height: parent.indicatorHeight
891 visible: controller.orientationCalTailDownSideVisible
892 calState: sideCalState(controller.orientationCalTailDownSideDone, controller.orientationCalTailDownSideInProgress)
893 calInProgressText: controller.orientationCalTailDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
894 imageSource: "qrc:///qmlimages/VehicleTailDown.png"
895 }
896 VehicleRotationCal {
897 objectName: "sensorsCal_upsideDownSide"
898 width: parent.indicatorWidth
899 height: parent.indicatorHeight
900 visible: controller.orientationCalUpsideDownSideVisible
901 calState: sideCalState(controller.orientationCalUpsideDownSideDone, controller.orientationCalUpsideDownSideInProgress)
902 calInProgressText: controller.orientationCalUpsideDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
903 imageSource: "qrc:///qmlimages/VehicleUpsideDown.png"
904 }
905 }
906 }
907 } // Item - Cal display area
908 } // Column - cal display
909 } // Row
910 } // Component - sensorsPageComponent
911} // SetupPage