Drone. Adapters. Crazyflie
(ex_drone v0.3.0)
View Source
Crazyflie 2.x adapter over Crazyradio (or an in-process mock transport).
Implements Drone.Adapter. Prefer connecting through Drone.connect/2
rather than calling this module directly.
Supported configuration (v0.3.0)
- Crazyflie 2.1 / 2.1+ with a documented CRTP protocol version
- Crazyradio PA / Crazyradio 2.0 via a pluggable USB backend
- High-level position commands with a positioning system (
:flow,:lighthouse,:loco) - One Crazyflie per adapter process
Connection options
| Option | Type | Default | Meaning |
|---|---|---|---|
:uri | String.t() | "mock://ready" | Link URI (mock://… or radio://…) |
:transport | module() | from URI | Override transport module |
:usb_backend | module() | USB.Unavailable | Required for radio:// |
:positioning | atom() | :flow | Positioning system label |
:default_height_cm | pos_integer() | 50 | Takeoff height in centimeters |
:default_speed_cm_s | pos_integer() | 50 | Horizontal move speed |
Connection
{:ok, drone} =
Drone.connect(:crazyflie,
name: :cf_1,
uri: "mock://ready",
positioning: :flow,
default_height_cm: 50
)
:ok = Drone.connect_sdk(drone)connect_sdk/1 is a documented no-op that succeeds for mission compatibility.
Real radio URIs require usb_backend: YourUSBModule implementing
Drone.Adapters.Crazyflie.USB.
Deferred
BLE, direct Crazyflie USB flight control, raw attitude setpoints, trajectory upload, parameter editing, firmware flashing, and multi-Crazyflie swarms.
Summary
Types
Crazyflie adapter state held by Drone.Vehicle.
Functions
Returns Crazyflie capability metadata for the connected state.
Executes a normalized Drone.Command over CRTP.
Opens a Crazyflie link and returns initial adapter state.
Closes the CRTP session and releases the transport.
Returns a telemetry snapshot for the vehicle safety / state machine.
Types
@type t() :: %Drone.Adapters.Crazyflie{ armed: boolean(), battery: integer() | nil, capabilities: Drone.Adapter.Capabilities.t() | nil, default_height_cm: integer() | nil, default_speed_cm_s: integer() | nil, estimator_ready: boolean() | nil, firmware: String.t() | nil, flying: boolean(), last_error: term() | nil, link_quality: integer() | nil, mode: atom(), move_speed_cm_s: integer() | nil, positioning: atom() | nil, protocol_version: integer() | nil, serial_number: String.t() | nil, session: Drone.Adapters.Crazyflie.Session.t() | nil, telemetry_at: integer() | nil, uri: String.t() | nil, x: integer(), y: integer(), yaw: integer(), z: integer() }
Crazyflie adapter state held by Drone.Vehicle.
| Field | Type | Meaning |
|---|---|---|
:session | Drone.Adapters.Crazyflie.Session.t() | Open CRTP session |
:uri | String.t() | Connection URI used at open |
:positioning | atom() | :flow, :lighthouse, :loco, … |
:default_height_cm | integer() | Takeoff target height (cm) |
:default_speed_cm_s | integer() | Initial move speed (cm/s) |
:move_speed_cm_s | integer() | Current move speed (updated by :speed) |
:protocol_version | integer() | nil | Negotiated CRTP protocol version |
:capabilities | Drone.Adapter.Capabilities.t() | Advertised capabilities |
:mode | atom() | :idle, :sdk_mode, :flying, :emergency |
:flying | boolean() | Whether a takeoff is considered active |
:armed | boolean() | Supervisor arm state |
:x, :y, :z | integer() | Estimated position in centimeters |
:yaw | integer() | Yaw in degrees |
:battery | integer() | Battery percent 0..100 |
:estimator_ready | boolean() | Positioning estimator readiness |
:link_quality | integer() | Link quality percent (best-effort) |
:telemetry_at | integer() | nil | Monotonic ms of last telemetry touch |
:firmware | String.t() | Firmware label when known |
:last_error | term() | nil | Most recent link/command error |
Example
%Drone.Adapters.Crazyflie{
uri: "mock://ready",
positioning: :flow,
default_height_cm: 50,
mode: :flying,
flying: true,
z: 50,
battery: 95,
estimator_ready: true,
protocol_version: 8
}
Functions
Returns Crazyflie capability metadata for the connected state.
Parameters
Returns
Drone.Adapter.Capabilities.t() (includes :requires_estimator, :link).
Examples
caps = Drone.Adapters.Crazyflie.capabilities(state)
:fire_and_forget = caps.maneuver_completion
Executes a normalized Drone.Command over CRTP.
Supported types include :sdk_mode (no-op success), :takeoff, :land,
:emergency, :move, :rotate, :stop, :hover, :speed, and :query.
:flip returns {:error, :unsupported_command, state}.
Takeoff arms the supervisor, then sends high-level TAKEOFF_2. Land and
emergency use commander/supervisor packets. Moves and rotates use relative
GO_TO_2 with unit conversion via Units.
Parameters
state(t/0) — current adapter statecommand(Drone.Command.t()) — command from the vehicle pipeline
Returns
{:ok, reply, t()}—replyis usually:okor a query value{:error, reason, t()}— readiness, link, or unsupported command
Examples
{:ok, :ok, state} =
Drone.Adapters.Crazyflie.command(state, Drone.Command.takeoff())
{:ok, pct, state} =
Drone.Adapters.Crazyflie.command(
state,
Drone.Command.query(:battery)
)
Opens a Crazyflie link and returns initial adapter state.
Resolves a transport via Transport.resolve/1, runs the CRTP handshake
through Session.connect/2, and seeds telemetry via optional
c:Transport.telemetry/1.
Closes the CRTP session and releases the transport.
Parameters
state(t/0) — final adapter state
Returns
Always :ok.
Examples
:ok = Drone.Adapters.Crazyflie.disconnect(state)
Returns a telemetry snapshot for the vehicle safety / state machine.
Transport-reported readiness fields are synced via optional
c:Transport.telemetry/1. Pose (x/y/z/yaw) is maintained by the
adapter from commanded moves.