diff --git a/examples/example-mission.plan b/examples/example-mission.plan new file mode 100644 index 00000000..b860e00c --- /dev/null +++ b/examples/example-mission.plan @@ -0,0 +1,124 @@ +{ + "fileType": "Plan", + "geoFence": { + "circles": [ + ], + "polygons": [ + ], + "version": 2 + }, + "groundStation": "QGroundControl", + "mission": { + "cruiseSpeed": 15, + "firmwareType": 12, + "globalPlanAltitudeMode": 1, + "hoverSpeed": 5, + "items": [ + { + "AMSLAltAboveTerrain": null, + "Altitude": 50, + "AltitudeMode": 1, + "autoContinue": true, + "command": 22, + "doJumpId": 1, + "frame": 3, + "params": [ + 0, + 0, + 0, + null, + 47.397742, + 8.5455939, + 50 + ], + "type": "SimpleItem" + }, + { + "AMSLAltAboveTerrain": null, + "Altitude": 50, + "AltitudeMode": 1, + "autoContinue": true, + "command": 16, + "doJumpId": 2, + "frame": 3, + "params": [ + 0, + 0, + 0, + null, + 47.39822664479198, + 8.545560383312846, + 50 + ], + "type": "SimpleItem" + }, + { + "AMSLAltAboveTerrain": null, + "Altitude": 50, + "AltitudeMode": 1, + "autoContinue": true, + "command": 16, + "doJumpId": 3, + "frame": 3, + "params": [ + 0, + 0, + 0, + null, + 47.398249311957585, + 8.544924206259822, + 50 + ], + "type": "SimpleItem" + }, + { + "AMSLAltAboveTerrain": null, + "Altitude": 50, + "AltitudeMode": 1, + "autoContinue": true, + "command": 16, + "doJumpId": 4, + "frame": 3, + "params": [ + 0, + 0, + 0, + null, + 47.397741626132294, + 8.544924213007533, + 50 + ], + "type": "SimpleItem" + }, + { + "autoContinue": true, + "command": 20, + "doJumpId": 5, + "frame": 2, + "params": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "type": "SimpleItem" + } + ], + "plannedHomePosition": [ + 47.397742, + 8.5455939, + 488.787199104001 + ], + "vehicleType": 2, + "version": 2 + }, + "rallyPoints": { + "points": [ + ], + "version": 2 + }, + "version": 1 +} diff --git a/examples/mission_import.py b/examples/mission_import.py new file mode 100755 index 00000000..86220df4 --- /dev/null +++ b/examples/mission_import.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import asyncio + +from mavsdk import System +import mavsdk.mission_raw + + +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("Drone discovered!") + break + + mission_import_data = await drone.mission_raw.import_qgroundcontrol_mission("example-mission.plan") + print(f"{len(mission_import_data.mission_items)} mission items imported") + await drone.mission_raw.upload_mission(mission_import_data.mission_items) + print("Mission uploaded") + + + +if __name__ == "__main__": + loop = asyncio.get_event_loop() + loop.run_until_complete(run())