Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DjiTelloSdkOfficialSample1.3.py
#
# Tello Python3 Control Demo
#
# http://www.ryzerobotics.com/
#
# 1/1/2018
#
# official source: https://terra-1-g.djicdn.com/2d4dce68897a46b19fc717f3576b7c6a/Tello%20编程相关/Both/Tello3(1).py
import threading
import socket
import sys
import time
import platform
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:
python_version = str(platform.python_version())
version_init_num = int(python_version.partition('.')[0])
# print (version_init_num)
if version_init_num == 3:
msg = input("");
elif version_init_num == 2:
msg = raw_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment