-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtello_control.py
More file actions
55 lines (45 loc) · 1.73 KB
/
tello_control.py
File metadata and controls
55 lines (45 loc) · 1.73 KB
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
from hand_control import hand_gesture
from tracking import tracking
import time
hand_gesture_info = []
rect_detect = [0, 0, 0, 0]
def moves(tello, frame, simulate: bool = True):
"""
Função que detecta os gestos e movimenta o drone
Args:
tello (TelloZune): Objeto do drone
frame (np.array): Frame da camera do drone
simulate (bool): Não faz com que o drone se movimente, apenas simula. Default: True
Returns:
frame (np.array): Frame da camera do drone
"""
# Obtem a informação e faz a detecção de gestos
hand_gesture_info = hand_gesture(frame)
# Desenha no frame
frame = hand_gesture_info[0]
# Obtém o bounding box da mão
rect_detect = hand_gesture_info[1][0]
# Obtém qual foi o gesto feito
hand_classification = hand_gesture_info[1][2]
old_move = ''
if not simulate:
if hand_classification == 'Takeoff' and hand_classification != old_move:
# Realiza o takeoff se o sinal for um V
tello.takeoff()
old_move = 'Takeoff'
print("dei takeoff")
time.sleep(1)
elif hand_classification == 'Land':
# Realiza o land se o sinal for um L
tello.land()
old_move = 'Land'
print("dei land")
time.sleep(1)
elif hand_classification == 'Tracking' and old_move != "Land":
# Realiza o tracking se o sinal for uma mão aberta
tracking(tello, rect_detect)
elif (hand_classification == 'None' or hand_classification == 'Stop') and old_move != 'Land':
# Para o drone se o sinal for uma mão fechada
tello.send_rc_control(0, 0, 0, 0)
print("PAREI")
return frame