You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib.rs
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -12,20 +12,20 @@
12
12
//! pid.p(10.0, 100.0);
13
13
//!
14
14
//! // Input a measurement with an error of 5.0 from our setpoint
15
-
//! let output = pid.next_control_output(10.0);
15
+
//! let output = pid.next_control_output(10.0, 1.0);
16
16
//!
17
17
//! // Show that the error is correct by multiplying by our kp
18
18
//! assert_eq!(output.output, 50.0); // <--
19
19
//! assert_eq!(output.p, 50.0);
20
20
//!
21
21
//! // It won't change on repeat; the controller is proportional-only
22
-
//! let output = pid.next_control_output(10.0);
22
+
//! let output = pid.next_control_output(10.0, 1.0);
23
23
//! assert_eq!(output.output, 50.0); // <--
24
24
//! assert_eq!(output.p, 50.0);
25
25
//!
26
26
//! // Add a new integral term to the controller and input again
27
27
//! pid.i(1.0, 100.0);
28
-
//! let output = pid.next_control_output(10.0);
28
+
//! let output = pid.next_control_output(10.0, 1.0);
29
29
//!
30
30
//! // Now that the integral makes the controller stateful, it will change
31
31
//! assert_eq!(output.output, 55.0); // <--
@@ -34,7 +34,7 @@
34
34
//!
35
35
//! // Add our final derivative term and match our setpoint target
36
36
//! pid.d(2.0, 100.0);
37
-
//! let output = pid.next_control_output(15.0);
37
+
//! let output = pid.next_control_output(15.0, 1.0);
38
38
//!
39
39
//! // The output will now say to go down due to the derivative
40
40
//! assert_eq!(output.output, -5.0); // <--
@@ -79,7 +79,7 @@ impl<T: PartialOrd + num_traits::Signed + Copy> Number for T {}
79
79
/// p_controller.p(10.0, 100.0);
80
80
///
81
81
/// // Get first output
82
-
/// let p_output = p_controller.next_control_output(400.0);
82
+
/// let p_output = p_controller.next_control_output(400.0, 1.0);
83
83
/// ```
84
84
///
85
85
/// 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:
@@ -92,7 +92,7 @@ impl<T: PartialOrd + num_traits::Signed + Copy> Number for T {}
/// let full_output = full_controller.next_control_output(400.0);
95
+
/// let full_output = full_controller.next_control_output(400.0, 1.0);
96
96
/// ```
97
97
///
98
98
/// 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.
0 commit comments