CommandPID

Struct CommandPID 

Source
pub struct CommandPID<G: Getter<State, E> + ?Sized, E: Copy + Debug> { /* private fields */ }
Expand description

Automatically integrates the command variable of a PID controller based on the position derivative of a Command. Designed to make it easier to use a standard DC motor and an encoder as a de facto servo.

Implementations§

Source§

impl<G: Getter<State, E> + ?Sized, E: Copy + Debug> CommandPID<G, E>

Source

pub const fn new( input: Reference<G>, command: Command, kvalues: PositionDerivativeDependentPIDKValues, ) -> Self

Constructor for CommandPID.

Source

pub fn reset(&mut self)

Clear cached data for calculating integral and derivative. After this is called, the PID controller will use the next few updates to rebuild its cache in the same way as it does during the first few updates after initialization. This is called when the command changes so as not to cause issues with the integral and derivative.

Trait Implementations§

Source§

impl<G: Getter<State, E> + ?Sized, E: Copy + Debug> Getter<f32, E> for CommandPID<G, E>

Source§

fn get(&self) -> Output<f32, E>

Get something.
Source§

impl<G: Getter<State, E> + ?Sized, E: Copy + Debug> Settable<Command, E> for CommandPID<G, E>

Source§

fn get_settable_data_ref(&self) -> &SettableData<Command, E>

As traits cannot have fields, get functions and separate types are required. All you have to do is make a field for a corresponding SettableData, make this return an immutable reference to it, and make get_settable_data_mut return a mutable reference to it.
Source§

fn get_settable_data_mut(&mut self) -> &mut SettableData<Command, E>

As traits cannot have fields, get functions and separate types are required. All you have to do is make a field for a corresponding SettableData, make this return a mutable reference to it, and make get_settable_data_ref return an immutable reference to it.
Source§

fn impl_set(&mut self, command: Command) -> NothingOrError<E>

Set something, not updating the internal SettableData. Due to current limitations of the language, you must implement this but call set. Do not call this directly as it will make get_last_request work incorrectly.
Source§

fn set(&mut self, value: S) -> NothingOrError<E>

Set something to a value. For example, this could set a motor to a voltage. You should call this and not impl_set.
Source§

fn follow(&mut self, getter: Reference<dyn Getter<S, E>>)

Begin following a Getter of the same type. For this to work, you must have update_following_data in your Updatable implementation.
Source§

fn stop_following(&mut self)

Stop following the Getter.
Source§

fn update_following_data(&mut self) -> NothingOrError<E>

Get a new value from the Getter we’re following, if there is one, and call set accordingly. You must add this to your Updatable implementation if you are following Getters. This is a current limitation of the Rust language. If specialization is ever stabilized, this will hopefully be done in a better way.
Source§

fn get_last_request(&self) -> Option<S>

Get the argument from the last time set was called.
Source§

impl<G: Getter<State, E> + ?Sized, E: Copy + Debug> Updatable<E> for CommandPID<G, E>

Source§

fn update(&mut self) -> NothingOrError<E>

As this trait is very generic, exactly what this does will be very dependent on the implementor.

Auto Trait Implementations§

§

impl<G, E> Freeze for CommandPID<G, E>
where E: Freeze, G: ?Sized,

§

impl<G, E> !RefUnwindSafe for CommandPID<G, E>

§

impl<G, E> !Send for CommandPID<G, E>

§

impl<G, E> !Sync for CommandPID<G, E>

§

impl<G, E> Unpin for CommandPID<G, E>
where E: Unpin, G: ?Sized,

§

impl<G, E> !UnwindSafe for CommandPID<G, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.