dwalker-uk / TelloEduSwarmSearch

A Python library for interfacing with the Ryze Tello Edu, including swarm and search behaviours.
MIT License
25 stars 24 forks source link

Tello Edu: Swarm & Search

The Tello Edu

After coming across the Tello Edu in Jan 2019, it seemed to offer something very new to the small drone market. Being designed for education, it had a few key features:

Note that the Tello Edu is different from the original Tello - the two key differences are noted in the following section.

Background & Motivation

This project is a replacement library for the Tello Edu, based on the official Python SDK here: https://github.com/TelloSDK/Multi-Tello-Formation

The motivations for creating this new project, rather than simply using or updating the official Multi-Tello-Formation project were:

There are some recommendations at the end of this README about improvements I'd suggest for further development. I don't plan to continue those developments myself, but welcome others to fork this project to do so.

Configuration / Setup

Only two non-standard Python libraries are required - netifaces and netaddr. These are available for Windows, Mac and Linux. Otherwise this project is self-contained.

Out of the box, each Tello and Tello Edu is configured with its own WiFi network, to which you connect in order to control them. However, the Tello Edu can also be made to connect to any other WiFi Network - a pre-requisite for any swarm behaviour. Once configured, the Tello Edu will always connect to this WiFi Network, until it is reset (by turning on then holding power button for 5-10secs).

To make a Tello Edu connect to a WiFi Network, connect to the Tello (initially by connecting to its own WiFi network) then run the following:

from fly_tello import FlyTello
with FlyTello(['XXX']) as fly:
    fly.set_ap_wifi(ssid='MY_SSID', password='MY_PASSWORD')

The above code initialises FlyTello, and then sets the SSID and Password you supply. You can get the Serial Number for your Tello from a tiny sticker inside the battery compartment, but by using 'XXX' here FlyTello will print the Serial Number to the Console anyway. You should usually provide the Serial Number when initialising FlyTello, but it's not essential here because there's only one.

Project Structure

There are three key files in the project:

FlyTello

Using FlyTello provides the easiest route to flying one or more Tellos. A simple demonstration would require the following code:

from fly_tello import FlyTello      # Import FlyTello

my_tellos = list()
my_tellos.append('0TQDFCAABBCCDD')  # Replace with your Tello Serial Number
my_tellos.append('0TQDFCAABBCCEE')  # Replace with your Tello Serial Number

with FlyTello(my_tellos) as fly:    # Use FlyTello as a Context Manager to ensure safe landing in case of any errors
    fly.takeoff()                   # Single command for all Tellos to take-off
    fly.forward(50)                 # Single command for all Tellos to fly forward by 50cm
    with fly.sync_these():          # Keep the following commands in-sync, even with different commands for each Tello
        fly.left(30, tello=1)       # Tell just Tello1 to fly left
        fly.right(30, tello=2)      # At the same time, Tello2 will fly right
    fly.flip(direction='forward')   # Flips are easy to perform via the Tello SDK
    fly.land()                      # Finally, land

It is suggested to browse through fly_tello.py for full details of the available methods which you can use - all are fully commented and explained in the code. A few worth mentioning however include:

FlyTello also provides a simple method of programming individual behaviours, which allow each Tello to behave and follow its own independent set of instructions completely independently from any other Tello. For full details read the comments in fly_tello.py, but key extracts from an example of this are also shown below:

# independent() is used to package up the FlyTello commands for the independent phase of the flight
def independent(tello, pad):
    found = fly.search_spiral(dist=50, spirals=2, height=100, speed=100, pad=pad, tello=tello)
    if found:
        print('[Search]Tello %d Found the Mission Pad!' % tello)
        fly.land(tello=tello)

with FlyTello(my_tellos) as fly:
    with fly.individual_behaviours():
        # individual_behaviours() is a Context Manager to ensure separate threads are setup and managed for each Tello's
        # own behaviour, as defined in the independent() function above.
        # run_individual() actually initiates the behaviour for a single Tello - in this case both searching, but each
        # is searching for a different Mission Pad ('m1' vs 'm2').
        fly.run_individual(independent, tello_num=1, pad_id='m1')
        fly.run_individual(independent, tello_num=2, pad_id='m2')

Demos

Two demo videos are provided on YouTube, showing the capabilities of Tello Edu with this library.

Limitations

There are some limitations of what can be done with this project and the Tello Edu:

Recommendations

The project as it is currently is enough to fly one or more Tello Edu drones via a simple yet sophisticated set of controls. Expanding its capabilities is easy, with layers of modules which expose increasingly more detailed / low-level functionality. I'd suggest adding or changing: