Tello программирование на питоне

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Python wrapper for Tello, Tello EDU and RoboMaster TT, support SDK 2.0 and 3.0

harleylara/tello-python

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Tello Drones — Python Wrapper

Banner

  • Support: Tello, Tello EDU, Robomaster TT (partially, functions for the ESP32 open-source controller not implemented)
  • Support: SDK 2.0 and SDK 3.0
  • High level functions
  • Low level SDK commands using send_command()
  • Detection of out-of-range values
  • User-friendly logs
sudo python setup.py install
from tello import Tello import time # create drone object drone = Tello() # Connect drone drone.connect() # takeoff drone.takeoff() # wait 2 secs time.sleep(2) # land drone.land()
Function Description SDK 2.0 SDK 3.0
connect() Initializes the connection to the drone.
takeoff() Auto takeoff.
lan() Auto land.
stream_on() Enables video stream.
stream_off() Disables video stream.
emergency() Stop Motors immediately.
reboot() Reboot the drone.
motor_on() Start the motors at low speed and enter in Motor-On mode
motor_off() Exit Motor-On mode.
throw_and_fly() Launch the drone horizontally within 5s right after executing this function.
move_up(distance) Ascend given distance.
Parameters:
— distance(int) in centimeters from 20 to 500
move_down(distance) Descend given distance.
Parameters:
— distance(int) in centimeters from 20 to 500
move_left(distance) Fly left given distance.
Parameters:
— distance(int) in centimeters from 20 to 500
move_right(distance) Fly right given distance.
Parameters:
— distance(int) in centimeters from 20 to 500
move_forward(distance) Fly forward given distance.
Parameters:
— distance(int) in centimeters from 20 to 500
move_backward(distance) Moves backward given distance.
Parameters:
— distance(int) in centimeters from 20 to 500
rotate_clockwise(angle) Rotates clockwise given angle.
Parameters:
— angle(int) in degrees from 1 to 360
rotate_counterclockwise(angle) Rotates counterclockwise given angle.
Parameters:
— angle(int) in degrees from 1 to 360
flip(direction) Flip given direction.
Parameters:
— direction(str) can be ‘right’ , ‘left’ , ‘forward’ and ‘backward’
go_to(x, y, z, speed) Fly to given coordinates 1 at given speed .
Parameters:
— x(int) from -500 to 500
— y(int) from -500 to 500
— z(int) from -500 to 500
— speed(int) from 10 to 100
joystick_control(roll, pitch, yaw, throttle) Sends joystick control commands.
Parameters:
— roll(int) from -100 to 100
— pitch(int) from -100 to 100
— yaw(int) from -100 to 100
— throttle(int) from -100 to 100

1 coordinate system in relation to the body framw and the nose pointing forward:

