-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from mavlink/pr-goto
Added goto example
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
from mavsdk import System | ||
|
||
|
||
async def run(): | ||
drone = System() | ||
await drone.connect(system_address="udp://:14540") | ||
|
||
print("Waiting for drone to connect...") | ||
async for state in drone.core.connection_state(): | ||
if state.is_connected: | ||
print(f"Drone discovered with UUID: {state.uuid}") | ||
break | ||
|
||
print("Waiting for drone to have a global position estimate...") | ||
async for health in drone.telemetry.health(): | ||
if health.is_global_position_ok: | ||
print("Global position estimate ok") | ||
break | ||
|
||
print("-- Arming") | ||
await drone.action.arm() | ||
|
||
print("-- Taking off") | ||
await drone.action.takeoff() | ||
|
||
await asyncio.sleep(1) | ||
|
||
await drone.action.goto_location(55.8688660, -4.2851267, 40, 0) | ||
|
||
if __name__ == "__main__": | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(run()) |