Skip to main content

Crate pidgeon

Crate pidgeon 

Source
Expand description

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:

§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

FeatureDefaultEffect
stdyesEnables PidController, ThreadSafePidController, and Error impl
debuggingnoStreams PID telemetry via Iggy.rs (implies std)
benchmarksnoEnables criterion benchmarks (implies std)
wasmnoSwaps std::time for web_time (implies std)

Structs§

ControllerConfig
Validated, immutable PID controller configuration.
ControllerConfigBuilder
Builder for ControllerConfig. Collects PID parameters without validation until build() is called.
ControllerStatistics
Runtime performance metrics for a PidController.
PidController
Stateful PID controller with built-in performance statistics.
PidState
Persistent state carried between pid_compute invocations.
ThreadSafePidController
Thread-safe PID controller backed by Arc<Mutex<PidController>>.

Enums§

AntiWindupMode
Anti-windup strategy for the integral term.
DerivativeMode
Selects which signal the derivative term operates on.
PidError
Error type for PID controller operations.

Functions§

pid_compute
Computes one PID control step as a pure function.