Fly AI with Tello drone19 Jan 2021
The popularity of drones and the area of their application is becoming greater each year.
In this article I will show how to programmatically control Tello Ryze drone, capture camera video and detect objects using Tensorflow. I have packed the whole solution into docker images (the backend and Web App UI are in separate images) thus you can simply run it.
The project code is available on my github https://github.com/qooba/aidrone You can also use ready docker image: https://hub.docker.com/repository/docker/qooba/aidrone
Before you will continue reading please watch short introduction: https://youtu.be/g8oZ8ltRArY
The application will use two network interfaces. The first will be used by the python backend to connect the the Tello wifi to send the commands and capture video stream. In the backend layer I have used the DJITelloPy library which covers all required tello move commands and video stream capture. To efficiently show the video stream in the browser I have used the WebRTC protocol and aiortc library. Finally I have used the Tensorflow 2.0 object detection with pretrained SSD ResNet50 model.
Using Web interface you can control the Tello movement where you can:
- start video stream
- stop video stream
- takeoff - which starts Tello flight
- rotate left
- rotate right
In addition using draw detection switch you can turn on/off the detection boxes on the captured video stream (however this introduces a delay in the video thus it is turned off by default). Additionally I send the list of detected classes through web sockets which are also displayed.
As mentioned before I have used the pretrained model thus It is good idea to train your own model to get better results for narrower and more specific class of objects.
Finally the whole solution is packed into docker images thus you can simply start it using commands:
docker network create -d bridge app_default docker run --name tello --network app_default --gpus all -d --rm -p 8890:8890 -p 8080:8080 -p 8888:8888 -p 11111:11111/udp qooba/aidrone /bin/bash -c "python3 drone.py" docker run -d --rm --network app_default --name nginx -p 80:80 -p 443:443 qooba/aidrone:front
To use GPU additional nvidia drivers (included in the NVIDIA CUDA Toolkit) are needed.