Skip to content

Commit f03730a

Browse files
Merge pull request mavlink#234 from mavlink/pr-goto
Added goto example
2 parents 7195967 + e76198b commit f03730a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

examples/goto.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
3+
import asyncio
4+
from mavsdk import System
5+
6+
7+
async def run():
8+
drone = System()
9+
await drone.connect(system_address="udp://:14540")
10+
11+
print("Waiting for drone to connect...")
12+
async for state in drone.core.connection_state():
13+
if state.is_connected:
14+
print(f"Drone discovered with UUID: {state.uuid}")
15+
break
16+
17+
print("Waiting for drone to have a global position estimate...")
18+
async for health in drone.telemetry.health():
19+
if health.is_global_position_ok:
20+
print("Global position estimate ok")
21+
break
22+
23+
print("-- Arming")
24+
await drone.action.arm()
25+
26+
print("-- Taking off")
27+
await drone.action.takeoff()
28+
29+
await asyncio.sleep(1)
30+
31+
await drone.action.goto_location(55.8688660, -4.2851267, 40, 0)
32+
33+
if __name__ == "__main__":
34+
loop = asyncio.get_event_loop()
35+
loop.run_until_complete(run())

0 commit comments

Comments
 (0)