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 ofminimal
dialect, 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 inall
family do not collide.- Other dialects from MAVLink XML definitions:
asluav
,avssuas
,csairlink
,cubepilot
,development
,icarous
,matrixpilot
,paparazzi
,ualberta
,uavionix
. These do not includepython_array_test
andtest
dialects which should be either generated manually or as a part ofall
meta-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-minimal
feature flagstandard
β enabled bydlct-standard
feature flagcommon
β enabled bydlct-common
feature flagardupilotmega
β enabled bydlct-ardupilotmega
feature flagall
β enabled bydlct-all
feature 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
std
feature to be enabled. definitions
requiresstd
feature 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
β Enablealloc
support -
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-dialects
feature flags enabled. -
dlct-ardupilotmega
β Includeardupilotmega
dialectThe dialect can be found in
rust::dialects::ardupilotmega
module. -
dlct-asluav
β IncludeASLUAV
dialectThe dialect can be found in
rust::dialects::asluav
module. -
dlct-avssuas
β IncludeAVSSUAS
dialectThe dialect can be found in
rust::dialects::avssuas
module. -
dlct-common
β Includecommon
dialectThe dialect can be found in
rust::dialects::common
module. -
dlct-cs_air_link
β IncludecsAirLink
dialectThe dialect can be found in
rust::dialects::cs_air_link
module. -
dlct-cubepilot
β Includecubepilot
dialectThe dialect can be found in
rust::dialects::cubepilot
module. -
dlct-development
β Includedevelopment
dialectThe dialect can be found in
rust::dialects::development
module. -
dlct-icarous
β Includeicarous
dialectThe dialect can be found in
rust::dialects::icarous
module. -
dlct-matrixpilot
β Includematrixpilot
dialectThe dialect can be found in
rust::dialects::matrixpilot
module. -
dlct-minimal
β Includeminimal
dialectThe dialect can be found in
rust::dialects::minimal
module. -
dlct-paparazzi
β Includepaparazzi
dialectThe dialect can be found in
rust::dialects::paparazzi
module. -
dlct-standard
β Includestandard
dialectThe dialect can be found in
rust::dialects::standard
module. -
dlct-ualberta
β Includeualberta
dialectThe dialect can be found in
rust::dialects::ualberta
module. -
dlct-uavionix
β IncludeuAvionix
dialectThe dialect can be found in
rust::dialects::u_avionix
module. -
dlct-all
β Includeall
meta-dialectThe dialect can be found in
rust::dialects::all
module. -
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::heartbeat
module. -
msrv-mission
β Mission microservice supportThis microservice can be found in
rust::microservices::mission
module. -
msrv-parameter
β Parameter protocol supportThis microservice can be found in
rust::microservices::parameter
module. -
msrv-parameter-ext
β Extended parameter protocol supportThis microservice can be found in
rust::microservices::parameter_ext
module. -
msrv-command
β Command protocol supportThis microservice can be found in
rust::microservices::command
module. -
msrv-manual-control
β Manual control protocol supportThis microservice can be found in
rust::microservices::manual_control
module. -
msrv-camera
β Camera protocol v2 supportThis microservice can be found in
rust::microservices::camera
module. -
msrv-gimbal-v1
β Gimbal protocol v1 supportThis microservice can be found in
rust::microservices::gimbal_v1
module. -
msrv-gimbal-v2
β Gimbal protocol v2 supportThis microservice can be found in
rust::microservices::gimbal_v2
module. -
msrv-arm-auth
β Arm authorization protocol supportThis microservice can be found in
rust::microservices::arm_auth
module. -
msrv-image-transmission
β Image transmission protocol supportThis microservice can be found in
rust::microservices::image_transmission
module. -
msrv-ftp
β File transfer protocol supportThis microservice can be found in
rust::microservices::ftp
module. -
msrv-landing-target
β Landing target protocol supportThis microservice can be found in
rust::microservices::landing_target
module. -
msrv-ping
β Ping protocol supportThis microservice can be found in
rust::microservices::ping
module. -
msrv-path-planning
β Path planning protocol supportThis microservice can be found in
rust::microservices::path_planning
module. -
msrv-battery
β Battery protocol supportThis microservice can be found in
rust::microservices::battery
module. -
msrv-terrain
β Terrain protocol supportThis microservice can be found in
rust::microservices::terrain
module. -
msrv-tunnel
β Tunnel protocol supportThis microservice can be found in
rust::microservices::tunnel
module. -
msrv-open-drone-id
β Open Drone ID protocol supportThis microservice can be found in
rust::microservices::open_drone_id
module. -
msrv-high-latency
β High latency protocol supportThis microservice can be found in
rust::microservices::high_latency
module. -
msrv-component-metadata
β Component metadata protocol supportThis microservice can be found in
rust::microservices::component_metadata
module. -
msrv-payload
β Payload protocol supportThis microservice can be found in
rust::microservices::payload
module. -
msrv-traffic-management
β Traffic management protocol supportThis microservice can be found in
rust::microservices::traffic_management
module. -
msrv-events-interface
β Events interface protocol supportThis microservice can be found in
rust::microservices::events_interface
module. -
msrv-time-sync
β Time synchronization protocol supportThis microservice can be found in
rust::microservices::time_sync
module. -
msrv-telemetry
β MAVLink TelemetryThis microservice can be found in
rust::microservices::telemetry
module.
Β§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
unstable
feature to take effect. -
msrv-utils-mission
β Mission protocol utilsIf enabled, these microservice tools can be found in
rust::microservices::utils::mission
.β οΈ Requires
unstable
feature 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