pub struct AngularPid { /* private fields */ }
Expand description
PID controller for use in rotational systems.
This struct operates on the same principles and implementation as Pid
,
but takes exclusively Angle
s as input. Unlike Pid
, AngularPid
is able to recognize when angles wrap. This means a 0° measurement is
equivalent to a 360° measurement, for instance.
This is useful for cases where you want the controller to drive the system to its setpoint using the “shortest turn possible”.
Implementations§
Source§impl AngularPid
impl AngularPid
Sourcepub const fn new(
kp: f64,
ki: f64,
kd: f64,
integration_range: Option<Angle>,
) -> Self
pub const fn new( kp: f64, ki: f64, kd: f64, integration_range: Option<Angle>, ) -> Self
Construct a new PID controller from gain constants and an optional integration range.
Sourcepub const fn gains(&self) -> (f64, f64, f64)
pub const fn gains(&self) -> (f64, f64, f64)
Get the current PID gains as a tuple (kp
, ki
, kd
).
Sourcepub const fn integration_range(&self) -> Option<Angle>
pub const fn integration_range(&self) -> Option<Angle>
Returns the controller’s integration range.
Integration range is the minimum error range required to start integrating error. This is optionally applied to the controller as a mitigation for integral windup.
Sourcepub const fn set_gains(&mut self, kp: f64, ki: f64, kd: f64)
pub const fn set_gains(&mut self, kp: f64, ki: f64, kd: f64)
Sets the PID gains to provided values.
Sourcepub const fn set_integration_range(&mut self, range: Option<Angle>)
pub const fn set_integration_range(&mut self, range: Option<Angle>)
Sets the controller’s integration range.
Integration range is the minimum error range required to start integrating error. This is optionally applied to the controller as a mitigation for integral windup.
Sourcepub const fn set_output_limit(&mut self, range: Option<f64>)
pub const fn set_output_limit(&mut self, range: Option<f64>)
Sets the controller’s output limit.
This sets a maximum range for the controller’s output signal. It will effectively limit how fast the controller is able to drive the system, which may be desirable in some cases (e.g. limiting the maximum speed of a robot’s motion).
Trait Implementations§
Source§impl Clone for AngularPid
impl Clone for AngularPid
Source§fn clone(&self) -> AngularPid
fn clone(&self) -> AngularPid
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more