{"id":14992277,"url":"https://github.com/josh-tracey/PIDController","last_synced_at":"2025-09-25T14:31:01.269Z","repository":{"id":124629002,"uuid":"230681013","full_name":"josh-tracey/PIDController","owner":"josh-tracey","description":"Rust PID Controller library ","archived":false,"fork":false,"pushed_at":"2021-01-15T05:26:00.000Z","size":69,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-24T16:10:02.444Z","etag":null,"topics":["pid","pid-controller","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/josh-tracey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-28T23:46:59.000Z","updated_at":"2024-03-18T13:34:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"dac2630e-1845-4396-8dad-db8969d41306","html_url":"https://github.com/josh-tracey/PIDController","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-tracey%2FPIDController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-tracey%2FPIDController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-tracey%2FPIDController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josh-tracey%2FPIDController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josh-tracey","download_url":"https://codeload.github.com/josh-tracey/PIDController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234200175,"owners_count":18795139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pid","pid-controller","rust"],"created_at":"2024-09-24T15:00:54.187Z","updated_at":"2025-09-25T14:31:01.257Z","avatar_url":"https://github.com/josh-tracey.png","language":"Rust","readme":"# PID Controller library\n\nRust Crate: https://crates.io/crates/adriftdev_pid\n\nProportional, integral, and derivative controller module designed to allow easy calculation of outputs based on feedback loop from plant equipment (sensors / microcontrollers). output of PID controller can control motors, servos, or any component that can output a varities of outputs to achieve targeted outcome.\n\n## RoadMap\n\n- Smoothing of output curve.\n- PID Stack control - can use any variety of controller pattern, not just PID, eg PD, PI, P, or PID controller configurations.\n- General microcontroller optimisations\n\n## Example Usage\n\nThe following example shows how to use the PID controller to bring a simulated system to a target setpoint.\n\n```rust\nuse adriftdev_pid::control;\nuse std::{thread, time::Duration};\n\nfn main() {\n    // Create a new PID controller module\n    let mut pid = control::Module::new(\n        control::PController::new(0.1),\n        control::IController::new(0.05),\n        control::DController::new(0.01),\n    );\n\n    // Set the target value for the PID controller\n    let setpoint = 100.0;\n    pid.set_setpoint(setpoint);\n    println!(\"Setpoint: {}\", setpoint);\n\n    // Set the output limits for the PID controller\n    pid.set_output_limits(-10.0, 10.0);\n\n    // Simulate a simple plant (e.g., a heater, a motor, etc.)\n    let mut plant_state = 0.0; // The current state of our system (e.g., temperature)\n\n    println!(\"--- Starting simulation ---\");\n    // Loop for a fixed number of iterations to simulate the control process\n    for i in 0..200 {\n        // The PID controller computes the output based on the current plant state\n        let output = pid.compute(plant_state);\n\n        // The output of the PID controller affects the plant's state.\n        // This is a very simple plant model. In a real system, this would be\n        // the physics of the system you are controlling.\n        plant_state += output * 0.1;\n\n        println!(\n            \"Iteration {}: Plant State = {:.2}, PID Output = {:.2}\",\n            i, plant_state, output\n        );\n\n        // In a real application, you would have a delay here that matches\n        // the sample time of your controller.\n        thread::sleep(Duration::from_millis(10));\n\n        // For this example, we'll break if we are close to the setpoint\n        if (plant_state - setpoint).abs() \u003c 0.1 {\n            println!(\"--- Setpoint reached ---\");\n            break;\n        }\n    }\n    println!(\"--- Simulation finished ---\");\n}\n```\n\n### API Notes\n- The `compute` method now takes the current sensor reading (process variable) as an `input: f64`.\n- You can set output limits using `set_output_limits(min: f64, max: f64)`.\n\n## Possible Applications\n\nThere are plenty of uses for PID Controllers this is just a small sample of usages.\n\n### Air Conditioner\n\n- Temperature regulation - through controlled output and feebback loop from temp sensors`\n\n### Quadcopter\n\n- Altitude control\n- Speed control\n- Rotation control\n- Tilt control\n- Advanced Navigation\n\n### Electric Skateboard\n\n- Speed Control\n- Brake Control\n","funding_links":[],"categories":["Motion Control"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosh-tracey%2FPIDController","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosh-tracey%2FPIDController","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosh-tracey%2FPIDController/lists"}