A local DJI Tello simulator with a djitellopy-compatible Python API and 3D Pygame renderer.
Project description
DJI Tello Simulator
djitellopy-sim lets you write Python code for a DJI Tello-style drone without
needing a real drone. Your program uses familiar djitellopy method names, and
the simulator shows a 3D drone in a Pygame window.
This project is useful for lessons, clubs, experiments, and practice. It is designed so students can learn movement, loops, functions, coordinates, race gates, and simple drone programming safely on one computer.
Start Here
- New to Python or drones? Read QUICKSTART.md.
- Need to look up every function? Read API_REFERENCE.md.
- Comparing this simulator with the real
djitellopylibrary? Read PARITY.md.
What You Can Do
- Fly a simulated Tello drone in a 3D window.
- Use commands such as
takeoff(),move_forward(100),flip_left(), andland(). - Generate race-gate courses that the drone must fly through in order.
- Show or hide in-view hints for distance, height, and relative gate position.
- Switch between a camera that follows the drone and a zoomed-out course view.
- Time a race from takeoff to landing, including penalties for missed gates or gates flown in the wrong order.
- Simulate the Tello Talent expansion LED and 8 by 8 matrix LED screen.
- Run simple swarm programs with more than one simulated drone.
Installation
Install from PyPI:
python -m pip install djitellopy-sim
Install from this folder while developing the project:
python -m pip install -e .
The package installs its own requirements automatically. It uses pygame-ce,
which provides modern prebuilt wheels for Windows, macOS, and Linux. In Python
code it is still imported as pygame.
Your First Flight
Create a file called first_flight.py:
from djitellopySim import Tello
tello = Tello()
tello.connect()
tello.takeoff()
tello.move_forward(100)
tello.rotate_clockwise(90)
tello.move_forward(100)
tello.flip_back()
tello.land()
Run it:
python first_flight.py
The numbers for movement are centimetres. move_forward(100) means move forward
100 cm, which is 1 metre. Rotation numbers are degrees, so
rotate_clockwise(90) means turn a quarter turn to the right.
Race Gates
Race gates are hoops or arches that the drone should fly through in order. A single command creates a whole course:
from djitellopySim import Tello
tello = Tello()
tello.connect()
tello.setup_race_gates(count=6, course="slalom", seed=7)
tello.set_camera_overview()
tello.set_race_hints(distance=True, height=True, relative=True)
tello.takeoff()
tello.move_forward(250)
tello.land()
print(tello.get_race_time())
Course types are:
lineslalomloopclimbarchesmixedrandom
Race timing starts when the drone takes off and stops when it lands. Missing a gate adds 10 seconds. Flying through a later gate before the correct next gate adds 5 seconds.
Students can ask the simulator for measurements before planning a movement:
print(tello.measure_drone_to_gate(1))
print(tello.measure_gate_to_gate(1, 2))
These measurements include distance and the angle relative to the current forward direction, which helps students decide how far to rotate and move.
Simulator Window Keys
The simulator shows the keymap on screen while it runs.
| Key | What it does |
|---|---|
F |
Follow the drone with the camera |
O |
Show the whole course |
+ |
Zoom in |
- |
Zoom out |
D |
Toggle distance hints |
H |
Toggle height hints |
R |
Toggle relative-position hints |
V |
Toggle the drone forward vector |
Expansion Kit
The simulator can show the Tello Talent expansion light and 8 by 8 matrix LED.
tello.send_expansion_command("led 255 0 0")
tello.send_expansion_command(
"mled " +
"00000000"
"00rrrr00"
"0rppppr0"
"0rppppr0"
"00bbbb00"
"000bb000"
"00000000"
"00000000"
)
The top LED uses red, green, and blue values from 0 to 255. The matrix display
is an 8 by 8 grid. Use 0 for black, r for red, b for blue, and p for
purple. There is no green matrix LED.
Swarms
A swarm is a group of drones controlled together:
from djitellopySim import TelloSwarm
swarm = TelloSwarm.fromFile("ip.txt")
swarm.connect()
swarm.takeoff()
swarm.parallel(lambda i, tello: tello.move_up(50 + i * 20))
swarm.land()
The ip.txt file should contain one simulated drone address per line.
Example Files
test.pyshows a small single-drone flight.testSwarm.pyandtestSwarm2.pyshow swarm flights.raceGatesExample.pyshows race gates, camera modes, and race timing.
Publishing
This repository is set up as a PyPI project. Build locally with:
python -m pip install build twine
python -m build
python -m twine check dist/*
GitHub Actions publishes to PyPI when a v* tag is pushed or a GitHub Release
is published. The workflow is in .github/workflows/publish.yml.
PyPI Trusted Publishing Setup
Use PyPI Trusted Publishing so GitHub Actions can publish without storing a PyPI password or token in GitHub.
- Create or log in to your PyPI account at
https://pypi.org. - Open your PyPI account or project publishing settings.
- Add a GitHub Actions trusted publisher.
- Use these values:
PyPI project name: djitellopy-sim
Owner: <your GitHub username or organization>
Repository name: <this GitHub repository name>
Workflow name: publish.yml
Environment name: pypi
- In GitHub, open this repository and go to
Settings->Environments. - Create an environment named
pypi. - Optional but recommended: require manual approval for the
pypienvironment. - Commit the version you want, push it, then create a GitHub Release or push a
tag such as
v0.2.6.
Important Safety Note
This package is a simulator. It does not fly a real drone. If you later move your code to a real DJI Tello, test carefully, keep people away from the drone, and follow your school's or club's safety rules.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djitellopy_sim-0.2.7.tar.gz.
File metadata
- Download URL: djitellopy_sim-0.2.7.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3ce4b410c5925c2ecc7c624986029d3964d568b91526e32aaa4d64fd613e8df
|
|
| MD5 |
78db0e475e4b5f32bb4e15902420198e
|
|
| BLAKE2b-256 |
ca66dc728d3b6f36edd2653d57e2148954121b1a99148dedcc369b80b23958b6
|
Provenance
The following attestation bundles were made for djitellopy_sim-0.2.7.tar.gz:
Publisher:
publish.yml on MrDaviesKellett/djitellopySim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djitellopy_sim-0.2.7.tar.gz -
Subject digest:
e3ce4b410c5925c2ecc7c624986029d3964d568b91526e32aaa4d64fd613e8df - Sigstore transparency entry: 1462301743
- Sigstore integration time:
-
Permalink:
MrDaviesKellett/djitellopySim@265db34eaee538e12e367b36163aa4b4ba3e452c -
Branch / Tag:
refs/tags/v0.2.7 - Owner: https://github.com/MrDaviesKellett
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@265db34eaee538e12e367b36163aa4b4ba3e452c -
Trigger Event:
push
-
Statement type:
File details
Details for the file djitellopy_sim-0.2.7-py3-none-any.whl.
File metadata
- Download URL: djitellopy_sim-0.2.7-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90741067c9562beed685436a6bdc5bb180f203ffeea2e72ace58b82d61e55345
|
|
| MD5 |
c38749f3db67adba11ad59a55148e195
|
|
| BLAKE2b-256 |
00e210d1aa8ab015ba0fbd3b587b2a3c97efc6deb1184a99c1fc0dc63355da23
|
Provenance
The following attestation bundles were made for djitellopy_sim-0.2.7-py3-none-any.whl:
Publisher:
publish.yml on MrDaviesKellett/djitellopySim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djitellopy_sim-0.2.7-py3-none-any.whl -
Subject digest:
90741067c9562beed685436a6bdc5bb180f203ffeea2e72ace58b82d61e55345 - Sigstore transparency entry: 1462301795
- Sigstore integration time:
-
Permalink:
MrDaviesKellett/djitellopySim@265db34eaee538e12e367b36163aa4b4ba3e452c -
Branch / Tag:
refs/tags/v0.2.7 - Owner: https://github.com/MrDaviesKellett
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@265db34eaee538e12e367b36163aa4b4ba3e452c -
Trigger Event:
push
-
Statement type: