Skip to content

LucaRitz/tello

Repository files navigation

C++ Tello Lib

The intent of this library is its simplicity to use. The following code section shows a basic setup for one Tello-drone.

#include <tello/logger/logger_interface.hpp>
#include <tello/connection/tello_network.hpp>
#include <tello/tello.hpp>

using tello::LoggerSettings;
using tello::LoggerInterface;
using tello::TelloNetwork;
using tello::Tello;
using tello::Response;

#define TELLO_IP_ADDRESS (ip_address)0xC0A80A01 // 192.168.10.1

int main() {
    // Initialize logging
    LoggerSettings settings {"./log/command_log.log", "./log/video_log.log", "./log/status_log.log"};
    LoggerInterface::initialize(settings);
    
    // Setup connection
    const bool isConnected = TelloNetwork::connect();
    assert(isConnected);
    
    // Create a tello drone object for interaction
    Tello tello(TELLO_IP_ADDRESS);
    
    // Enter command mode.
    future<Response> command_future = tello.command();
    // You don't have to wait for a response.
    // A response is timed-out after 15 seconds.
    command_future.wait();

    // There are some commands, which don't wait to a response
    // The status of the response will be 'UNKNOWN'
    future<Response> rc_future = tello.rc_control(10, -10, 0, 0);
    
    // More commands
    // ...
    
    // At least, the connections have to be closed.
    TelloNetwork::disconnect();
}

Another possibility is the setup of a swarm.

// includes ...
#include <tello/swarm.hpp>
// usings ...

using tello::Swarm;

int main() {
    // setup ...

    // Create tello drones object for interaction
    Tello tello_1(TELLO_IP_ADDRESS_1);
    Tello tello_2(TELLO_IP_ADDRESS_2);
    // ...
    Tello tello_n(TELLO_IP_ADDRESS_n);
     
    // Create a swarm object and add tellos
    Swarm swarm;
    swarm << tello_1 << tello_2 << ... << tello_n;
     
    // Enter command mode
    unordered_map<ip_address, future<Response>> response_futures = swarm.command();
    for(auto& entry : response_futures) {
        entry.second.wait();
    }
    // May repeate command for a single tello if one failed.
     
     
    // More commands and tear down
    // ...   
}

Build

Per default, a static library is built. One can set the option
'TELLO_BUILD_SHARED_LIBS' to ON to build a shared library.
Note: The target 'tello_test' cannot be built with this option on,
because there are some usages, which are not exported (e.g. command_test.cpp).
Use the target 'shared_linking_test' instead.

OS & Compiler

C++ 17

OS

  • Windows

Compiler

  • nmake
  • mingw/g++ 8.1.0 - Windows MSYS2

Third-party libs

Tello SDK 2.0

Send Command & Receive Response

Tello IP: 192.168.10.1 UDP Port (Both): 8889

Listen to: 0.0.0.0

Receive Tello State

Tello IP: 192.168.10.1

Listen to: 0.0.0.0 UDP Port: 8890

Receive Tello Video Stream

Tello IP: 192.168.10.1

Listen to: 0.0.0.0 UDP Port: 11111

Tello Commands

Control Commands

Command Description Possible Response Implemented
command Enter SDK mode. ok / error ✔️
takeoff Auto takeoff. ok / error ✔️
land Auto landing. ok / error ✔️
streamon Enable video stream. ok / error ✔️
streamoff Disable video stream. ok / error ✔️
emergency Stop motors immediately. ok / error ✔️
up "x" Ascend to "x" cm.
x = 20-500
ok / error ✔️
down "x" down "x" Descend to "x" cm.
x = 20-500
ok / error ✔️
left "x" Fly left for "x" cm.
x = 20-500
ok / error ✔️
right "x" Fly right for "x" cm.
x = 20-500
ok / error ✔️
forward "x" Fly forward for "x" cm.
x = 20-500
ok / error ✔️
back "x" Fly backward for "x" cm.
x = 20-500
ok / error ✔️
cw "x" Rotate "x" degrees clockwise.
x = 1-360
ok / error ✔️
ccw "x" Rotate "x" degrees counterclockwise.

x = 1-360
ok / error ✔️
flip "x" Flip in "x" direction.
x = "l" or "r" or "f" or "b"
l = left
r = right
f = forward
b = back
ok / error ✔️
go "x" "y" "z" "speed" Fly to "x" "y" "z" at "speed" (cm/s).
x = -500-500
y = -500-500
z = -500-500
speed = 10-100
Note: "x", "y" and "z" values can't be set between
-20-20 siultaneously.
ok / error
stop Hovers in the air.
Note: works at any time.
ok / error ✔️
curve "x1" "y1" "z1" "x2" "y2"
"z2" "speed"
Fly at a curve according to the two given coordinates
at "speed" (cm/s).
If the arc radius is not within a range of 0.5-10 meters,
it will respond with an error.
x1, x2 = -500-500
y1, y2 = -500-500
z1, z2 = -500-500
speed = 10-60

