~alecgraves/telloc

A minimal C driver for the DJI Tello drone
feba74a8 — Alec Graves 2 years ago
add windows/mac shared lib names
d1b60daa — Alec Graves 2 years ago
update README
81b0bf3e — Alec Graves 2 years ago
updates for python

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~alecgraves/telloc
read/write
git@git.sr.ht:~alecgraves/telloc

You can also use your local clone with git send-email.

#telloc 📸🎮

Cross-platform C library for connecting to the DJI Tello with video support

This was created for the Roadrunner Dynamics Club.

#What? 🕹ī¸ đŸĒŸ 🍏 🐧

This library supports Windows, MacOS and Linux developers who might want to make cool apps to control their fancy flying robot.

#Why? ⁉ī¸

Mostly because existing tello libraries are overly complicated, abandoned, and/or do not work.

This library implements a clean, cross-platform interface for:

  • Sending commands and receiving responses
  • Receiving video data as RBG images
  • Receiving state data as a string

#How? 📖

#Building the library 🚧👷

To build this library, you simply need to install ffmpeg libraries (avformat, avcodec, avutil, swscale).

Windows:

choco install ffmpeg-shared

MacOS:

brew install ffmpeg

Debian/Ubuntu:

sudo apt install libavformat-dev libavcodec-dev libavutil-dev libswscale-dev

Then you should be able to build telloc with CMake.

mkdir build
cd build
cmake ..
make

telloc also comes with a testing program for Windows / Unix-based systems that will attempt to connect to the drone and display information if successful. And Python3 bindings.

mkdir build
cd build
cmake .. -DBUILD_TESTING=True -DBUILD_PYTHON=True
make

#Using the python library 🐍

  1. Build The library with python bindings
mkdir build
cd build
cmake .. -DBUILD_PYTHON=True
make
  1. Copy libtellopy.so into the tellopy folder
cd ..
cp build/libtellopy.so tellopy
  1. Install the python library
cd ..
pip install -e tellopy

#Using the library đŸĒ¨

telloc has a simple interface defined in telloc.h. You can read main.c for example usage.

telloc spawns three threads when you call telloc_connect(...):

  • the state thread - reads state strings and saves them into a buffer.
  • the video thread - reads and decodes video data into an RGB image buffer.
  • the keepalive thread - sends a keepalive query to the drone once per second.

To attempt a connection and spawn threads, you can run

tello_connection *connection = telloc_connect();

When you want to send data to a successful connection, you do:

char *command="streamon";
char *response=malloc(TELLOC_STATE_SIZE);
int ret_command = telloc_send_command(connection, command, strlen(command), response, TELLOC_STATE_SIZE)
printf("Response was %s\n", response);

To read the most recent video frame, you can do the following:

unsigned char *image = malloc(TELLOC_VIDEO_SIZE);
unsigned int image_bytes;
unsigned int image_width;
unsigned int image_height;
int ret_video = telloc_read_image(connection, image, TELLOC_VIDEO_SIZE, &image_bytes, &image_width, &image_height);
if (ret_video==0)
    printf("Image: %d bytes; %d x %d\n", image_bytes, image_width, image_height);

To read the most recent state string, you can do the following:

char *state = malloc(TELLOC_STATE_SIZE);
int ret_state = telloc_read_state(connection, state, TELLOC_STATE_SIZE);
if (ret_state==0)
    printf("State: %s\n", state);

#TODO ✔ī¸

  • [ ] Use static libraries for ffmepg, build static telloc
  • [ ] Save binaries somewhere accessible

#Release Notes 📝

  • 2023-02-18: Improved interface by using opaque struct pointer instead of void*
  • 2023-03-04: Added python bindings

#License Šī¸ ❎

This is licenced under the đŸ’Ĩ ⚖ī¸âš–ī¸ Unlicence ⚖ī¸ 🚀, so basically, do whatever you want but please don't sue me.

see LICENSE.

Do not follow this link