Unable to receive vídeo Stream from tello drone

3.2k views Asked by At

I am writhing a python script in order to communicate to my tello drone via wifi. Once connected with the drone I can send UDP packets to send commands (this works perfectly fine). I want to receive the video stream from the drone via UDP packets arriving at my udp server on port 11111. This is described in the SDK documentation, "https://dl-cdn.ryzerobotics.com/downloads/tello/20180910/Tello%20SDK%20Documentation%20EN_1.3.pdf".


print ('\r\n\r\nTello drone communication tool\r\n')

print("...importing modules...")

import threading 
import socket
import sys
import time
import platform  
import cv2

print("Modules imported")

print("...Initialiasing UDP server to get video stream....")

drone_videostream = cv2.VideoCapture('udp://@0.0.0.0:11111')

print("Server initialised")

# my local adress to receive UDP packets from tello DRONE
host = ''
port = 9000
locaddr = (host,port) 

print("...creation of UDP socket...")
# Create a UDP socket (UDP Portocol to receive and send UDP packets from/to drone)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Got drone port and ip adress from network (explained in official SDK documentation)
tello_address = ('192.168.10.1', 8889)

print("UDP socket created")


sock.bind(locaddr)

width = 320
height = 240


def receiveStream() :
    print("...receiving stream...")
    while True :
        ret, frame = drone_videostream.read()
        img = cv2.resize(frame, (width, height))
        cv2.imshow("LiveStream", frame)
        cv2.waitKey(1)
        drone_videostream.release()
        cv2.destroyAllWindows()
        
   
def receiving():
    while True: 
        try:
            data, server = sock.recvfrom(1518)
            print(data.decode(encoding="utf-8"))
        except Exception:
            print ('\nExit . . .\n')
            break


print ("...initialiazing connection with tello drone...")

message = "command"
message = message.encode(encoding="utf-8") 
sent = sock.sendto(message, tello_address)

print("Connection established")

#create a thread that will excute the receiving() function
receiveThread = threading.Thread(target=receiving)
receiveThread.start()

receiveStreamThread = threading.Thread(target=receiveStream)


while True :
    message = input(str("Enter a command :\r\n"))
    if message == "streamon" :
        message = message.encode(encoding="utf-8") 
        sent = sock.sendto(message, tello_address)
        receiveStreamThread.start()
    else :
        message = message.encode(encoding="utf-8") 
        sent = sock.sendto(message, tello_address)


When I send the "streamon" command to the drone, I am unable to read the sended UDP packets. I get the following error :

error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

This means that the frames are empty, thus, no image received.

Do you know why I dont receive them ?

Thank you very much for your help in advance, Best :)

3

There are 3 answers

0
Polo On BEST ANSWER

The problem on my side was solved as follows, it appear that my antivirus was blocking the incoming video packets from the tello drone. If you have windows defender, turn off public and private network firewalls while you use the tello drone.

0
Prashant Katigar On

Hi Those who are following murtaza workshop , and unable to get the video stream , Use Open CV library version 4.4.0.46, and python interpreter 3.9.0. Try to make sure you use the above specified versions.

0
Dr Yuan Shenghai On

I play with tello a lot recently.

what I saw from you code is you have entered "command" by right the light should turn green. The once you "stream on" the should be a return message. Check this message to see if there is any error.

The only apparent error is video source ID. You did what manually said.

enter image description here

But from my experience, the only IP that I`m able to get the UDP stream is from udp://192.168.10.1:11111

You can check if you can see it by seeing from ffplay udp://192.168.10.1:11111

enter image description here