QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SensorsVehicleModel.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick3D
3
4/// A simple model of the vehicle for the calibration stage. The top is blue, the underside grey and the nose orange so the
5/// side it is on can be told at a glance. The vehicle's nose points along -z and its right wing along +x.
6Node {
7 id: root
8
9 /// "multiRotor", "fixedWing", "vtol", "rover" or anything else for a flat board
10 property string kind: "board"
11
12 /// Half the size of the box around the model along x, y and z
13 readonly property var halfSize: {
14 switch (kind) {
15 case "multiRotor":
16 return [112, 16, 112]
17 case "fixedWing":
18 return [110, 17, 105]
19 case "vtol":
20 return [110, 20, 105]
21 case "rover":
22 return [66, 20, 84]
23 }
24 return [60, 6, 40]
25 }
26
27 readonly property color _top: "#3b82f6"
28 readonly property color _under: "#8a8f98"
29 readonly property color _nose: "#f59e0b"
30 readonly property color _dark: "#374151"
31 readonly property color _spinning: Qt.rgba(0.8, 0.85, 0.95, 0.45)
32
33 component Part: Model {
34 property color tint: root._top
35 property bool glass: false
36
37 materials: PrincipledMaterial {
38 baseColor: tint
39 roughness: 0.55
40 alphaMode: glass ? PrincipledMaterial.Blend : PrincipledMaterial.Opaque
41 }
42 }
43
44 Node {
45 visible: root.kind === "multiRotor"
46
47 Part { source: "#Cube"; position: Qt.vector3d(0, 3, 0); scale: Qt.vector3d(0.6, 0.1, 0.6) }
48 Part { source: "#Cube"; position: Qt.vector3d(0, -5, 0); scale: Qt.vector3d(0.6, 0.06, 0.6); tint: root._under }
49 Part { source: "#Cube"; position: Qt.vector3d(0, 3, -38); scale: Qt.vector3d(0.22, 0.1, 0.14); tint: root._nose }
50 Part { source: "#Cube"; position: Qt.vector3d(0, 0, 0); eulerRotation.y: 45; scale: Qt.vector3d(1.9, 0.06, 0.1); tint: root._under }
51 Part { source: "#Cube"; position: Qt.vector3d(0, 0, 0); eulerRotation.y: -45; scale: Qt.vector3d(1.9, 0.06, 0.1); tint: root._under }
52
53 Repeater3D {
54 model: 4
55
56 Node {
57 required property int index
58 position: Qt.vector3d((index & 1 ? 1 : -1) * 67, 4, (index & 2 ? 1 : -1) * 67)
59
60 Part { source: "#Cylinder"; scale: Qt.vector3d(0.36, 0.16, 0.36); tint: root._dark }
61 Part { source: "#Cylinder"; position: Qt.vector3d(0, 9, 0); scale: Qt.vector3d(0.9, 0.01, 0.9); tint: root._spinning; glass: true }
62 }
63 }
64 }
65
66 Node {
67 visible: root.kind === "fixedWing" || root.kind === "vtol"
68
69 Part { source: "#Cylinder"; eulerRotation.x: 90; scale: Qt.vector3d(0.28, 2, 0.28) }
70 Part { source: "#Sphere"; position: Qt.vector3d(0, 0, -100); scale: Qt.vector3d(0.28, 0.28, 0.28); tint: root._nose }
71 Part { source: "#Cube"; position: Qt.vector3d(0, 2, -10); scale: Qt.vector3d(2.2, 0.04, 0.4) }
72 Part { source: "#Cube"; position: Qt.vector3d(0, -1, -10); scale: Qt.vector3d(2.2, 0.02, 0.4); tint: root._under }
73 Part { source: "#Cube"; position: Qt.vector3d(0, 2, 90); scale: Qt.vector3d(0.8, 0.03, 0.22) }
74 Part { source: "#Cube"; position: Qt.vector3d(0, 10, 92); scale: Qt.vector3d(0.03, 0.2, 0.26) }
75 }
76
77 Node {
78 visible: root.kind === "vtol"
79
80 Repeater3D {
81 model: 2
82
83 Node {
84 required property int index
85 position: Qt.vector3d((index === 0 ? -1 : 1) * 50, 0, 20)
86
87 Part { source: "#Cube"; scale: Qt.vector3d(0.06, 0.05, 1.5); tint: root._under }
88 Part { source: "#Cylinder"; position: Qt.vector3d(0, 6, -75); scale: Qt.vector3d(0.56, 0.01, 0.56); tint: root._spinning; glass: true }
89 Part { source: "#Cylinder"; position: Qt.vector3d(0, 6, 75); scale: Qt.vector3d(0.56, 0.01, 0.56); tint: root._spinning; glass: true }
90 }
91 }
92 }
93
94 Node {
95 visible: root.kind === "rover"
96 y: 8
97
98 Part { source: "#Cube"; position: Qt.vector3d(0, 6, 0); scale: Qt.vector3d(0.9, 0.1, 1.6) }
99 Part { source: "#Cube"; position: Qt.vector3d(0, -4, 0); scale: Qt.vector3d(0.9, 0.12, 1.6); tint: root._under }
100 Part { source: "#Cube"; position: Qt.vector3d(0, 2, -82); scale: Qt.vector3d(0.5, 0.12, 0.04); tint: root._nose }
101
102 Repeater3D {
103 model: 4
104
105 Part {
106 required property int index
107 source: "#Cylinder"
108 eulerRotation.z: 90
109 position: Qt.vector3d((index & 1 ? 1 : -1) * 52, -6, (index & 2 ? 1 : -1) * 55)
110 scale: Qt.vector3d(0.44, 0.14, 0.44)
111 tint: root._dark
112 }
113 }
114 }
115
116 Node {
117 visible: root.kind !== "multiRotor" && root.kind !== "fixedWing" && root.kind !== "vtol" && root.kind !== "rover"
118
119 Part { source: "#Cube"; position: Qt.vector3d(0, 2, 0); scale: Qt.vector3d(1.2, 0.06, 0.8) }
120 Part { source: "#Cube"; position: Qt.vector3d(0, -3, 0); scale: Qt.vector3d(1.2, 0.04, 0.8); tint: root._under }
121 Part { source: "#Cube"; position: Qt.vector3d(0, 6, 4); scale: Qt.vector3d(0.3, 0.05, 0.3); tint: root._dark }
122 Part { source: "#Cube"; position: Qt.vector3d(0, 3, -34); scale: Qt.vector3d(0.3, 0.04, 0.1); tint: root._nose }
123 }
124}