Drone.Command (ex_drone v0.1.0)

View Source

Command struct and helpers for drone operations.

Every command sent through the ex_drone pipeline is represented as a Drone.Command struct. This provides a unified representation regardless of which adapter handles the command.

Summary

Functions

Creates an emergency stop command.

Checks if a command is an emergency command.

Creates a flip command.

Creates a hover command.

Creates a land command.

Creates a movement command.

Checks if a command is a movement command.

Creates a new command struct.

Creates a query command.

Checks if a command is a query command.

Checks if a command requires the drone to be flying.

Creates a rotation command.

Checks if a command is a safe (retryable) command.

Creates an SDK mode activation command.

Creates a speed setting command.

Creates a stop command (hover in place).

Creates a takeoff command.

Returns all valid command types.

Types

command_type()

@type command_type() ::
  :sdk_mode
  | :takeoff
  | :land
  | :emergency
  | :move
  | :rotate
  | :flip
  | :hover
  | :speed
  | :stop
  | :query

direction()

@type direction() :: :up | :down | :left | :right | :forward | :back

flip_direction()

@type flip_direction() :: :left | :right | :forward | :back

query_type()

@type query_type() ::
  :battery | :height | :speed | :time | :wifi | :sdk_version | :serial_number

rotation()

@type rotation() :: :cw | :ccw

t()

@type t() :: %Drone.Command{
  args: keyword(),
  raw: String.t() | nil,
  type: command_type()
}

Functions

emergency()

@spec emergency() :: t()

Creates an emergency stop command.

emergency?(arg1)

@spec emergency?(t()) :: boolean()

Checks if a command is an emergency command.

flip(direction)

@spec flip(flip_direction()) :: t()

Creates a flip command.

Direction must be one of: :left, :right, :forward, :back.

hover(seconds)

@spec hover(pos_integer()) :: t()

Creates a hover command.

Seconds must be a positive integer.

land()

@spec land() :: t()

Creates a land command.

move(direction, distance)

@spec move(direction(), pos_integer()) :: t()

Creates a movement command.

Direction must be one of: :up, :down, :left, :right, :forward, :back. Distance must be between 20 and 500 cm.

movement?(arg1)

@spec movement?(t()) :: boolean()

Checks if a command is a movement command.

new(type, args \\ [])

@spec new(
  command_type(),
  keyword()
) :: t()

Creates a new command struct.

query(type)

@spec query(query_type()) :: t()

Creates a query command.

Query type must be one of: :battery, :height, :speed, :time, :wifi, :sdk_version, :serial_number.

query?(arg1)

@spec query?(t()) :: boolean()

Checks if a command is a query command.

requires_flying?(arg1)

@spec requires_flying?(t()) :: boolean()

Checks if a command requires the drone to be flying.

rotate(direction, degrees)

@spec rotate(rotation(), pos_integer()) :: t()

Creates a rotation command.

Direction must be :cw (clockwise) or :ccw (counter-clockwise). Degrees must be between 1 and 3600.

safe_to_retry?(arg1)

@spec safe_to_retry?(t()) :: boolean()

Checks if a command is a safe (retryable) command.

sdk_mode()

@spec sdk_mode() :: t()

Creates an SDK mode activation command.

speed(speed)

@spec speed(pos_integer()) :: t()

Creates a speed setting command.

Speed must be between 10 and 100 cm/s.

stop()

@spec stop() :: t()

Creates a stop command (hover in place).

takeoff()

@spec takeoff() :: t()

Creates a takeoff command.

types()

@spec types() :: [command_type()]

Returns all valid command types.