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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Pidgeon: A robust PID controller library written in Rust
// Copyright (c) 2025 Security Union LLC
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! High-performance PID controller with `no_std` support, IIR-filtered derivative,
//! configurable anti-windup, and optional thread safety.
//!
//! # Architecture
//!
//! The library is split into two layers:
//!
//! - **Pure function**: [`pid_compute`] takes a [`ControllerConfig`] and [`PidState`],
//! returns a control output and updated state. Works in `no_std` environments.
//! - **Stateful controllers** (requires `std`): [`PidController`] and
//! [`ThreadSafePidController`] wrap the pure function with automatic state
//! management and performance statistics.
//!
//! # Quick start
//!
//! ```
//! use pidgeon::{ControllerConfig, PidState, pid_compute};
//!
//! // 1. Build a validated config
//! let config = ControllerConfig::builder()
//! .with_kp(2.0)
//! .with_ki(0.5)
//! .with_kd(0.1)
//! .with_setpoint(100.0)
//! .with_output_limits(0.0, 255.0)
//! .build()
//! .unwrap();
//!
//! // 2. Start with default state
//! let mut state = PidState::default();
//!
//! // 3. Run the control loop
//! let dt = 0.01; // 10 ms
//! for _ in 0..100 {
//! let process_value = 80.0; // read from sensor
//! let (output, next_state) = pid_compute(&config, &state, process_value, dt).unwrap();
//! state = next_state;
//! // apply `output` to actuator
//! }
//! ```
//!
//! # Feature flags
//!
//! | Feature | Default | Effect |
//! |--------------|---------|--------|
//! | `std` | yes | Enables [`PidController`], [`ThreadSafePidController`], and `Error` impl |
//! | `debugging` | no | Streams PID telemetry via Iggy.rs (implies `std`) |
//! | `benchmarks` | no | Enables criterion benchmarks (implies `std`) |
//! | `wasm` | no | Swaps `std::time` for `web_time` (implies `std`) |
pub use pid_compute;
pub use ;
pub use ;
pub use PidError;
pub use PidState;
pub use ;
pub use ThreadSafePidController;
pub use ;