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