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 property double pose_z: (finiteOr((vehicle ? vehicle.altitudeRelative.value : 0), 0) + altitudeBias) * 10
25 property double roll: vehicle ? finiteOr(vehicle.roll.value, 0) : 0
26 property var vehicle
27
28 rotation: Quaternion.fromEulerAngles(Qt.vector3d(0, 0, (90 - body.heading)))
29
30 Behavior on rotation {
31 QuaternionAnimation {
32 duration: _angleAnimationDuration
33 easing.amplitude: 3.0
34 easing.period: 2.0
35 easing.type: Easing.Linear
36 }
37 }
38
39 Viewer3DGeoCoordinateType {
40 id: geo2Enu
41
42 coordinate: vehicle ? vehicle.coordinate : QtPositioning.coordinate(0, 0, 0)
43 gpsRef: body.gpsRef
44 }
45
46 Node {
47 id: labelText
48
49 eulerRotation.x: 90
50 position.x: -10
51 position.z: 30
52
53 QGCLabel {
54 color: "red"
55 font.pixelSize: 25
56 text: vehicle ? Number(vehicle.id) : ""
57 }
58 }
59
60 position: Qt.vector3d(body.pose_x, body.pose_y, body.pose_z)
61
62 Behavior on position {
63 Vector3dAnimation {
64 duration: _poseAnimationDuration
65 easing.type: Easing.Linear
66 }
67 }
68
69 Node {
70 id: rollPitchRotationNode
71
72 rotation: Quaternion.fromEulerAngles(Qt.vector3d(body.roll, -body.pitch, 0))
73
74 Behavior on rotation {
75 QuaternionAnimation {
76 duration: _angleAnimationDuration
77 easing.amplitude: 3.0
78 easing.period: 2.0
79 easing.type: Easing.Linear
80 }
81 }
82
83 Node {
84 eulerRotation {
85 x: 90
86 }
87
88 Node {
89 id: innerNode
90
91 eulerRotation: Qt.vector3d(0, 90, 0)
92
93 Node {
94 eulerRotation: Qt.vector3d(0, 45, 0)
95 position: Qt.vector3d(-640, -360, -155)
96
97 // Arms
98 DronePart { meshSource: "Djif450/DroneModel_arm_1/node.mesh"; baseColor: "white"; metalness: 0.2 }
99 DronePart { meshSource: "Djif450/DroneModel_arm_2/node.mesh"; baseColor: "red"; metalness: 0.2 }
100 DronePart { meshSource: "Djif450/DroneModel_arm_3/node.mesh"; baseColor: "red"; metalness: 0.2 }
101 DronePart { meshSource: "Djif450/DroneModel_arm_4/node.mesh"; baseColor: "red"; metalness: 0.2 }
102
103 // Motors
104 DronePart { meshSource: "Djif450/DroneModel_BLDC_1/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
105 DronePart { meshSource: "Djif450/DroneModel_BLDC_2/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
106 DronePart { meshSource: "Djif450/DroneModel_BLDC_3/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
107 DronePart { meshSource: "Djif450/DroneModel_BLDC_4/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
108
109 // Frame
110 DronePart { meshSource: "Djif450/DroneModel_Base_Top_1/node.mesh"; baseColor: "black"; indexOfRefraction: 2.0; metalness: 0.9 }
111 DronePart { meshSource: "Djif450/DroneModel_Base_bottom_1/node.mesh"; baseColor: "gray"; indexOfRefraction: 2.0; metalness: 0.9 }
112
113 // Propellers — counter-rotating pairs
114 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 }
115 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 }
116 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 }
117 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 }
118 }
119 }
120 }
121 }
122}