Skip to content

Commit c8b43eb

Browse files
committed
Add missing argument to tests
1 parent 796814a commit c8b43eb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
//! pid.p(10.0, 100.0);
1313
//!
1414
//! // 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);
1616
//!
1717
//! // Show that the error is correct by multiplying by our kp
1818
//! assert_eq!(output.output, 50.0); // <--
1919
//! assert_eq!(output.p, 50.0);
2020
//!
2121
//! // 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);
2323
//! assert_eq!(output.output, 50.0); // <--
2424
//! assert_eq!(output.p, 50.0);
2525
//!
2626
//! // Add a new integral term to the controller and input again
2727
//! 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);
2929
//!
3030
//! // Now that the integral makes the controller stateful, it will change
3131
//! assert_eq!(output.output, 55.0); // <--
@@ -34,7 +34,7 @@
3434
//!
3535
//! // Add our final derivative term and match our setpoint target
3636
//! 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);
3838
//!
3939
//! // The output will now say to go down due to the derivative
4040
//! assert_eq!(output.output, -5.0); // <--
@@ -79,7 +79,7 @@ impl<T: PartialOrd + num_traits::Signed + Copy> Number for T {}
7979
/// p_controller.p(10.0, 100.0);
8080
///
8181
/// // 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);
8383
/// ```
8484
///
8585
/// 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 {}
9292
/// full_controller.p(10.0, 100.0).i(4.5, 100.0).d(0.25, 100.0);
9393
///
9494
/// // Get first output
95-
/// let full_output = full_controller.next_control_output(400.0);
95+
/// let full_output = full_controller.next_control_output(400.0, 1.0);
9696
/// ```
9797
///
9898
/// 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.
@@ -141,7 +141,7 @@ pub struct Pid<T: Number> {
141141
/// pid.p(10.0, 100.0).i(1.0, 100.0).d(2.0, 100.0);
142142
///
143143
/// // Input an example value and get a report for an output iteration
144-
/// let output = pid.next_control_output(26.2456);
144+
/// let output = pid.next_control_output(26.2456, 1.0);
145145
/// println!("P: {}\nI: {}\nD: {}\nFinal Output: {}", output.p, output.i, output.d, output.output);
146146
/// ```
147147
#[derive(Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)