Skip to main content

Program a drone with the DroneBlocks Simulator and then deploy to Tello

Project description

DroneBlocksTelloSimulator

Welcome to the DroneBlocks Tello Simulator with Python. If you are looking for the JavaScript version you can check it out here.

The wonderful thing about this library is you can interact with a simulated Tello drone and take the same code and run it with a real Tello drone.

The first thing we recommend you do is set up a virtual environment for your project. This isn't a necessity but it helps keep your project clean.

python3 -m venv venv

or on some systems you may need to use the following:

python -m venv venv

Now that your virtual environment is up and running go ahead and activate it from the root of the project directory.

source venv/bin/activate

on Windows:

.\venv\Scripts\activate

Now install the DroneBlocksTelloSimulator Python package:

pip install DroneBlocksTelloSimulator

Installation is done! Now you need to create your first mission with the DroneBlocks Simulator. You can access the simulator at the link below:

DroneBlocks Simulator Link

You will need configure Chrome to "Allow Insecure Content" for the simulator. This is not a security risk and will only be done for this domain. This will allow the DroneBlocks simulator to receive commands from Python. Follow these steps:

  1. Click on the lock icon next to the web address
  2. Click on "Site settings"
  3. Scroll to the bottom and look for "Insecure content"
  4. Change "Block" to "Allow"
  5. Close the tab and refresh the simulator

You can now move onto programming your first simulated drone mission in Python! Click the button in the top left of the DroneBlocks simulator that says "Get Drone Simulator Key". Copy this unique key to your clipboard as it will be used in your mission code below.

Create a simulated mission using the following code:

from DroneBlocksTelloSimulator.DroneBlocksSimulatorContextManager import DroneBlocksSimulatorContextManager

if __name__ == '__main__':

    sim_key = 'YOUR_SIM_KEY_GOES_HERE'
    distance = 40
    with DroneBlocksSimulatorContextManager(simulator_key=sim_key) as drone:
        drone.takeoff()
        drone.fly_forward(distance, 'in')
        drone.fly_left(distance, 'in')
        drone.fly_backward(distance, 'in')
        drone.fly_right(distance, 'in')
        drone.flip_backward()
        drone.land()

Congrats on your first simulated mission! Now let's run the exact same code on a real Tello. We're assuming you know how to connect to Tello from your computer so go ahead and do that.

Once connected you'll run the exact same code above with one small difference. We've changed the sim_key to None and Python now knows to send the same commands to your real Tello, Tello EDU, or Tello Talent!

from DroneBlocksTelloSimulator.DroneBlocksSimulatorContextManager import DroneBlocksSimulatorContextManager

if __name__ == '__main__':

    sim_key = None
    distance = 40
    with DroneBlocksSimulatorContextManager(simulator_key=sim_key) as drone:
        drone.takeoff()
        drone.fly_forward(distance, 'in')
        drone.fly_left(distance, 'in')
        drone.fly_backward(distance, 'in')
        drone.fly_right(distance, 'in')
        drone.flip_backward()
        drone.land()

Ta-da! Now you've run the same code in both the DroneBlocks simulator and on Tello! Let's take a look at all the commands available to both the Simulator and Tello:

drone.takeoff()
drone.fly_forward(20, 'in')
drone.fly_backward(20, 'in')
drone.fly_left(20, 'in')
drone.fly_right(20, 'in')
drone.fly_up(20, 'in')
drone.fly_down(20, 'in')
drone.fly_to_xyz(10, 20, 30, 'in')
drone.fly_curve(25, 25, 0, 0, 50, 0, 'in')
drone.flip_forward()
drone.flip_backward()
drone.flip_left()
drone.flip_right()
drone.land()

Give it a try and let us know what you think! If you run into any issues please open a bug here.

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

DroneBlocksTelloSimulator-0.0.7.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

DroneBlocksTelloSimulator-0.0.7-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file DroneBlocksTelloSimulator-0.0.7.tar.gz.

File metadata

  • Download URL: DroneBlocksTelloSimulator-0.0.7.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for DroneBlocksTelloSimulator-0.0.7.tar.gz
Algorithm Hash digest
SHA256 fe48e422fed96a22eefe221f694f500b9d058693b5ce696f53c8dc693c774b37
MD5 7f208c9f8df454538c3fd7721a00885d
BLAKE2b-256 6f51e0897df477ca2ec3a2e1f45c40fdda953b0746d963f47a622ab905fa7e28

See more details on using hashes here.

File details

Details for the file DroneBlocksTelloSimulator-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: DroneBlocksTelloSimulator-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for DroneBlocksTelloSimulator-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e86cc477938c234045a42fdfc62131e98c1b4d9f6089d5e64cb3c11c61a154e2
MD5 2b8e1d5c43294ed2ebc0c8be3ca085af
BLAKE2b-256 5300d02a4baf61056c4ba437269cc440faeeec2f5a355c8c86242cf05b383f86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page