-
Notifications
You must be signed in to change notification settings - Fork 6
/
tello_keyboard.py
57 lines (39 loc) · 1.26 KB
/
tello_keyboard.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
###########################################
# Tello simple kyeboard commands
# Author: fvilmos
###########################################
from utils.telloconnect import TelloConnect
import signal
if __name__=="__main__":
# signal handler
def signal_handler(sig, frame):
raise Exception
# capture signals
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
tello = TelloConnect(DEBUG=False)
# wait till connected, than proceed
tello.wait_till_connected()
tello.start_communication()
while True:
try:
k = input()
# exit
if k == 'q':
tello.stop_communication()
break
if k == 't':
tello.send_cmd('takeoff')
if k == 'l':
tello.send_cmd('land')
if k == 'w':
tello.send_cmd('up 20')
if k == 's':
tello.send_cmd('down 20')
if k == 'a':
tello.send_cmd('cw 20')
if k == 'd':
tello.send_cmd('ccw 20')
except Exception:
tello.stop_communication()
break