Posts Flying the Tello Drone from Anywhere
Post
Cancel

Flying the Tello Drone from Anywhere

The client running

The Tello is a fun little quadcopter. It is cheap, and it is equipped with brushed motors, but it is different from the other quadcopters of its range: a decent 720p camera with a good stabilisation (although it is only software), an Intel VPU running a visual positioning system - the chip is so juicy that the drone needs to fly to avoid overheating, which says a lot about how stable it ends up being - a precise range sensor and a barometer.

And the most important feature here: Ryze released an SDK, so a computer can talk to the drone, get the video and the sensors data, and send it commands.

I drive my robots through Vigibot, a low latency interface for robots, so the idea was simple: make the drone one of them. A relay on a Raspberry Pi speaks to the drone on one side and to the Vigibot client on the other, and the Tello becomes completely accessible from the internet.

How it works

The link to the drone uses the protocol of the official Ryze SDK. It is simple to implement, because it is made of string commands sent over UDP, like takeoff or land, plus a stream of “state” packets coming back with the attitude, the battery and the sensors. It is not the optimal choice though, because the smartphone application uses a different (undocumented) protocol with more functionalities - some libraries go the retro-engineering way to talk to the drone.

On the Pi, the main thread stays in sync with the Vigibot frames coming from the serial link. A separate thread takes care of receiving the Tello state packets, a second one sends the Vigibot frames back, and a one second timer takes care of the streamon / streamoff video command. No thread locks are required and the parsing is failproof.

The video is where the Pi 3 shows its limitations: it has to transcode the stream before Vigibot can send it, through processdiffvideo and the h264_omx encoder. A low latency profile at 15 fps and 500 kbit/s to fly comfortably, or a 3 Mbit/s one when the drone is standing still. A Raspberry Pi 4 is worth the upgrade here.

Setting it up

The drone works only in AP mode (the Edu version allows STA mode but it is limited), so you need a dedicated WLAN for the drone. For indoor usage, the internal wifi interface of the Pi is enough, but for better performance or outdoor usage I recommend a wifi USB stick with a high gain antenna (I have a WN722n) or a repeater. A second interface for the internet link - your home connection through an ethernet cable is perfect.

The repository contains the client and the configuration files I use:

  • telloclient.py, the client itself
  • configs/robot.json for the Vigibot client, plus the remote.json and hardware.json to import in the Vigibot interface
  • socat.service, to keep a virtual serial interface available after a reboot

Then pip3 install -r requirement.txt and python3 telloclient.py. Note that sudo is required to write to the virtual interface, or you can run the script in usermode if you change the permissions. If everything is alright, you should see the threads frequencies in the console, around 20 Hz, 10 Hz and 10 Hz.

Demo

The architecture is still under development and the code is a bit messy, some revisions are coming. But it flies:

Youtube demo