Drone.Mission (ex_drone v0.1.0)

View Source

Mission DSL for scripting drone command sequences.

A mission is an ordered list of commands that can be validated and replayed against a drone or simulator.

Example

mission =
  Drone.Mission.new()
  |> Drone.Mission.sdk_mode()
  |> Drone.Mission.takeoff()
  |> Drone.Mission.hover(seconds: 3)
  |> Drone.Mission.move(:up, 40)
  |> Drone.Mission.move(:forward, 100)
  |> Drone.Mission.rotate(:cw, 90)
  |> Drone.Mission.land()

Drone.Mission.run(mission, drone)

Summary

Functions

Returns the list of commands in the mission in execution order.

Adds an emergency stop command to the mission.

Adds a flip command to the mission.

Adds a hover command to the mission.

Adds a land command to the mission.

Returns the number of commands in the mission.

Adds a movement command to the mission.

Creates a new empty mission.

Adds a query command to the mission.

Adds a rotation command to the mission.

Runs a mission against a drone process.

Adds an SDK mode activation command to the mission.

Adds a speed setting command to the mission.

Adds a stop command to the mission.

Adds a takeoff command to the mission.

Types

t()

@type t() :: %Drone.Mission{commands: [Drone.Command.t()], name: String.t() | nil}

Functions

commands(mission)

@spec commands(t()) :: [Drone.Command.t()]

Returns the list of commands in the mission in execution order.

emergency(mission)

@spec emergency(t()) :: t()

Adds an emergency stop command to the mission.

flip(mission, direction)

@spec flip(t(), Drone.Command.flip_direction()) :: t()

Adds a flip command to the mission.

hover(mission, opts \\ [])

@spec hover(
  t(),
  keyword()
) :: t()

Adds a hover command to the mission.

land(mission)

@spec land(t()) :: t()

Adds a land command to the mission.

length(mission)

@spec length(t()) :: non_neg_integer()

Returns the number of commands in the mission.

move(mission, direction, distance)

@spec move(t(), Drone.Command.direction(), pos_integer()) :: t()

Adds a movement command to the mission.

new(opts \\ [])

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

Creates a new empty mission.

query(mission, type)

@spec query(t(), Drone.Command.query_type()) :: t()

Adds a query command to the mission.

rotate(mission, direction, degrees)

@spec rotate(t(), Drone.Command.rotation(), pos_integer()) :: t()

Adds a rotation command to the mission.

run(mission, drone_name)

@spec run(t(), atom()) :: {:ok, [term()]} | {:error, Drone.Command.t(), term()}

Runs a mission against a drone process.

Each command is sent sequentially. If any command fails, the mission stops and returns the error.

Returns {:ok, results} with a list of results for each command, or {:error, command, reason} with the failing command and error.

sdk_mode(mission)

@spec sdk_mode(t()) :: t()

Adds an SDK mode activation command to the mission.

speed(mission, speed)

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

Adds a speed setting command to the mission.

stop(mission)

@spec stop(t()) :: t()

Adds a stop command to the mission.

takeoff(mission)

@spec takeoff(t()) :: t()

Adds a takeoff command to the mission.