Class Drone
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
connectionStringstringURI of the form
udp://localBind:localPort?rhost=remote&rport=remotePort. See ConnectionString.timeoutTimeSpanHow long to wait for the first heartbeat before throwing.
connectionLoggerILogger<MavlinkConnection>Optional logger for the underlying transport.
vehicleLoggerILogger<Vehicle>Optional logger for the Vehicle layer.
ctCancellationTokenCancellation token.
Returns
Exceptions
- TimeoutException
No heartbeat arrived within
timeout.
Snapshot()
Capture an immutable snapshot of the current observable state.
public DroneState Snapshot()
Returns
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
handlerAction<DroneState>Receives an immutable snapshot on each delivery.
rateStateRateDelivery rate — see StateRate.
Returns
- StateSubscription
A handle whose Dispose() unsubscribes.