forked from geaxgx/depthai_blazepose
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tello_control.py
50 lines (44 loc) · 1.2 KB
/
tello_control.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
from djitellopy import Tello
import cv2
import time
tello = Tello()
# print(tello)
tello.connect()
# tello.streamon()
frame_read = tello.get_frame_read()
tello.takeoff()
while True:
img = frame_read.frame
cv2.imshow("drone", img)
key = cv2.waitKey(1) & 0xff
if key == 27: # ESC
break
elif key == ord('a'):
tello.send_rc_control(1,0,0,0)
time.sleep(1)
tello.send_rc_control(0,0,0,0)
elif key == ord('a'):
tello.send_rc_control(-1,0,0,0)
time.sleep(1)
tello.send_rc_control(0,0,0,0)
elif key == ord('s'):
tello.send_rc_control(0,-1,0,0)
time.sleep(1)
tello.send_rc_control(0,0,0,0)
elif key == ord('w'):
tello.send_rc_control(0,1,0,0)
time.sleep(1)
tello.send_rc_control(0,0,0,0)
elif key == ord('e'):
tello.rotate_clockwise(30)
elif key == ord('q'):
tello.rotate_counter_clockwise(30)
elif key == ord('r'):
tello.send_rc_control(0,0,1,0)
time.sleep(1)
tello.send_rc_control(0,0,0,0)
elif key == ord('f'):
tello.send_rc_control(0,0,-1,0)
time.sleep(1)
tello.send_rc_control(0,0,0,0)
tello.land()