Note: "x", "y" and "z" values can't be set between
-20-20 siultaneously.
ok / error
go "x" "y" "z" "speed" "mid" Fly to the "x", "y" and "z" coordinates of the Mission
Pad.

mid = m1-m8
x = -500-500
y = -500-500
z = -500-500
speed = 10-100 (cm/s)

Note: "x", "y" and "z" values can't be set between
-20-20 siultaneously.
ok / error
curve "x1" "y1" "z1" "x2" "y2"
"z2" "speed" "mid"
Fly at a curve according to the two given coordinates
of the Mission Pad ID at "speed" (cm/s).
If the arc radius is not within a range of 0.5-10 meters,
it will respond with an error.
x1, x2 = -500-500
y1, y2 = -500-500
z1, z2 = -500-500
speed = 10-60

Note: "x", "y" and "z" values can't be set between
-20-20 siultaneously.
ok / error
jump "x" "y" "z" "speed" "yaw"
"mid1" "mid2"
Fly to coordinates "x", "y" and "z" of Mission Pad 1,
and recognize coordinates 0, 0, "7" of Mission Pad 2
and rotate to the yaw value.
mid = m1-m8
x = -500-500
y = -500-500
z = -500-500
speed = 10-100 (cm/s)

Note: "x", "y" and "z" values can't be set between
-20-20 siultaneously.
ok / error

Set Commands

Command Description Possible Response Implemented
speed "x" Set speed to "x" cm/s.
x = 10-100
ok / error ✔️
rc "a" "b" "c" "d" Set remote controller via four channels.
a = left/right (-100-100)
b = forward/backward (-100-100)
c = up/down (-100-100)
d = yaw (-100-100)
ok / error
wifi "ssid" "pass" Set Wi-Fi password.
ssid = updated Wi-Fi name
pass = updated Wi-Fi password
ok / error
mon Enable mission pad detection (both forward and
downward detection).
ok / error
moff Disable mission pad detection. ok / error
mdirection "x" x = 0 or 1 or 2

0 = Enable downward detection only
1 = Enable forward detection only
2 = Enable both forward and downward detection

Notes:
Perform "mon" command before performing this
command.
The detection frequency is 20 Hz if only the forward
or downward detection is enabled. If both the forward
and downward detection are enabled, the detection
frequency is 10 Hz.
ok / error
ap "ssid" "pass" Set the Tello to station mode, and connect to a
new access point with the access point's ssid and
password.

ssid = updated Wi-Fi name
pass = updated Wi-Fi password
ok / error

Read Commands

Command Description Possible Response Implemented
speed? Obtain current speed (cm/s) x = 10-100 ✔️
battery? Obtain current battery percentage. x = 0-100
time? Obtain current flight time. time
wifi? Obtain Wi-Fi SNR. snr ✔️
sdk? Obtain the Tello SDK version. sdk version
sn? Obtain the Tello serial number. serial number

Tello State

Data string received when the mission pad detection feature is enabled:
"ata string received when the mission pad detection feature is enabled:requency is 10 Hz.I
theof:%d;h:%d;bat:%d;baro:%f;\r\nm"

Data string received when the mission pad detection feature is disabled:
"pitch:%d;roll%d;yaw:%d;vgw:%d;vgy:%d;vgz:%d;templ:%d;temph:%d;tof:%d;h:%d;bat:%d;baro:%.2f;
time:%d;agx:%.2f;agy:%.2f;agz:%.2f;\r\n"

Description
mid = the ID of the Mission Pad detected. If no Mission Pad is detected,
a "-1" message will be reeived instead.
x = the "x" coordinate detected on the Mission Pad. If there is no Mission Pad,
a "0" message will be received instead.
y = the "y" coordinate detected on the Mission Pad. If there is no Mission Pad,
a "0" message will be received instead.
z = the "z" coordinate detected on the Mission Pad. If there is no Mission Pad,
a "0" message will be received instead.
pitch = the degree of the attitude pitch.
roll = the degreee of the attitude roll.
yaw = the degree of the attitude yaw.
vgx = the speed of "x" axis.
vgy = the speed of "y" axis.
vgz = the speed of "z" axis.
templ = the lowest temperature in degree Celsius.
temph = the highest temperature in degree Celsius.
tof = the time of flight distance in cm.
h = the height in cm.
bat = the percentage of the current battery level.
baro = the barometer measurement in cm.
time = the amount of time the motor has been used.
agx = the acceleration of the "x" axis.
agy = the acceleration of the "y" axis.
agz = the acceleration of the "z" axis.