Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法下载适用于IOS的Tello SDK_Ios - Fatal编程技术网

无法下载适用于IOS的Tello SDK

无法下载适用于IOS的Tello SDK,ios,Ios,任何人都知道如何下载用于iOS的Tello sdk。我已经访问了该链接,但它没有用没有官方的SDK可供Tello下载。您可以找到有关通过网络连接向无人机发送UDP数据包的详细说明。您可以使用GitHub上的Find来帮助您创建到套接字的连接,然后将命令作为ASCII数据传递给Tello func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data, fromAddress address: Data, withFilterCont

任何人都知道如何下载用于iOS的Tello sdk。我已经访问了该链接,但它没有用

没有官方的SDK可供Tello下载。您可以找到有关通过网络连接向无人机发送UDP数据包的详细说明。您可以使用GitHub上的Find来帮助您创建到套接字的连接,然后将命令作为ASCII数据传递给Tello

func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data, fromAddress address: Data, withFilterContext filterContext: Any?) {
let dataString = String(data: data, encoding: String.Encoding.utf8)
if (sock.localPort() == sendPort) {
    print(dataString)
}

if (sock.localPort() == statePort) {
    var telloStateDictionary = [String:Double]()
    let stateArray = dataString?.components(separatedBy: ";")

    for itemState in stateArray! {
        let keyValueArray = itemState.components(separatedBy: ":")
        if (keyValueArray.count == 2) {
            telloStateDictionary[keyValueArray[0]] = Double(keyValueArray[1])
        }
    }
    print(telloStateDictionary)
}
下面是一些示例代码(我今天早些时候自己编写的):

首先,创建套接字、一个带有Tello IP的字符串和一对保存端口号的常量(8889用于向发送命令,如果命令成功,还接收诸如“OK”之类的响应。8890用于每秒多次从无人机接收遥测数据

这将向Tello发送初始“命令”命令:

// Set the delegate and dispatch queue
socket.setDelegate(self)
socket.setDelegateQueue(DispatchQueue.main)

// Send the "command" command to the socket.
do {
    try socket.bind(toPort: sendPort)
    try socket.enableBroadcast(true)
    try socket.beginReceiving()
    socket.send("command".data(using: String.Encoding.utf8)!,
                toHost: sendHost,
                port: sendPort,
                withTimeout: 0,
                tag: 0)
} catch {
    print("Command command sent.")
}
您需要确保该类符合GCDAsyncUdpSocketDelegate

实现从Tello接收数据的委托方法

func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data, fromAddress address: Data, withFilterContext filterContext: Any?) {
let dataString = String(data: data, encoding: String.Encoding.utf8)
if (sock.localPort() == sendPort) {
    print(dataString)
}

if (sock.localPort() == statePort) {
    var telloStateDictionary = [String:Double]()
    let stateArray = dataString?.components(separatedBy: ";")

    for itemState in stateArray! {
        let keyValueArray = itemState.components(separatedBy: ":")
        if (keyValueArray.count == 2) {
            telloStateDictionary[keyValueArray[0]] = Double(keyValueArray[1])
        }
    }
    print(telloStateDictionary)
}
}

设置端口8890以监听遥测:

let receiveSocket = GCDAsyncUdpSocket(delegate: self, delegateQueue: DispatchQueue.main)
    do {
        try receiveSocket.bind(toPort: statePort)
    } catch {
        print("Bind Problem")
    }

    do {
        try receiveSocket.beginReceiving()
    } catch {
        print("Receiving Problem")
    }
运行应用程序。假设你已经手动连接到Tello(就像你用Tello应用程序控制它一样),你应该开始从Tello获取信息

func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data, fromAddress address: Data, withFilterContext filterContext: Any?) {
let dataString = String(data: data, encoding: String.Encoding.utf8)
if (sock.localPort() == sendPort) {
    print(dataString)
}

if (sock.localPort() == statePort) {
    var telloStateDictionary = [String:Double]()
    let stateArray = dataString?.components(separatedBy: ";")

    for itemState in stateArray! {
        let keyValueArray = itemState.components(separatedBy: ":")
        if (keyValueArray.count == 2) {
            telloStateDictionary[keyValueArray[0]] = Double(keyValueArray[1])
        }
    }
    print(telloStateDictionary)
}
要向其发送更多命令,如“起飞”或“cw 360”,您可以执行以下操作:

func sendCommand(command: String) {
    let message = command.data(using: String.Encoding.utf8)
    socket.send(message!, toHost: sendHost, port: sendPort, withTimeout: 2, tag: 0)
}

将命令作为字符串传递,然后将其发送给Tello。

我投票将此问题作为离题题结束,因为这应该问软件供应商自己,与编程无关。您实现了视频流吗?我可以推“streamon”命令发送到UDP端口,并能够侦听来自端口11111的数据。但我在解码它(H264)时遇到问题。我还没有,但本周将查看它。
func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data, fromAddress address: Data, withFilterContext filterContext: Any?) {
let dataString = String(data: data, encoding: String.Encoding.utf8)
if (sock.localPort() == sendPort) {
    print(dataString)
}

if (sock.localPort() == statePort) {
    var telloStateDictionary = [String:Double]()
    let stateArray = dataString?.components(separatedBy: ";")

    for itemState in stateArray! {
        let keyValueArray = itemState.components(separatedBy: ":")
        if (keyValueArray.count == 2) {
            telloStateDictionary[keyValueArray[0]] = Double(keyValueArray[1])
        }
    }
    print(telloStateDictionary)
}