Expand description
Β§MAVSpec
Bindings and code-generation toolchain for MAVLink protocol based on MAVInspect.
This library is I/O agnostic and does not provide any abstractions for transferring MAVLink
messages. If you want to communicate with MAVLink devices, use
Mavio for embedded devices and simple tasks or
Maviola for advanced I/O in std environments (for ground
control stations, communication layers, and so on).
MAVSpec is a part of Mavka toolchain
Β§Features
This library provides MAVLink abstractions to work with MAVLink messages and dialects.
It also provides a set of additional tools to work with MAVLink microservices. Basic microservices support involves generation of sub-dialects which include only required entities. For some microservices, like mission, additional utilities are provided.
Β§Rust
All Rust-related bindings can be found in rust module.
This library is mostly focused on Rust bindings. At the moment, we support other languages using specta.
By default, this library pre-builds standard MAVLink dialects. However, when
--no-default-features is set, then you should enable one of the dialects Cargo features as
described below.
Β§Dialects
Standard MAVLink dialect can be bundled with MAVSpec. This can be enabled by the corresponding feature flags.
minimalβ minimal dialect required to expose your presence to other MAVLink devices.standardβ a superset ofminimaldialect, that expected to be used by almost all flight stack.commonβ minimum viable dialect with most of the features, a building block for other future-rich dialects.ardupilotmegaβ feature-full dialect used by ArduPilot. In most cases this dialect is the go-to choice if you want to recognize almost all MAVLink messages used by existing flight stacks.allβ meta-dialect which includes all other standard dialects including those which were created for testing purposes. It is guaranteed that namespaces of the dialects inallfamily do not collide.- Other dialects from MAVLink XML definitions:
asluav,avssuas,csairlink,cubepilot,development,icarous,matrixpilot,paparazzi,ualberta,uavionix. These do not includepython_array_testandtestdialects which should be either generated manually or as a part ofallmeta-dialect.
To bundle MAVLink entities for Rust, you should enable rust-dialects feature flag.
For example:
use mavspec::rust::dialects::common as dialect;
use dialect::{Common, messages::Heartbeat};
let message = Heartbeat {
/* construct a message */
};
// Use message with dialect enum:
let dialect_message = Common::Heartbeat(message);
// Dialect message:
match dialect_message {
Common::Heartbeat(msg) => {
/* process heartbeat */
}
/* process other messages */
};Β§Default dialect
When standard MAVLink dialects are used and at least minimal Cargo feature is enabled, this
library exposes default_dialect and
DefaultDialect entities that allow to access the most feature-rich
enabled MAVLink dialect.
The sequence of default dialects is the following (in the order of the increased completeness):
minimalβ enabled bydlct-minimalfeature flagstandardβ enabled bydlct-standardfeature flagcommonβ enabled bydlct-commonfeature flagardupilotmegaβ enabled bydlct-ardupilotmegafeature flagallβ enabled bydlct-allfeature flag
Β§Microservices
MAVSpec allows to generate additional structures tailored for MAVLink microservices. Each microservice is a subdialect with only those messages and enums which are necessary.
Microservices are generated only for a default dialect and available as rust::microservices.
To generate microservice subdialects use the corresponding msrv-* feature flag.
MAVSpec also provides additional utils to work with MAVLink microservices. These tools can be
enabled by msrv-utils-* feature flags and available in rust::microservices::utils module.
msrv-utils-* are considered unstable for now! Use unstable feature flag to enable them.
Β§Metadata
You may want to add additional metadata to MAVLink entities such as a name of enum or the list
of its variants. In that case you may enable metadata feature flag.
use mavspec::rust::default_dialect::enums::MavCmd;
println!("Enum name: {}", MavCmd::name());
for entry in MavCmd::entries() {
println!("Entry {:?} has a value {}", entry, entry.value());
}Β§Message definitions
It is possible to bundle message definitions generated by MAVInspect
into definitions module. This can be useful for ground control stations that require to present the
user with the descriptions of MAVLink entities.
To enable definitions bundling use definitions feature flag.
For example:
let protocol = mavspec::definitions::protocol();
let mav_cmd = protocol
.default_dialect()
.unwrap()
.get_enum_by_name("MAV_CMD")
.unwrap();
println!("MAV_CMD\n: {}", mav_cmd.description());Message definitions available only with std feature enabled. Otherwise, this will cause build
to fail.
Β§Generation
This library can generate custom dialects from XML definitions.
Check rust::gen for details.
Β§Fingerprints
MAVInspect may skip code re-generation if dialects havenβt changed. It uses 64-bit CRC fingerprint to monitor
changes. Set fingerprints feature flag to enable this behavior.
This feature is useful for reducing build time during development and CI runs. Make sure that your releases are clean and do not depend on fingerprints.
Β§Caveats
The API is straightforward and generally stable, however, incorrect use of certain features may lead to issues during deployment and development.
Β§Binary Size
For small applications that use only a small subset of messages, avoid using dialect enums as they contain all message variants. Instead, decode messages directly from frames:
This will help compiler to throw away unnecessary pieces of code.
Additionally, you may use microservices to reduce API surface you are
interacting with.
Β§Unstable Features
Certain features are considered unstable and available only when unstable feature flag is
enabled. Unstable features are marked with β and are may be changed in futures
versions.
Β§Incompatible Features
- Specta requires
stdfeature to be enabled. definitionsrequiresstdfeature to be enabled.
Β§Feature Flags
In most of the cases you will be interested in dialect features, msrv-*, msrv-utils-*
feature families, and alloc / std target specification. However, a more fine-grained control
may be required.
Β§Generic features
-
defaultβ Default features (nothing is enabled) -
allocβ Enableallocsupport -
stdβ Enable standard library support -
metadataβ Add additional metadata to MAVLink entities. -
unstableβ β οΈ Enables unstable API features.Certain features wonβt take effect without this flag.
Unstable features will be marked with
β. -
rustβ Enable Rust core interfaces -
specsβ Enable all core interfaces
Β§Code generation
Features required for custom dialects generation.
rust_genβ Enable Rust code-generation toolsgeneratorsβ Enable all generatorsfingerprintsβ Use protocol CRC-fingerprints to avoid re-generating files
Β§Serialization and reflection
These features enable serde and specta support.
Β§MAVLink message definitions
These features control whether and how MAVLink message definitions generated by MAVInspect will be bundled.
β οΈ While being useful for ground control stations, the generated definitions is quite large and may bloat the size of the binary.
-
definitionsβ Bundles MAVLink message definitions.Message definitions will be generated only for bundled MAVLink dialects. Microservices will be ignored as they are just subsets of existing dialects.
Β§Dialects
These features control which MAVLink dialects will be considered by MAVSpec.
Enabled dialects can be found under the rust::dialects module.
To enable standard MAVLink dialects as defined in XML
message definitions, use dlct-* feature
family.
In case you want to patch
mavlink-message-definitions, you might be interested in enabling extra-dialects feature.
To bundle Rust bindings for MAVLink dialects, enable rust-dialects. No Rust bindings will be generated otherwise.
The dialect selection will also control which dialect definitions will be bundled if definitions feature is
enabled.
-
rust-dialectsβ Bundle MAVLink dialectsThis feature does not generate any dialect by itself unless
dlct-*ofextra-dialectsfeature flags enabled. -
dlct-ardupilotmegaβ IncludeardupilotmegadialectThe dialect can be found in
rust::dialects::ardupilotmegamodule. -
dlct-asluavβ IncludeASLUAVdialectThe dialect can be found in
rust::dialects::asluavmodule. -
dlct-avssuasβ IncludeAVSSUASdialectThe dialect can be found in
rust::dialects::avssuasmodule. -
dlct-commonβ IncludecommondialectThe dialect can be found in
rust::dialects::commonmodule. -
dlct-cs_air_linkβ IncludecsAirLinkdialectThe dialect can be found in
rust::dialects::cs_air_linkmodule. -
dlct-cubepilotβ IncludecubepilotdialectThe dialect can be found in
rust::dialects::cubepilotmodule. -
dlct-developmentβ IncludedevelopmentdialectThe dialect can be found in
rust::dialects::developmentmodule. -
dlct-icarousβ IncludeicarousdialectThe dialect can be found in
rust::dialects::icarousmodule. -
dlct-matrixpilotβ IncludematrixpilotdialectThe dialect can be found in
rust::dialects::matrixpilotmodule. -
dlct-minimalβ IncludeminimaldialectThe dialect can be found in
rust::dialects::minimalmodule. -
dlct-paparazziβ IncludepaparazzidialectThe dialect can be found in
rust::dialects::paparazzimodule. -
dlct-standardβ IncludestandarddialectThe dialect can be found in
rust::dialects::standardmodule. -
dlct-ualbertaβ IncludeualbertadialectThe dialect can be found in
rust::dialects::ualbertamodule. -
dlct-uavionixβ IncludeuAvionixdialectThe dialect can be found in
rust::dialects::u_avionixmodule. -
dlct-allβ Includeallmeta-dialectThe dialect can be found in
rust::dialects::allmodule. -
extra-dialectsβ Enables extra dialectsDownstream crates can patch mavlink-message-definitions adding extra MAVLink dialects.
-
test-dialectsβ Enables test dialectsThese dialects are useful for checking various test cases.
Β§MAVLink microservices
These features will control generation of MAVLink microservice-specific bindings.
If enabled, microservices can be found in rust::microservices module.
-
msrv-allβ Support for all MAVLink microservices -
msrv-heartbeatβ Heartbeat protocol supportThis microservice can be found in
rust::microservices::heartbeatmodule. -
msrv-missionβ Mission microservice supportThis microservice can be found in
rust::microservices::missionmodule. -
msrv-parameterβ Parameter protocol supportThis microservice can be found in
rust::microservices::parametermodule. -
msrv-parameter-extβ Extended parameter protocol supportThis microservice can be found in
rust::microservices::parameter_extmodule. -
msrv-commandβ Command protocol supportThis microservice can be found in
rust::microservices::commandmodule. -
msrv-manual-controlβ Manual control protocol supportThis microservice can be found in
rust::microservices::manual_controlmodule. -
msrv-cameraβ Camera protocol v2 supportThis microservice can be found in
rust::microservices::cameramodule. -
msrv-gimbal-v1β Gimbal protocol v1 supportThis microservice can be found in
rust::microservices::gimbal_v1module. -
msrv-gimbal-v2β Gimbal protocol v2 supportThis microservice can be found in
rust::microservices::gimbal_v2module. -
msrv-arm-authβ Arm authorization protocol supportThis microservice can be found in
rust::microservices::arm_authmodule. -
msrv-image-transmissionβ Image transmission protocol supportThis microservice can be found in
rust::microservices::image_transmissionmodule. -
msrv-ftpβ File transfer protocol supportThis microservice can be found in
rust::microservices::ftpmodule. -
msrv-landing-targetβ Landing target protocol supportThis microservice can be found in
rust::microservices::landing_targetmodule. -
msrv-pingβ Ping protocol supportThis microservice can be found in
rust::microservices::pingmodule. -
msrv-path-planningβ Path planning protocol supportThis microservice can be found in
rust::microservices::path_planningmodule. -
msrv-batteryβ Battery protocol supportThis microservice can be found in
rust::microservices::batterymodule. -
msrv-terrainβ Terrain protocol supportThis microservice can be found in
rust::microservices::terrainmodule. -
msrv-tunnelβ Tunnel protocol supportThis microservice can be found in
rust::microservices::tunnelmodule. -
msrv-open-drone-idβ Open Drone ID protocol supportThis microservice can be found in
rust::microservices::open_drone_idmodule. -
msrv-high-latencyβ High latency protocol supportThis microservice can be found in
rust::microservices::high_latencymodule. -
msrv-component-metadataβ Component metadata protocol supportThis microservice can be found in
rust::microservices::component_metadatamodule. -
msrv-payloadβ Payload protocol supportThis microservice can be found in
rust::microservices::payloadmodule. -
msrv-traffic-managementβ Traffic management protocol supportThis microservice can be found in
rust::microservices::traffic_managementmodule. -
msrv-events-interfaceβ Events interface protocol supportThis microservice can be found in
rust::microservices::events_interfacemodule. -
msrv-time-syncβ Time synchronization protocol supportThis microservice can be found in
rust::microservices::time_syncmodule. -
msrv-telemetryβ MAVLink TelemetryThis microservice can be found in
rust::microservices::telemetrymodule.
Β§Additional MAVLink tools
These features will enable additional MAVLink utilities such as *.waypoints files support, mission planninc, etc.
If enabled, additional microservice tools can be found in rust::microservices::utils.
β οΈ All such features require unstable feature to be enabled in order to take effect.
-
msrv-utils-allβ All MAVLink microservices utilsβ οΈ Requires
unstablefeature to take effect. -
msrv-utils-missionβ Mission protocol utilsIf enabled, these microservice tools can be found in
rust::microservices::utils::mission.β οΈ Requires
unstablefeature to take effect.
Β§Technical features
These features should not be used directly.
-
cliβ β Command-line utilitiesTurned on automatically when CLI tools are built.
-
msrvβ β Enable MAVLink microservices supportDo not use directly as this feature does not give access to any specific functionality by itself. Instead, use one of
msrv-*features. -
msrv-utilsβ βοΈ Enables MAVLink microservices extra utilsDo not use directly as this feature does not give access to any specific functionality by itself. Instead, use one of
msrv-utils-*features.
ModulesΒ§
- definitions
- MAVLink message definitions for MAVSpec.
- rust
- MAVSpecβs code generation toolchain for Rust