tello_control package#

class tello_control.Experiment(output_path: Union[str, Path])#

Bases: ABC

Abstract class which provides a framework to analyze a session with the tello.

Experiments record the telemetry read from the tello and the commands sent to the tello to CSVs which can be later analyzed.

tello#

The Tello which the experiment is being run with.

log_command_history()#

Write the command history to the experiment output path

log_events()#

Write the event history to the experiment output path

log_results()#

Write the telemetry trace to the experiment output path

abstract main()#

Main loop of the experiment

An experiment is created by overriding this method at minimum

run()#

Run the experiment

Running an experiment entails setting up the experiment, running the main function, and tearing down any created resources.

setUp() bool#

Do all setup related to the experiment.

At a minimum, this method simply connects to the Tello and returns whether or not that connection was successful.

Returns

Whether or not connecting to the tello was successful.

tearDown()#

Destroy any objects created during the experiment.

At a minimum, this method lands the Tello and disconnects from it.

class tello_control.TelemetryPacket(timestamp: float, pitch: int, roll: int, yaw: int, vel_x: int, vel_y: int, vel_z: int, temp_l: int, temp_h: int, flight_dist: float, height: float, battery: int, barometer: float, time: int, accel_x: float, accel_y: float, accel_z: float)#

Bases: object

Container for Tello Telemetry.

All telemetry points are specified in the Tello SDK User Manual

Parameters
  • timestamp – When the Telemetry was recorded.

  • pitch – the pitch angle of the Tello.

  • roll – the roll angle of the Tello.

  • yaw – the yaw angle of the Tello.

  • vel_x – drone velocity in the x direction.

  • vel_y – drone velocity in the y direction.

  • vel_z – drone velocity in the z direction.

  • temp_l – Corresponds to templ from the SDK

  • temp_h – Corresponds to temph from the SDK

  • flight_dist – Corresponds to tof from the SDK.

  • height – drone height

  • battery – drone battery

  • barometer – Corresponds to baro from the SDK.

  • time – flight time

  • accel_x – drone acceleration in the x direction.

  • accel_y – drone acceleration in the y direction.

  • accel_z – drone acceleration in the z direction.

classmethod from_data_str(data: str)#

Constructs a TelemetryPacket from a string sent by the drone.

The format of the telemetry coming from the drone is given in the Tello SDK User Guide.

accel_x: float#
accel_y: float#
accel_z: float#
barometer: float#
battery: int#
flight_dist: float#
height: float#
pitch: int#
roll: int#
temp_h: int#
temp_l: int#
time: int#
timestamp: float#
vel_x: int#
vel_y: int#
vel_z: int#
yaw: int#
class tello_control.Tello(ack_timeout: int = 15)#

Bases: object

The primary interface between the user and the Tello

telem#

A UdpInterface for reading Drone Telemetry.

cmd#

A UdpInterface for sending commands and receiving their responses.

video#

A UdpInterface for receiving video frames.

command_history#

A list of command packets sent to the drone.

event_history#

A list of events and timestamps

connect() bool#

Connect to the Tello

Returns

Whether or not the Tello connection was successful

disconnect()#

Disconnect from the tello

end_video_stream()#

Stop the video stream

log_event(event: TelloEvent, level: int = 20)#

Logs an event to the Tello

Parameters
  • event – The event to log

  • level – The logging level. This comes straight from the logging library.

send_command(command: TelloCommand, *args: Any, wait_for_success=False) tuple[bool, Optional[str]]#

Sends a command to the Tello

Parameters
  • command – The TelloCommand to send.

  • *args – Any arguments the Tello command takes.

  • wait_for_success – Whether or not to wait until the Tello response

stream_video()#

Turn on the video stream

property battery: int#

Check the Tello battery

class tello_control.TelloCommand(value)#

Bases: Enum

Support commands to send the Tello

CHECK_BATTERY = 'battery?'#
HOVER = 'stop'#
LAND = 'land'#
RC = 'rc'#
SDK_ON = 'command'#
START_VIDEO = 'streamon'#
STOP_VIDEO = 'streamoff'#
TAKE_OFF = 'takeoff'#
class tello_control.TelloController(tello: Tello, control_frequency: float = 10)#

Bases: ABC

An abstract base class for a Tello controller.

It runs a control step at a specified frequency (default 10 Hz) and processes telemetry for use in the control step.

abstract compute_reference(now_time: float, telemetry: list[tello_control.structs.TelemetryPacket]) Iterable[float]#

Compute the reference that the controller is tracking

A Controller can optionally override this method as an easy way to create the reference signal that the drone is supposed to be tracking.

Parameters
  • now_time – The current time

  • telemetry – A list of Telemetry packets which arrived since the last execution.

Returns

An iterable of floats depending on what the reference represents. The implementation of the step function is responsible for knowing how to use the result of this function.

start()#

Start running the controller.

abstract step(telemetry: list[tello_control.structs.TelemetryPacket]) tuple[float, float, float, float]#

The main control step.

A Controller is created by overriding at least this method. It is run at the frequency the Controller was created with.

Parameters

telemetry – A list of TelemetryPackets which arrived since the last execution.

Returns

A tuple representing the x, y, z, and yaw rc command that should be sent to the Tello

stop()#

Stop running the controller.

This method closes both the telemetry thread and the control thread that it started when the controller began execution.

class tello_control.TelloEvent(value)#

Bases: Enum

Types of Tello Events

DROPPED_PACKET = 'DROPPED_PACKET'#
START_CONTROL = 'START_CONTROL'#
STOP_CONTROL = 'STOP_CONTROL'#

Private Modules#

These classes are used under the hood. You might find them helpful to know about, but you should never need to import them yourself.

tello_control.udp_interface module#

class tello_control.udp_interface.CommandInterface#

Bases: UdpSocketInterface

A UDP socket for sending commands to the Tello and receiving responses

send(packet: CommandPacket)#
class tello_control.udp_interface.TelemetryInterface#

Bases: UdpSocketInterface

A UDP socket which processes Tello telemetry

history#

A list of TelemetryPackets received over the lifetime of the UDP connection

class tello_control.udp_interface.UdpInterface(name: str, ip: str, port: int)#

Bases: ABC

An abstract class for a general UDP Interface

messages#

A Python Queue which stores messages read from the UDP connection

connect() None#

Connect via UDP.

This method also creates a thread to continuously wait for and read data from the UDP socket.

disconnect() None#

Disconnect from UDP

This method stops the thread which is consuming data from the socket.

class tello_control.udp_interface.UdpSocketInterface(name: str, ip: str, port: int)#

Bases: UdpInterface

A UdpInterface representing a traditional UDP socket. Also an abstract class

class tello_control.udp_interface.VideoInterface#

Bases: UdpInterface

A UdpInterface using OpenCV to open a video socket to the Tello

tello_control.utils module#

tello_control.utils.clip_rc(x: float) float#

Clip RC commands to the [-100, 100] range.

Tello RC Commands must have an absolute value less than or equal to 100

Parameters

x – The input to be clipped

Returns

x but clipped to the range [-100, 100].