Function Description SDK 2.0 SDK 3.0
set_speed(speed) Set the current speed to speed in cm/s
Parameters:
— speed(int) from 10 to 100
set_wifi(ssid, password) Change WiFi name and password
Parameters:
— ssid(str) WiFi name without spaces
— password(str) password to connect WiFi
set_mission_on() Enables mission pad. By default, downward detection is enabled
set_mission_off() Disables mission pad detection.
set_mission_detection(direction) Define Before use, you must use the set_mission_on() to enable the detection function
Parameters:
— direction(str) can be «forward» , «downward» or «both» .
When either forward-looking or downward-looking detection is enabled alone, the detection frequency is 20Hz. If both enabled, detection will be performed alternatively, with a frequency of 10Hz in each direction
set_ap(ssid, password) Switch Tello to «Station mode» and connect to WiFi access point
Parameters:
— ssid(str) WiFi SSID
— password(str) password to connect WiFi
set_wifi_channel(channel) Set the WiFi channel of the open-source controller. (Only for Robotmaster TT hardware)
set_video_port(info, video) Set the ports for pushing state information and video streams. Here, info is the port for pushing state information, and video is the port for pushing video streaming. The range of ports is 1025 to 65535.
Parameters:
— info(str) drone state port
— video(str) video streaming port
set_fps(fps) Set the video stream frame rate.
Parameters:
— fps(str) can be «high» , «middle» , or «low» , indicating 30fps , 15fps , and 5fps , respectively
set_bitrate(bitrate) Set the video stream bit rate.
Parameters:
— bitrate(str) can be ‘auto’ , ‘1’ , ‘2’ , ‘3’ , ‘4’ , ‘5’ indicating 1Mbps , 2MBps , 3Mbps , 4Mbps , and 5Mbps
set_resolution(resolution) Set the video stream resolution.
Parameters:
— resolution(str) can be «high» or «low» , indicating 720P and 480P , respectively
set_video_direction(direction) Switch camera source for video streaming
Parameters:
— direction(str) can be «forward» or «downward»
Function Description Return SDK 2.0 SDK 3.0
get_current_set_speed() Get current set speed (cm/s) (This is not the current speed) in a range from 10 to 100 float
get_battery() Get current battery percentage in a range from 0 to 100 int
get_flight_time() Get motor running time in seconds int
get_wifi_snr() Get Wi-Fi SNR (Signal to Noise Ratio) int
get_sdk_version() Get SDK version. 20 for 2.0 or 30 for 3.0 int
get_serial() Get Tello serial number str
get_hardware() Get hardware type. ‘TELLO’ or ‘RMTT’ (Robomaster TT) str
get_wifi_version() Query the -WiFi version of the open-source controller. (Only applies to ‘Robomaster TT’) str
get_ap() Get the name and password of the current router to be connected. (Only applies to ‘Robomaster TT’) str
get_ssid() Get the current SSID of the drone. (Only applies to ‘Robomaster TT’) str
Function Description Return SDK 2.0 and 3.0
get_pad_id() Get ID of the detected mission pad.
— If the mission pad detection function is not enabled, -2 is returned.
— If the detection function is enabled but no mission pad is detected, -1 is returned
int
get_x()
get_y()
get_z()
Get the x y z coordinates respectively, relative to the detected mission pad, in centimeters.
— If the mission pad detection function is not enabled, -200 is returned.
— If the detection function is enabled but no mission pad is detected, -100 is returned.
int
get_pad_coord() Get list of coordinates in format [x, y, z] of the drone relative to the detected mission pad, in centimeters
— If the mission pad detection function is not enabled, [-200, -200, -200] is returned.
— If the detection function is enabled but no mission pad is detected, [-100, -100, -100] is returned.
list(int)
get_pad_orientation() Get list of angles in format [roll, pitch, yaw] of the drone relative to the detected mission pad, in degrees list(int)
get_pitch() Get pitch angle in degrees (relative to the initial orientation at the moment of turn on the drone) int
get_roll() Get roll angle in degrees (relative to the initial orientation at the moment of turn on the drone) int
get_yaw() Get yaw angle in degrees (relative to the initial orientation at the moment of turn on the drone) int
get_orientation() Get orientation angles in format [roll, pitch, yaw] relative to the initial orientation at the moment of turn on the drone. list(int)
get_speed_x() Get x-axis speed in dm/s *(decimeter per second) int
get_speed_y() Get y-axis speed in dm/s *(decimeter per second) int
get_speed_z() Get z-axis speed in dm/s *(decimeter per second) int
get_speed() Get list of linear velocities in format [vel_x, vel_y, vel_z] *(decimeter per second) list(int)
get_min_temp() Get the minimum temperature of the main board in degrees celsius int
get_max_temp() Get the maximum temperature of the main board in degrees celsius int
get_tof_distance() Get the distance from the bottom of the drone to the ground (using the ToF sensor) in centimeter.
— Measuring range is from 30 to 900 cm
— If the sensor is out of range, it returns 0
int
get_height() Get drone height in cm relative to take-off point int
get_baro() Get height detected by barometer in meters (absolute height) float
get_time() Get motor running time in seconds float
get_acc_x() Get x-axis acceleration cm/s2 float
get_acc_y() Get y-axis acceleration cm/s2 float
get_acc_z() Get z-axis acceleration cm/s2 float
get_acceleration() Get list of accelerations for x y and z in format [acc_x, acc_y, acc_z] cm/s2 list(float)
Function Description SDK 2.0 and 3.0
read_frame() Read last frame from the video streaming
bgr8_to_jpeg(value) Convert from bgr8 to jpeg

Источник

DJITelloPy

DJI Tello drone python interface using the official Tello SDK and Tello EDU SDK. This library has the following features:

  • implementation of all tello commands
  • easily retrieve a video stream
  • receive and parse state packets
  • control a swarm of drones
  • support for python >= 3.6

Install using pip

For Linux distributions with both python2 and python3 (e.g. Debian, Ubuntu, . ) you need to run

Install in developer mode

Using the commands below you can install the repository in an editable way. This allows you to modify the library and use the modified version as if you had installed it regularly.

git clone https://github.com/damiafuentes/DJITelloPy.git cd DJITelloPy pip install -e . 

Usage

API Reference

See djitellopy.readthedocs.io for a full reference of all classes and methods available.

Simple example

In the examples directory there are some code examples. Comments in the examples are mostly in both english and chinese.

Notes

  • If you are using the streamon command and the response is Unknown command means you have to update the Tello firmware. That can be done through the Tello app.
  • Mission pad detection and navigation is only supported by the Tello EDU.
  • Bright environment is necessary for successful use of mission pads.
  • Connecting to an existing wifi network is only supported by the Tello EDU.
  • When connected to an existing wifi network video streaming is not available (TODO: needs confirmation with the new SDK3 port commands)

DJITelloPy in the media and in the wild

Оцените статью