1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! # embedded-flight
//! A `#![no_std]` flight software library for embedded rust
//!
//! # Examples
//!
//! For more check out the [basic](https://github.com/matthunz/embedded-flight/blob/main/examples/basic.rs) example on GitHub.
//!
//! Create and run a [`MultiCopter`] from a motor matrix, inertial sensor, clock, and frequency (in hz).
//! ```ignore
//!     use embedded_flight::MultiCopter;
//!     use embedded_flight::motors::MotorMatrix;
//!     
//!     // Create a quad-copter motor matrix from 4 ESCs
//!     let motor_matrix = MotorMatrix::quad(ESC(0), ESC(1), ESC(2), ESC(3));
//!
//!     // Create the quad-copter
//!     let mut copter = MultiCopter::new(
//!         motor_matrix,
//!         ExampleInertialSensor,
//!         ExampleClock,
//!         400
//!     );
//!
//!     // Run the tasks in the scheduler and output to the motors in a loop
//!     // By default this will stabilize the attitude
//!     copter.run();
//! ```
//!
//! Use the lower level [`MultiCopterAttitudeController`](control::attitude::MultiCopterAttitudeController) to get the motor output for a desired attitude:
//! ```
//! use embedded_flight::control::attitude::MultiCopterAttitudeController;
//! use nalgebra::{Vector3, Quaternion};
//!
//! let mut controller = MultiCopterAttitudeController::default();
//!
//! // Input the desired attitude and angular velocity with the current attitude
//! controller.attitude_controller.input(
//!     Quaternion::default(),
//!     Vector3::default(),
//!     Quaternion::default(),
//! );
//!
//! // Output the control to the motors with the current gyroscope data.
//! let output = controller.motor_output(Vector3::default(), 1);
//! dbg!(output);
//! ```

#![cfg_attr(not(test), no_std)]

pub use embedded_flight_control as control;
pub use embedded_flight_core as core;
pub use embedded_flight_motors as motors;

pub mod copter;
pub use copter::MultiCopter;