Skip to content

Commit 7c4b61c

Browse files
authored
Merge pull request #595 from arpitpara/main
Do_orbit Example
2 parents 2d90bf8 + e5e8c6b commit 7c4b61c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

examples/do_orbit.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import asyncio
2+
from mavsdk import System
3+
from mavsdk.action import OrbitYawBehavior
4+
5+
6+
async def run():
7+
drone = System()
8+
await drone.connect(system_address="udp://:14540")
9+
10+
print("Waiting for drone to connect...")
11+
async for state in drone.core.connection_state():
12+
if state.is_connected:
13+
print("Drone discovered!")
14+
break
15+
16+
print("Waiting for drone to have a global position estimate...")
17+
async for health in drone.telemetry.health():
18+
if health.is_global_position_ok and health.is_home_position_ok:
19+
print("-- Global position estimate OK")
20+
break
21+
22+
position = await drone.telemetry.position().__aiter__().__anext__()
23+
orbit_height = position.absolute_altitude_m+10
24+
yaw_behavior = OrbitYawBehavior.HOLD_FRONT_TO_CIRCLE_CENTER
25+
26+
print("-- Arming")
27+
await drone.action.arm()
28+
29+
print("--- Taking Off")
30+
await drone.action.takeoff()
31+
await asyncio.sleep(10)
32+
33+
print('Do orbit at 10m height from the ground')
34+
await drone.action.do_orbit(radius_m=10,
35+
velocity_ms=2,
36+
yaw_behavior=yaw_behavior,
37+
latitude_deg=47.398036222362471,
38+
longitude_deg=8.5450146439425509,
39+
absolute_altitude_m=orbit_height)
40+
await asyncio.sleep(60)
41+
42+
await drone.action.return_to_launch()
43+
print("--- Landing")
44+
45+
if __name__ == "__main__":
46+
asyncio.run(run())

0 commit comments

Comments
 (0)