본문 바로가기
Programming/PYTHON

[PYTHON] Drone Tello 제어

Drone Tello 제어






1. 드론의 전원을 켜고 노트북과 드론의 wifi를 연결

2. F5를 눌러 파이썬을 실행 시킨 뒤

3. command 라고 먼저 입력

4. 그 뒤 원하는 제어 단어를 사용하면 드론 Tello를 사용할 수 있습니다.

https://github.com/samdo0812/Android/tree/master/Project/AIDrone


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
68
69
70
71
#
# Tello Python3 Control Demo 
#
# http://www.ryzerobotics.com/
#
# 1/1/2018
 
import threading 
import socket
import sys
import time
 
 
host = ''
port = 9000
locaddr = (host,port) 
 
 
# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 
tello_address = ('192.168.10.1'8889)
 
sock.bind(locaddr)
 
def recv():
    count = 0
    while True: 
        try:
            data, server = sock.recvfrom(1518)
            print(data.decode(encoding="utf-8"))
        except Exception:
            print ('\nExit . . .\n')
            break
 
 
print ('\r\n\r\nTello Python3 Demo.\r\n')
 
print ('Tello: command takeoff land flip forward back left right \r\n       up down cw ccw speed speed?\r\n')
 
print ('end -- quit demo.\r\n')
 
 
#recvThread create
recvThread = threading.Thread(target=recv)
recvThread.start()
 
while True: 
 
    try:
        msg = input("");
 
        if not msg:
            break  
 
        if 'end' in msg:
            print ('...')
            sock.close()  
            break
 
        # Send data
        msg = msg.encode(encoding="utf-8"
        sent = sock.sendto(msg, tello_address)
    except KeyboardInterrupt:
        print ('\n . . .\n')
        sock.close()  
        break
 
 
 
.