-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMANUAL.py
67 lines (48 loc) · 1.48 KB
/
MANUAL.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import asyncio
from mavsdk import System
from mavsdk.offboard import (OffboardError, VelocityNedYaw,VelocityBodyYawspeed)
"""
make sure the drone is already in AIR
"""
TIME=5 #sec
async def map_exec(i,drone):
if(i<0):
await drone.offboard.stop()
elif(i==0):
PACK=[0,0,0,0]
elif(i==1):
PACK=[2,0,0,0]
elif(i==2):
PACK=[0,2.0,0,0]
elif(i==3):
PACK=[0,0,2,0]
elif(i==4):
PACK=[0,0,0,10]
elif(i==5):
PACK=[-2,0,0,0]
elif(i==6):
PACK=[0,-2,0,0]
elif(i==7):
PACK=[0,0,-2,0]
elif(i==8):
PACK=[0,0,0,-10]
pack=PACK
await drone.offboard.set_velocity_body(VelocityBodyYawspeed(float(pack[0]), float(pack[1]), float(pack[2]), float(pack[3])))
async def change_2_offboard(drone):
await drone.connect()
async for health in drone.telemetry.health():
if health.is_global_position_ok and health.is_home_position_ok:
# print("-- Global position estimate OK")
break
await drone.action.arm()
# make sure its already in air
await drone.offboard.set_velocity_ned(VelocityNedYaw(0.0, 0.0, 0.0, 0.0))
await drone.offboard.start()
#mark your mode
return
async def manual(i, drone):
# i=int(input("input_for _manual"))
await map_exec(i,drone)
# print("lol")
# asyncio.run(c())
# asyncio.run(a())