DJI TelloはUDPでテキストコマンド送れば制御できる

TelloにはDJIの提供する標準のアプリもありますが、Tello自体はテキストコマンドで制御できる、つまり専用のドライバなどは不要、ということで簡単にカスタムアプリができます。

UDP/ポート8889でソケット接続すれば、ドライバ不要でテキストモードでコマンド送信とレスポンス受信ができます。

 

<コマンド一覧>

SDK

The Tello SDK connects to the aircraft through a Wi-Fi UDP port, allowing users to control the drone with text commands

https://alfredo-reyes-montero.gitbook.io/tello-dji/sdk

 

<サンプル>

以下のサンプルプログラムを持ってきて、

https://github.com/dji-sdk/Tello-Python

Python2.7なので一部3形に書き換え必要なので書き換えて、

https://github.com/chateight/tello_python

に置いてあります、Python3への変換(except文とprint文)は機械的にできます。

コマンドはテキストファイル(以下ではcommand.txt)で一番単純であろうコマンドを定義して、

command
takeoff
delay 1
land

最初のcommand文はAPIモードに入る宣言として必要です。

 

<実行結果>

コマンドの引数でコマンドファイル(command.txt)を指定します。

% python tello_test.py command.txt
sending command: command to 192.168.10.1
from ('192.168.10.1', 8889): b'ok'
Done!!! sent command: command to 192.168.10.1
sending command: takeoff to 192.168.10.1
from ('192.168.10.1', 8889): b'ok'
Done!!! sent command: takeoff to 192.168.10.1
delay 1.0
sending command: land to 192.168.10.1
from ('192.168.10.1', 8889): b'ok'
Done!!! sent command: land to 192.168.10.1
Traceback (most recent call last):
  File "/Users/xxxxxx/github/tello_python/tello_test.py", line 28, in 
    out = open('log/' + start_time + '.txt', 'w')
FileNotFoundError: [Errno 2] No such file or directory: 'log/2022-10-26 13:06:37.254305.txt'

ログファイルができてないと言われてますが、それはlogディレクトリ作成してないからで、logディレクトリ作成するときちんとログが取れました。

id: 0
command: command
response: b'ok'
start time: 2022-10-26 14:27:31.283580
end_time: 2022-10-26 14:27:31.309985
duration: 0.026405


id: 1
command: takeoff
response: b'ok'
start time: 2022-10-26 14:27:31.310001
end_time: 2022-10-26 14:27:38.808229
duration: 7.498228


id: 2
command: land
response: b'ok'
start time: 2022-10-26 14:27:39.813307
end_time: 2022-10-26 14:27:42.531767
duration: 2.71846

 

ソケットで接続すれば良いだけなので、言語はPythonに限らず今時の言語ならなんでもつながるということになるので、ライブラリ次第で使い分けでしょう。

例えば、ScratchのTello拡張だと、Node.js使ってソケット接続しています。

TelloEDUモデル(編隊飛行だけでなく)だとクライアントモードでつながるので、クラウドサービス(例えばGoogle TM)を使った画像認識とかもできますね。EDUモード買えばよかった。

 

admin