5import QGroundControl.Controls
6import QGroundControl.FlightMap
8/// Live attitude of the vehicle and the sensors it has, to check the autopilot orientation and the compass against.
9/// devices is PX4SensorsRows.hardwareDevices, deviceName(param) returns the description of a device ID parameter.
13 property var vehicle: null
14 /// "multiRotor", "fixedWing", "vtol", "rover" or anything else for a flat board
15 property string vehicleKind: ""
16 property var devices: []
17 property var deviceName: function (param) { return "" }
19 QGCPalette { id: qgcPal }
21 // Formats after rounding, so a small negative value shows 0 rather than -0. A wrapped heading shows 360 as 0.
22 function _degrees(value, decimals, wrap) {
23 if (!isFinite(value)) {
26 let rounded = Number(value.toFixed(decimals))
27 if (wrap && rounded >= 360) {
33 return rounded.toFixed(decimals) + "°"
37 text: qsTr("Live orientation")
41 // Qt Quick 3D needs a GPU renderer. Without one the attitude indicator is shown instead.
43 objectName: "sensors_attitude"
44 Layout.fillWidth: true
45 Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 12
47 switch (GraphicsInfo.api) {
48 case GraphicsInfo.Unknown:
50 case GraphicsInfo.Software:
51 return attitudeIndicator
62 vehicleKind: control.vehicleKind
63 roll: control.vehicle ? control.vehicle.roll.rawValue : 0
64 pitch: control.vehicle ? control.vehicle.pitch.rawValue : 0
65 heading: control.vehicle ? control.vehicle.heading.rawValue : 0
74 anchors.centerIn: parent
76 vehicle: control.vehicle
82 Layout.fillWidth: true
83 spacing: ScreenTools.defaultFontPixelWidth
87 { caption: qsTr("Roll"), value: control._degrees(control.vehicle ? control.vehicle.roll.rawValue : NaN, 1) },
88 { caption: qsTr("Pitch"), value: control._degrees(control.vehicle ? control.vehicle.pitch.rawValue : NaN, 1) },
89 { caption: qsTr("Heading"), value: control._degrees(control.vehicle ? control.vehicle.heading.rawValue : NaN, 0, true) }
92 // Equal fixed widths and right aligned values, so changing values do not move anything
94 Layout.fillWidth: true
95 Layout.preferredWidth: 1
96 caption: modelData.caption
98 required property var modelData
101 Layout.fillWidth: true
102 horizontalAlignment: Text.AlignRight
103 text: modelData.value
104 font.family: ScreenTools.fixedFontFamily
111 Layout.fillWidth: true
113 color: qgcPal.borderSubtle
114 visible: control.devices.length > 0
118 Layout.fillWidth: true
119 spacing: ScreenTools.defaultFontPixelHeight * 0.25
120 visible: control.devices.length > 0
123 model: control.devices
126 Layout.fillWidth: true
128 required property var modelData
131 Layout.fillWidth: true
132 text: modelData.label
133 color: qgcPal.textSecondary
137 text: control.deviceName(modelData.param)
138 font.family: ScreenTools.fixedFontFamily
145 text: qsTr("Tilt and turn the vehicle: the model should follow. If it moves the wrong way, change the autopilot rotation.")