-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: add simple mission_raw example
As an example how to set seq and current. Signed-off-by: Julian Oes <[email protected]>
- Loading branch information
Showing
1 changed file
with
58 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,58 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
from mavsdk import System | ||
from mavsdk import mission_raw | ||
|
||
async def px4_connect_drone(): | ||
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("-- Connected to drone!") | ||
return drone | ||
|
||
async def run(): | ||
drone = await px4_connect_drone() | ||
await run_drone(drone) | ||
|
||
async def run_drone(drone): | ||
|
||
mission_items = [] | ||
|
||
mission_items.append(mission_raw.MissionItem( | ||
0, # start seq at 0 | ||
6, | ||
16, | ||
1, # first one is current | ||
1, | ||
0, 10, 0, float('nan'), | ||
int(47.40271757 * 10**7), | ||
int(8.54285027 * 10**7), | ||
30.0, | ||
0 | ||
)) | ||
|
||
mission_items.append(mission_raw.MissionItem( | ||
1, | ||
6, | ||
16, | ||
0, | ||
1, | ||
0, 10, 0, float('nan'), | ||
int(47.40271757 * 10**7), | ||
int(8.54361892 * 10**7), | ||
30.0, | ||
0 | ||
)) | ||
|
||
print("-- Uploading mission") | ||
await drone.mission_raw.upload_mission(mission_items) | ||
print("-- Done") | ||
|
||
|
||
if __name__ == "__main__": | ||
# Run the asyncio loop | ||
asyncio.run(run()) |