Coding4Fun Drone posts
- Introduction to DJI Tello
- Analyzing Python samples code from the official SDK
- Drone Hello World ! Takeoff and land
- Tips to connect to Drone WiFi in Windows 10
- Reading data from the Drone, Get battery level
- Sample for real time data read, Get Accelerometer data
- How the drone camera video feed works, using FFMPEG to display the feed
- Open the drone camera video feed using OpenCV
- Performance and OpenCV, measuring FPS
- Detect faces using the drone camera
- Detect a banana and land!
- Flip when a face is detected!
Today I’ll write the equivalent of a Hello World in the drone ecosystem. This is a very complex app which:
- take off the drone
- wait a couple of seconds
- lands the drone
I’ve followed the Python code sample from the SDK and the final code is very complex (see below). And it deserves some remarks
- Line 11. The function recv() run in a separated thread to receive messages from the drone. The thread is started on line 44
- Line 19. The function sendMessage() sends messages to the drone. Important, the messages must be UTF-8 encoded. This took me some time, until I figure it out. This time implements a timeout with 5 second until the response is processed in a separated thread
- Lines 31-41. Connection information and sockets to communicate with the drone
- Line 48. Main code for the app. Start the SDK mode, Wait 5 seconds, send the take off message, and then send the land message. A very simple exception catch is implemented here.
Important: When using the SDK, the 1st command should be “command”, as I did in line 49.
Here is the code:
Here is the app running at 3X speed so you don’t spend all day watching boring drones videos: