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 | Full |
15//! | Commander | Full |
16//! | Console | Full |
17//! | High-level Commander | Full |
18//! | Localization | Full |
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 >= [`SUPPORTED_PROTOCOL_VERSION`].
27//!
28//! ## Usage
29//!
30//! The basic procedure to use the lib is:
31//!  - Find the link URI to connect, either by scanning or as a config or user input
32//!  - Create a Crazyflie object from the URI or a connected Link, this will connect to the Crazyflie and initializes
33//!    the subsystems
34//!  - Subsystems are available as public fields of the [Crazyflie] struct.
35//!  - Use the subsystems in the Crazyflie object to control the Crazyflie
36//!  - Drop the Crazyflie object or call [crazyflie::Crazyflie::disconnect()]
37//!
38//! All subsystems functions are only taking an un-mutable reference to self (`&self`), the intention is for the
39//! Crazyflie object to be shared between tasks using `Arc<>` or `Rc<>`.
40//!
41//! For example:
42//! ``` no_run
43//! # async fn test() -> Result<(), Box<dyn std::error::Error>> {
44//! let link_context = crazyflie_link::LinkContext::new();
45//!
46//! // Scan for Crazyflies on the default address
47//! let found = link_context.scan([0xE7; 5]).await?;
48//!
49//! if let Some(uri) = found.first() {
50//!     let cf = crazyflie_lib::Crazyflie::connect_from_uri(
51//!         &link_context,
52//!         uri,
53//!         crazyflie_lib::NoTocCache
54//!     ).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};
86pub use crate::crtp_utils::TocCache;
87pub use crate::crtp_utils::NoTocCache;
88
89/// Supported protocol version
90///
91/// see [the crate documentation](crate#compatibility) for more information.
92pub const SUPPORTED_PROTOCOL_VERSION: u8 = 10;