Drone. Adapters. Tello. Encoder
(ex_drone v0.3.0)
View Source
Encodes Drone.Command structs into Tello UDP command strings.
The Tello SDK uses plain ASCII text commands sent over UDP. This module
converts the structured Drone.Command representation into the wire format
expected by DJI Tello / Tello EDU firmware.
Mapping overview
| Command type | Wire string |
|---|---|
:sdk_mode | "command" |
:takeoff / :land / :emergency / :stop | same atom name as string |
:hover | "stop" |
:move | "forward 50", "up 30", … |
:rotate | "cw 90", "ccw 45" |
:flip | "flip l" / "r" / "f" / "b" |
:speed | "speed 50" |
:query | "battery?", "height?", "sdk?", … |
Examples
"command" = Drone.Adapters.Tello.Encoder.encode(Drone.Command.sdk_mode())
"forward 50" =
Drone.Adapters.Tello.Encoder.encode(Drone.Command.move(:forward, 50))
"battery?" =
Drone.Adapters.Tello.Encoder.encode(Drone.Command.query(:battery))
Summary
Functions
Encodes a normalized command into a Tello SDK ASCII string.
Functions
@spec encode(Drone.Command.t()) :: String.t()
Encodes a normalized command into a Tello SDK ASCII string.
Parameters
command(Drone.Command.t()) — command produced byDrone.Commandhelpers or the vehicle pipeline
Returns
String.t() ready to send with Drone.Adapters.Tello.Connection.send_command/3.
Raises
KeyError when required args (:direction, :distance, :degrees,
:speed, :type) are missing from the command.
Examples
iex> Drone.Adapters.Tello.Encoder.encode(Drone.Command.takeoff())
"takeoff"
iex> Drone.Adapters.Tello.Encoder.encode(Drone.Command.move(:left, 40))
"left 40"
iex> Drone.Adapters.Tello.Encoder.encode(Drone.Command.rotate(:cw, 90))
"cw 90"
iex> Drone.Adapters.Tello.Encoder.encode(Drone.Command.flip(:forward))
"flip f"
iex> Drone.Adapters.Tello.Encoder.encode(Drone.Command.speed(60))
"speed 60"
iex> Drone.Adapters.Tello.Encoder.encode(Drone.Command.hover(3))
"stop"
iex> Drone.Adapters.Tello.Encoder.encode(Drone.Command.query(:sdk_version))
"sdk?"