Microservices
The MAVLink protocol defines microservices as:
We also use microservices from MAVLink. You can usually access them from an IClientDevice
like this:
GetMicroservice
returns null
if it fails to find the requested microservice.
Microservices are designed to provide user-friendly abstractions for different parts of the MAVLink protocol. They are fully compatible with other MAVLink devices — for example, you can connect your own FTP client to the autopilot's FTP server and vice versa. We also provide several custom MAVLink services, which are typically built by combining multiple standard microservices.
Available microservices:
Note about the reactive approach (R3 library)
This package was originally developed for our asv-drones desktop application. We chose a reactive approach because it is more efficient and easier to use compared to classic event-based patterns. We initially used Microsoft's Rx (System.Reactive) but later switched to R3.
Reactivity is very similar to events — in fact, it uses events under the hood. Here’s a short introduction to make it easier for you to get started: Use our Get Started guide to experiment with microservices and reactivity.
Most of our services expose data pipes. Clients and servers from Asv.Common have Rx and Tx pipes to receive and send data — similar to microcontrollers with UART interfaces. Asv.Mavlink microservices follow the same principle.
Let’s take a closer look at the heartbeat client:
Get the microservice:
Subscribe to RawHeartbeat and print the MavType:
Dispose of the subscription when it’s no longer needed:
In the example above, we use Subscribe()
from the R3 library to print all heartbeat packets to the console. The code inside the Action
runs every time the ReadOnlyReactiveProperty<HeartbeatPayload?>
changes. You can also use SubscribeAwait()
to run code asynchronously. Each subscription creates unmanaged resources (IDisposable
), so remember to dispose them manually with .Dispose()
— otherwise you may end up with a memory leak.
We hope this guide helps you get started. Feel free to experiment — try subscribing to other reactive properties of the heartbeat client to explore more data.