QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
DroneModelDjiF450.qml
Go to the documentation of this file.
1import QtPositioning
2import QtQuick3D
3
4import QGroundControl
5import QGroundControl.Controls
6import QGroundControl.Viewer3D
7
8Node {
9 id: body
10
11 function finiteOr(value, fallback) {
12 return Number.isFinite(value) ? value : fallback;
13 }
14
15 property int _angleAnimationDuration: 100
16 property int _poseAnimationDuration: 200
17 property double altitudeBias: 0
18 property var gpsRef: QtPositioning.coordinate(0, 0, 0)
19 property double heading: vehicle ? finiteOr(vehicle.heading.value, 0) : 0
20 property alias modelScale: innerNode.scale
21 property double pitch: vehicle ? finiteOr(vehicle.pitch.value, 0) : 0
22 property double pose_x: finiteOr(geo2Enu.localCoordinate.x, 0) * 10
23 property double pose_y: finiteOr(geo2Enu.localCoordinate.y, 0) * 10
24 // Scene coordinates are meters - use rawValue since cooked value follows the user's units setting
25 property double pose_z: (finiteOr((vehicle ? vehicle.altitudeRelative.rawValue : 0), 0) + altitudeBias) * 10
26 property double roll: vehicle ? finiteOr(vehicle.roll.value, 0) : 0
27 property var vehicle
28
29 rotation: Quaternion.fromEulerAngles(Qt.vector3d(0, 0, (90 - body.heading)))
30
31 Behavior on rotation {
32 QuaternionAnimation {
33 duration: _angleAnimationDuration
34 easing.amplitude: 3.0
35 easing.period: 2.0
36 easing.type: Easing.Linear
37 }
38 }
39
40 Viewer3DGeoCoordinateType {
41 id: geo2Enu
42
43 coordinate: vehicle ? vehicle.coordinate : QtPositioning.coordinate(0, 0, 0)
44 gpsRef: body.gpsRef
45 }
46
47 Node {
48 id: labelText
49
50 eulerRotation.x: 90
51 position.x: -10
52 position.z: 30
53
54 // Plain Text instead of QGCLabel: QGCLabel sets font.pointSize, which
55 // conflicts with the explicit pixelSize needed for 3D scene scaling.
56 Text {
57 color: "red"
58 font.family: ScreenTools.normalFontFamily
59 font.pixelSize: 25
60 text: vehicle ? Number(vehicle.id) : ""
61 }
62 }
63
64 position: Qt.vector3d(body.pose_x, body.pose_y, body.pose_z)
65
66 Behavior on position {
67 Vector3dAnimation {
68 duration: _poseAnimationDuration
69 easing.type: Easing.Linear
70 }
71 }
72
73 Node {
74 id: rollPitchRotationNode
75
76 rotation: Quaternion.fromEulerAngles(Qt.vector3d(body.roll, -body.pitch, 0))
77
78 Behavior on rotation {
79 QuaternionAnimation {
80 duration: _angleAnimationDuration
81 easing.amplitude: 3.0
82 easing.period: 2.0
83 easing.type: Easing.Linear
84 }
85 }
86
87 Node {
88 eulerRotation {
89 x: 90
90 }
91
92 Node {
93 id: innerNode
94
95 eulerRotation: Qt.vector3d(0, 90, 0)
96
97 Node {
98 eulerRotation: Qt.vector3d(0, 45, 0)
99 position: Qt.vector3d(-640, -360, -155)
100
101 // Arms
102 DronePart { meshSource: "Djif450/DroneModel_arm_1/node.mesh"; baseColor: "white"; metalness: 0.2 }
103 DronePart { meshSource: "Djif450/DroneModel_arm_2/node.mesh"; baseColor: "red"; metalness: 0.2 }
104 DronePart { meshSource: "Djif450/DroneModel_arm_3/node.mesh"; baseColor: "red"; metalness: 0.2 }
105 DronePart { meshSource: "Djif450/DroneModel_arm_4/node.mesh"; baseColor: "red"; metalness: 0.2 }
106
107 // Motors
108 DronePart { meshSource: "Djif450/DroneModel_BLDC_1/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
109 DronePart { meshSource: "Djif450/DroneModel_BLDC_2/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
110 DronePart { meshSource: "Djif450/DroneModel_BLDC_3/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
111 DronePart { meshSource: "Djif450/DroneModel_BLDC_4/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
112
113 // Frame
114 DronePart { meshSource: "Djif450/DroneModel_Base_Top_1/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
115 DronePart { meshSource: "Djif450/DroneModel_Base_bottom_1/node.mesh"; baseColor: "gray"; indexOfRefraction: 2.0; metalness: 0.9 }
116
117 // Propellers — counter-rotating pairs
118 AnimatedPropeller { meshSource: "Djif450/DroneModel_propeller22_1/node.mesh"; pivotPoint: Qt.vector3d(343.50, 404.07, 783.00); rotationTarget: -360; flightMode: vehicle ? (vehicle.armed + vehicle.flying) : 0 }
119 AnimatedPropeller { meshSource: "Djif450/DroneModel_propeller22_2/node.mesh"; pivotPoint: Qt.vector3d(343.42, 404.16, 333.06); rotationTarget: -360; flightMode: vehicle ? (vehicle.armed + vehicle.flying) : 0 }
120 AnimatedPropeller { meshSource: "Djif450/DroneModel_propeller2_2/node.mesh"; pivotPoint: Qt.vector3d(119.51, 402.66, 557.75); rotationTarget: 360; flightMode: vehicle ? (vehicle.armed + vehicle.flying) : 0 }
121 AnimatedPropeller { meshSource: "Djif450/DroneModel_propeller2_7/node.mesh"; pivotPoint: Qt.vector3d(567.97, 404.00, 558.26); rotationTarget: 360; flightMode: vehicle ? (vehicle.armed + vehicle.flying) : 0 }
122 }
123 }
124 }
125 }
126}