crazyflie_lib/lib.rs
1//! # Crazyflie library
2//!
3//! This crate allows to connect, communicate with and control the Crazyflie using the [crazyflie-link] crate
4//! to open a communication link. The link implementation only supports radio for now, but more will be implemented
5//! in the future (at least USB).
6//!
7//! ## Status
8//!
9//! The crate aims at implementing a Rust API to control the Crazyflie. The Crazyflie functionalities are implemented in
10//! subsystems. The current status is:
11//!
12//! | Subsystem | Support |
13//! |-----------|---------|
14//! | App channel | None |
15//! | Commander | Partial (only RPYT) |
16//! | Console | Full |
17//! | High-level Commander | None |
18//! | Localization | None |
19//! | Log | Full (V2) |
20//! | Memory | None |
21//! | Param | Full(V2) |
22//! | Platform | Full |
23//!
24//! ## Compatibility
25//!
26//! This crate is compatible with Crazyflie protocol version > 4. This means Crazyflie firmware release >= 2018.08.
27//!
28//! The Crazyflie guarantees backward functionalities for one protocol version
29//! so this lib will be compatible with version 4 (~2018-08) and 5 (future) of
30//! the protocol.
31//!
32//! ## Usage
33//!
34//! The basic procedure to use the lib is:
35//! - Find the link URI to connect, either by scanning or as a config or user input
36//! - Create a Crazyflie object from the URI or a connected Link, this will connect to the Crazyflie and initializes
37//! the subsystems
38//! - Subsystems are available as public fields of the [Crazyflie] struct.
39//! - Use the subsystems in the Crazyflie object to control the Crazyflie
40//! - Drop the Crazyflie object or call [crazyflie::Crazyflie::disconnect()]
41//!
42//! All subsystems functions are only taking an un-mutable reference to self (`&self`), the intention is for the
43//! Crazyflie object to be shared between tasks using `Arc<>` or `Rc<>`.
44//!
45//! For example:
46//! ``` no_run
47//! # async fn test() -> Result<(), Box<dyn std::error::Error>> {
48//! let link_context = crazyflie_link::LinkContext::new();
49//!
50//! // Scan for Crazyflies on the default address
51//! let found = link_context.scan([0xE7; 5]).await?;
52//!
53//! if let Some(uri) = found.first() {
54//! let cf = crazyflie_lib::Crazyflie::connect_from_uri(&link_context, uri).await?;
55//!
56//! println!("List of params variables: ");
57//! for name in cf.param.names() {
58//! println!(" - {}", name);
59//! }
60//!
61//! println!("List of log variables: ");
62//! for name in cf.param.names() {
63//! println!(" - {}", name);
64//! }
65//!
66//! cf.disconnect().await;
67//! }
68//! # Ok(())
69//! # }
70//! ```
71//!
72//! [crazyflie-link]: https://crates.io/crates/crazyflie-link
73
74#![warn(missing_docs)]
75
76mod crazyflie;
77mod crtp_utils;
78mod error;
79mod value;
80
81pub mod subsystems;
82
83pub use crate::crazyflie::Crazyflie;
84pub use crate::error::{Error, Result};
85pub use crate::value::{Value, ValueType};
86
87/// Supported protocol version
88///
89/// see [the crate documentation](crate#compatibility) for more information.
90pub const SUPPORTED_PROTOCOL_VERSION: u8 = 7;