forked from sh-song/vision-based-drone-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanner.py
66 lines (42 loc) · 1.81 KB
/
planner.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
#!/usr/bin/env python3
import asyncio
from mavsdk import System
from mavsdk.offboard import (OffboardError, PositionNedYaw)
class Planner:
def __init__(self, master):
self.data = master.data
def set_desired_status(self, n, e, d, yaw):
self.data['des_n'], self.data['des_e'], self.data['des_d'], self.data['des_yaw'] = n, e, d, yaw
async def run(self, d):
await d.connect()
await asyncio.sleep(3)
while self.data['is_on'] is True:
mission = self.data['mission']
if mission == 'None':
print('Planner: No Mission...')
await d.waiting()
elif mission == 'cctv_test':
print("Planner: Mission CCTV TEST")
await d.cctv_test()
#await asyncio.sleep(5)
elif mission == 'cctv':
print("Planner: Mission CCTV")
await d.cctv()
elif mission == 'land':
print("Planner: Mission Land")
break
elif mission == 'parking':
print("Planner: Mission Parking")
self.data['des_n'] = int(input('des_n: '))
self.data['des_e'] = int(input('des_e: '))
self.data['des_d'] = int(input('des_d: '))
await d.parking()
elif mission == 'manual':
print("Planner: Manual flight mode")
self.set_desired_status(2, 2, 2, 2)
await d.move()
else:
print('Planner: Invalid Mission')
await asyncio.sleep(5)
await d.land()
await asyncio.sleep(3)