Class Drone

Namespace
MavNet.PX4.Vehicles
Assembly
MavNet.PX4.dll

A multirotor vehicle. Currently a thin marker over Vehicle so consumers can pattern-match on type (if (v is Drone)) and so we have a clear extension point for multirotor-specific behaviour later. The mission protocol surface (upload / download / clear / fence / rally) lives on Vehicle since boats, rovers, and planes use the same protocol.

The static ConnectAsync(string, TimeSpan, ILogger<MavlinkConnection>?, ILogger<Vehicle>?, CancellationToken) factory is the one-liner entry point for the common case: parse URI → open MavlinkConnection → wait for first heartbeat → return a Drone that owns the connection.

public sealed class Drone : Vehicle, IAsyncDisposable, IStateObservable<DroneState>, IStateObservable
Inheritance
Drone
Implements
Inherited Members

Methods

ConnectAsync(string, TimeSpan, ILogger<MavlinkConnection>?, ILogger<Vehicle>?, CancellationToken)

One-liner factory for the common case. Opens a UDP MavlinkConnection, waits for the first inbound heartbeat, returns a Drone that owns the connection. Disposing the Drone closes the socket.

public static Task<Drone> ConnectAsync(string connectionString, TimeSpan timeout, ILogger<MavlinkConnection>? connectionLogger = null, ILogger<Vehicle>? vehicleLogger = null, CancellationToken ct = default)

Parameters

connectionString string

URI of the form udp://localBind:localPort?rhost=remote&rport=remotePort. See ConnectionString.

timeout TimeSpan

How long to wait for the first heartbeat before throwing.

connectionLogger ILogger<MavlinkConnection>

Optional logger for the underlying transport.

vehicleLogger ILogger<Vehicle>

Optional logger for the Vehicle layer.

ct CancellationToken

Cancellation token.

Returns

Task<Drone>

Exceptions

TimeoutException

No heartbeat arrived within timeout.

Snapshot()

Capture an immutable snapshot of the current observable state.

public DroneState Snapshot()

Returns

DroneState

SubscribeState(Action<DroneState>, StateRate)

Subscribe to state-change notifications at the given rate. The handler may run on any thread; consumers needing UI-thread marshalling must do it themselves.

public StateSubscription SubscribeState(Action<DroneState> handler, StateRate rate)

Parameters

handler Action<DroneState>

Receives an immutable snapshot on each delivery.

rate StateRate

Delivery rate — see StateRate.

Returns

StateSubscription

A handle whose Dispose() unsubscribes.