Crates.io | advanced-pid |
lib.rs | advanced-pid |
version | 0.2.2 |
source | src |
created_at | 2024-05-01 02:59:12.142099 |
updated_at | 2024-05-17 06:31:17.981893 |
description | An advanced PID control library implemented in Rust |
homepage | |
repository | https://github.com/teruyamato0731/advanced-pid-rs |
max_upload_size | |
id | 1225797 |
size | 36,463 |
no_std
supportf32
and f64
floating point types through feature flagsTo install, run the following Cargo command in your project directory:
cargo add advanced-pid
Or add the following to your Cargo.toml:
[dependencies]
advanced-pid = "0.2.2"
cargo run --example simulation
Example of Standard PID Control
use advanced_pid::{prelude::*, Pid, PidGain};
fn main() {
let gain = PidGain {
kp: 1.0,
ki: 0.3,
kd: 0.1,
};
let mut pid = Pid::new(gain.into());
println!("{:5.2}", pid.update(1.0, 0.0, 1.0));
println!("{:5.2}", pid.update(1.0, 0.5, 1.0));
println!("{:5.2}", pid.update(1.0, 0.8, 1.0));
}
Example of Velocity Form PID Control
use advanced_pid::{prelude::*, PidConfig, VelPid};
fn main() {
let config = PidConfig::new(1.0, 0.1, 0.1).with_limits(-1.0, 1.0);
let mut pid = VelPid::new(config);
let target = 1.0;
let dt = 1.0;
println!("{:5.2}", pid.update(target, 0.0, dt));
println!("{:5.2}", pid.update(target, 0.1, dt));
println!("{:5.2}", pid.update(target, 0.3, dt));
}
For additional information, please visit:
Copyright (c) 2024 Yoshikawa Teru
This project is released under the MIT License, see LICENSE.