5import QGroundControl.Controls
7import "PX4SensorsPose.js" as Pose
9/// The vehicle in 3D on the side given. When the side changes it tips once, by the shortest turn, onto the new side. While
10/// rotating it then turns about the vertical. When live it follows roll, pitch and heading instead.
14 property string side: "level"
15 property bool rotating: false
16 /// "multiRotor", "fixedWing", "vtol", "rover" or anything else for a flat board
17 property string vehicleKind: ""
18 property bool live: false
19 /// Degrees, used when live
21 property real pitch: 0
22 property real heading: 0
24 // When live the vehicle stays put and the ground is below the furthest it can reach in any attitude
25 readonly property real _ground: live ? Math.hypot(vehicleModel.halfSize[0], vehicleModel.halfSize[1], vehicleModel.halfSize[2]) + 4 :
26 Math.max(vehicleModel.halfSize[0], vehicleModel.halfSize[1], vehicleModel.halfSize[2])
28 property var _from: Pose.sidePose("level")
29 property var _to: Pose.sidePose("level")
30 property real _swing: 1
31 property var _pose: Pose.slerp(_from, _to, _swing)
32 readonly property var _shownPose: live ? Pose.attitudePose(roll, pitch, heading) : _pose
37 _to = Pose.tipTarget(_from, side)
38 swingAnimation.restart()
41 Component.onCompleted: {
42 _from = Pose.sidePose(side)
46 QGCPalette { id: qgcPal }
55 easing.type: Easing.InOutCubic
60 property: "eulerRotation.y"
64 loops: Animation.Infinite
65 running: control.rotating && control._swing >= 1
68 spin.eulerRotation.y = 0
73 environment: SceneEnvironment {
74 backgroundMode: SceneEnvironment.Transparent
75 antialiasingMode: SceneEnvironment.MSAA
76 antialiasingQuality: SceneEnvironment.High
79 // Further back when live, to fit the wider disc and the vehicle in any attitude
81 position: control.live ? Qt.vector3d(0, 300, 859) : Qt.vector3d(0, 185, 560)
87 eulerRotation: Qt.vector3d(-45, -30, 0)
92 eulerRotation: Qt.vector3d(30, 150, 0)
97 y: control.live ? 20 : 0
100 // When live the disc is wider, so the north arrow on its rim stays clear of the vehicle
103 y: -control._ground - 1
104 scale: control.live ? Qt.vector3d(3.4, 0.01, 3.4) : Qt.vector3d(2.4, 0.01, 2.4)
105 materials: PrincipledMaterial {
106 baseColor: qgcPal.borderSubtle
111 // Points north, heading 0, which the live pose turns the nose (-z) towards. Sits on top of the disc, which has a
112 // radius of 170 when live. The cone's base is at its origin, so its tip, 36 further on, is on the rim.
114 visible: control.live
119 scale: Qt.vector3d(0.28, 0.36, 0.01)
120 materials: PrincipledMaterial {
121 baseColor: qgcPal.colorRed
122 lighting: PrincipledMaterial.NoLighting
129 SensorsVehicleModel {
131 kind: control.vehicleKind
132 rotation: Qt.quaternion(control._shownPose[0], control._shownPose[1], control._shownPose[2], control._shownPose[3])
133 y: control.live ? 0 : Pose.restHeight(control._shownPose, halfSize) - control._ground