Drone.Safety.Geofence (ex_drone v0.1.0)

View Source

Geofence definitions for restricting drone flight area.

A geofence defines an allowed flight area. Movement commands that would take the drone outside the geofence are rejected by the safety pipeline.

Two geofence shapes are supported:

  • Circle: defined by a center point and radius
  • Polygon: defined by a list of vertices

Coordinates are in centimeters from the launch point.

Summary

Functions

Creates a circular geofence centred at the given point with the given radius.

Checks whether a point is inside the geofence.

Creates a polygon geofence from a list of vertices.

Creates a circular geofence centred at the origin with the given radius.

Types

t()

@type t() :: %Drone.Safety.Geofence{
  center: {integer(), integer()} | nil,
  points: [{integer(), integer()}] | nil,
  radius_cm: pos_integer() | nil,
  type: :circle | :polygon
}

Functions

circle(center, radius_cm)

@spec circle(
  {integer(), integer()},
  pos_integer()
) :: t()

Creates a circular geofence centred at the given point with the given radius.

contains?(arg1, point)

@spec contains?(
  t() | nil,
  {integer(), integer()}
) :: boolean()

Checks whether a point is inside the geofence.

Returns true if the point is inside or on the boundary, false otherwise.

polygon(points)

@spec polygon([{integer(), integer()}]) :: t()

Creates a polygon geofence from a list of vertices.

The polygon must have at least 3 vertices. The last vertex is automatically connected to the first.

radius(radius_cm)

@spec radius(pos_integer()) :: t()

Creates a circular geofence centred at the origin with the given radius.

This is a convenience for defining a radius around the launch point.