Skip to content

Commit 695e784

Browse files
committed
Apply cargo fmt.
1 parent cd98035 commit 695e784

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/lib.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! A proportional-integral-derivative (PID) controller library.
2-
//!
2+
//!
33
//! See [Pid] for the adjustable controller itself, as well as [ControlOutput] for the outputs and weights which you can use after setting up your controller. Follow the complete example below to setup your first controller!
4-
//!
4+
//!
55
//! # Example
6-
//!
6+
//!
77
//! ```rust
88
//! use pid::Pid;
99
//!
@@ -49,37 +49,37 @@ use num_traits::float::FloatCore;
4949
use serde::{Deserialize, Serialize};
5050

5151
/// Adjustable proportional-integral-derivative (PID) controller.
52-
///
52+
///
5353
/// # Examples
54-
///
54+
///
5555
/// This controller provides a builder pattern interface which allows you to pick-and-choose which PID inputs you'd like to use during operation. Here's what a basic proportional-only controller could look like:
56-
///
56+
///
5757
/// ```rust
5858
/// use pid::Pid;
59-
///
59+
///
6060
/// // Create limited controller
6161
/// let mut p_controller = Pid::new(15.0, 100.0);
6262
/// p_controller.p(10.0, 100.0);
63-
///
63+
///
6464
/// // Get first output
6565
/// let p_output = p_controller.next_control_output(400.0);
6666
/// ```
67-
///
67+
///
6868
/// This controller would give you set a proportional controller to `10.0` with a target of `15.0` and an output limit of `100.0` per [output](Self::next_control_output) iteration. The same controller with a full PID system built in looks like:
69-
///
69+
///
7070
/// ```rust
7171
/// use pid::Pid;
72-
///
72+
///
7373
/// // Create full PID controler
7474
/// let mut full_controller = Pid::new(15.0, 100.0);
7575
/// full_controller.p(10.0, 100.0).i(4.5, 100.0).d(0.25, 100.0);
76-
///
76+
///
7777
/// // Get first output
7878
/// let full_output = full_controller.next_control_output(400.0);
7979
/// ```
80-
///
80+
///
8181
/// This [`next_control_output`](Self::next_control_output) method is what's used to input new values into the controller to tell it what the current state of the system is. In the examples above it's only being used once, but realistically this will be a hot method. Please see [ControlOutput] for examples of how to handle these outputs; it's quite straight forward and mirrors the values of this structure in some ways.
82-
///
82+
///
8383
/// The last item of note is that these [`p`](Self::p()), [`i`](Self::i()), and [`d`](Self::d()) methods can be used *during* operation which lets you add and/or modify these controller values if need be.
8484
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
8585
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
@@ -112,7 +112,7 @@ pub struct ControlOutput<T: FloatCore> {
112112
/// Contribution of the P term to the output.
113113
pub p: T,
114114
/// Contribution of the I term to the output.
115-
///
115+
///
116116
/// This integral term is equal to `sum[error(t) * ki(t)] (for all t)`
117117
pub i: T,
118118
/// Contribution of the D term to the output.
@@ -126,11 +126,11 @@ where
126126
T: FloatCore,
127127
{
128128
/// Creates a new controller with the target setpoint and the output limit
129-
///
129+
///
130130
/// To set your P, I, and D terms into this controller, please use the following builder methods:
131-
/// - [Self::p()]: Proportional term setting
132-
/// - [Self::i()]: Integral term setting
133-
/// - [Self::d()]: Derivative term setting
131+
/// - [Self::p()]: Proportional term setting
132+
/// - [Self::i()]: Integral term setting
133+
/// - [Self::d()]: Derivative term setting
134134
pub fn new(setpoint: impl Into<T>, output_limit: impl Into<T>) -> Self {
135135
Self {
136136
setpoint: setpoint.into(),
@@ -176,7 +176,7 @@ where
176176
/// Given a new measurement, calculates the next control output.
177177
///
178178
/// # Panics
179-
///
179+
///
180180
/// - If a setpoint has not been set via `update_setpoint()`.
181181
pub fn next_control_output(&mut self, measurement: T) -> ControlOutput<T> {
182182
let error = self.setpoint - measurement;
@@ -228,8 +228,8 @@ fn apply_limit<T: FloatCore>(limit: T, value: T) -> T {
228228

229229
#[cfg(test)]
230230
mod tests {
231-
use crate::ControlOutput;
232231
use super::Pid;
232+
use crate::ControlOutput;
233233

234234
/// Proportional-only controller operation and limits
235235
#[test]

0 commit comments

Comments
 (0)