【问题标题】:Unable to receive vídeo Stream from tello drone无法从 Tello 无人机接收视频流
【发布时间】:2020-10-01 17:24:04
【问题描述】:

我正在扭动一个 python 脚本,以便通过 wifi 与我的 Tello 无人机通信。 与无人机连接后,我可以发送 UDP 数据包来发送命令(这非常好)。 我想通过 UDP 数据包在端口 11111 上到达我的 udp 服务器接收来自无人机的视频流。这在 SDK 文档中进行了描述,“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)


当我向无人机发送“streamon”命令时,我无法读取发送的 UDP 数据包。我收到以下错误:

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

这意味着帧是空的,因此没有接收到图像。

你知道我为什么没有收到吗?

非常感谢您提前提供的帮助, 最好的:)

【问题讨论】:

  • 您需要缩小代码范围以了解发生了什么。可能不是您收到的所有数据包都包含您期望的数据,因此您可能不得不丢弃它们
  • 删除网络防火墙解决了问题。

标签: python sockets udp dji-sdk tello-drone


【解决方案1】:

嗨,那些关注 murtaza 工作坊的人, 并且无法获取视频流, 使用 Open CV 库版本 4.4.0.46 和 python 解释器 3.9.0。 尽量确保您使用上述指定的版本。

【讨论】:

    【解决方案2】:

    我最近经常玩tello。

    我从您的代码中看到的是您已在右侧输入“命令”,指示灯应变为绿色。一旦您“流式传输”应该是返回消息。检查此消息以查看是否有任何错误。

    唯一明显的错误是视频源 ID。你按照手动说的做了。

    但根据我的经验,我能够获取 UDP 流的唯一 IP 来自 udp://192.168.10.1:11111

    可以通过从ffplay udp://192.168.10.1:11111查看来检查是否可以看到

    【讨论】:

      【解决方案3】:

      我这边的问题解决如下,看来我的防病毒软件阻止了来自 Tello 无人机的传入视频数据包。如果您有 Windows Defender,请在使用 Tello 无人机时关闭公共和私有网络防火墙。

      【讨论】:

        猜你喜欢
        • 2021-07-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-31
        • 2016-02-05
        • 1970-01-01
        • 2013-03-20
        相关资源
        最近更新 更多