Skip to content

Commit 74178f0

Browse files
authored
Merge pull request #440 from mavlink/pr-add-import-example
examples: add QGC mission import example
2 parents edd21f4 + 84c2af3 commit 74178f0

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

examples/example-mission.plan

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"fileType": "Plan",
3+
"geoFence": {
4+
"circles": [
5+
],
6+
"polygons": [
7+
],
8+
"version": 2
9+
},
10+
"groundStation": "QGroundControl",
11+
"mission": {
12+
"cruiseSpeed": 15,
13+
"firmwareType": 12,
14+
"globalPlanAltitudeMode": 1,
15+
"hoverSpeed": 5,
16+
"items": [
17+
{
18+
"AMSLAltAboveTerrain": null,
19+
"Altitude": 50,
20+
"AltitudeMode": 1,
21+
"autoContinue": true,
22+
"command": 22,
23+
"doJumpId": 1,
24+
"frame": 3,
25+
"params": [
26+
0,
27+
0,
28+
0,
29+
null,
30+
47.397742,
31+
8.5455939,
32+
50
33+
],
34+
"type": "SimpleItem"
35+
},
36+
{
37+
"AMSLAltAboveTerrain": null,
38+
"Altitude": 50,
39+
"AltitudeMode": 1,
40+
"autoContinue": true,
41+
"command": 16,
42+
"doJumpId": 2,
43+
"frame": 3,
44+
"params": [
45+
0,
46+
0,
47+
0,
48+
null,
49+
47.39822664479198,
50+
8.545560383312846,
51+
50
52+
],
53+
"type": "SimpleItem"
54+
},
55+
{
56+
"AMSLAltAboveTerrain": null,
57+
"Altitude": 50,
58+
"AltitudeMode": 1,
59+
"autoContinue": true,
60+
"command": 16,
61+
"doJumpId": 3,
62+
"frame": 3,
63+
"params": [
64+
0,
65+
0,
66+
0,
67+
null,
68+
47.398249311957585,
69+
8.544924206259822,
70+
50
71+
],
72+
"type": "SimpleItem"
73+
},
74+
{
75+
"AMSLAltAboveTerrain": null,
76+
"Altitude": 50,
77+
"AltitudeMode": 1,
78+
"autoContinue": true,
79+
"command": 16,
80+
"doJumpId": 4,
81+
"frame": 3,
82+
"params": [
83+
0,
84+
0,
85+
0,
86+
null,
87+
47.397741626132294,
88+
8.544924213007533,
89+
50
90+
],
91+
"type": "SimpleItem"
92+
},
93+
{
94+
"autoContinue": true,
95+
"command": 20,
96+
"doJumpId": 5,
97+
"frame": 2,
98+
"params": [
99+
0,
100+
0,
101+
0,
102+
0,
103+
0,
104+
0,
105+
0
106+
],
107+
"type": "SimpleItem"
108+
}
109+
],
110+
"plannedHomePosition": [
111+
47.397742,
112+
8.5455939,
113+
488.787199104001
114+
],
115+
"vehicleType": 2,
116+
"version": 2
117+
},
118+
"rallyPoints": {
119+
"points": [
120+
],
121+
"version": 2
122+
},
123+
"version": 1
124+
}

examples/mission_import.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
3+
import asyncio
4+
5+
from mavsdk import System
6+
import mavsdk.mission_raw
7+
8+
9+
async def run():
10+
drone = System()
11+
await drone.connect(system_address="udp://:14540")
12+
13+
print("Waiting for drone to connect...")
14+
async for state in drone.core.connection_state():
15+
if state.is_connected:
16+
print("Drone discovered!")
17+
break
18+
19+
mission_import_data = await drone.mission_raw.import_qgroundcontrol_mission("example-mission.plan")
20+
print(f"{len(mission_import_data.mission_items)} mission items imported")
21+
await drone.mission_raw.upload_mission(mission_import_data.mission_items)
22+
print("Mission uploaded")
23+
24+
25+
26+
if __name__ == "__main__":
27+
loop = asyncio.get_event_loop()
28+
loop.run_until_complete(run())

0 commit comments

Comments
 (0)