State

Struct State 

Source
pub struct State {
    pub position: f32,
    pub velocity: f32,
    pub acceleration: f32,
}
Expand description

A one-dimensional motion state with position, velocity, and acceleration.

Fields§

§position: f32

Where you are. This should be in millimeters.

§velocity: f32

How fast you’re going. This should be in millimeters per second.

§acceleration: f32

How fast how fast you’re going’s changing. This should be in millimeters per second squared.

Implementations§

Source§

impl State

Source

pub const fn new( position: Quantity, velocity: Quantity, acceleration: Quantity, ) -> Self

Constructor for State using Quantity objects for position, velocity, and acceleration.

Source

pub const fn new_raw(position: f32, velocity: f32, acceleration: f32) -> Self

Constructor for State using raw f32s for position, velocity, and acceleration.

Examples found in repository?
examples/devices.rs (line 6)
6const STATE: State = State::new_raw(0.0, 0.0, 0.0);
Source

pub fn update(&mut self, delta_time: Time)

Calculate the future state assuming a constant acceleration.

Source

pub const fn set_constant_acceleration( &mut self, acceleration: Quantity, ) -> Result<(), ()>

Set the acceleration with a Quantity. With dimension checking enabled, sets the acceleration and returns Ok if the argument’s Unit is correct, otherwise leaves it unchanged and returns Err. With dimension checking disabled, always sets the acceleration to the Quantity’s value and returns Ok, ignoring the Unit.

Source

pub const fn set_constant_acceleration_raw(&mut self, acceleration: f32)

Set the acceleration with an f32 of millimeters per second squared.

Source

pub const fn set_constant_velocity( &mut self, velocity: Quantity, ) -> Result<(), ()>

Set the velocity to a given value with a Quantity, and set acceleration to zero. With dimension checking enabled, sets the velocity and acceleration and returns Ok if the argument’s Unit is correct, otherwise leaves them unchanged and returns Err. With dimension checking disabled, ignores the Unit and always sets velocity and acceleration and returns Ok.

Source

pub const fn set_constant_velocity_raw(&mut self, velocity: f32)

Set the velocity to a given value with an f32 of millimeters per second, and set acceleration to zero.

Source

pub const fn set_constant_position( &mut self, position: Quantity, ) -> Result<(), ()>

Set the position to a given value with a Quantity, and set velocity and acceleration to zero. With dimension checking enabled, sets the position, velocity, and acceleration and returns Ok if the argument’s Unit is correct, otherwise leaves them unchanged and returns Err. With dimension checking disabled, always sets the position, velocity, and acceleration and returns Ok, ignoring the Unit.

Source

pub const fn set_constant_position_raw(&mut self, position: f32)

Set the position to a given value with an f32 of millimeters, and set velocity and acceleration to zero.

Source

pub const fn get_position(&self) -> Quantity

Get the position as a Quantity.

Source

pub const fn get_velocity(&self) -> Quantity

Get the velocity as a Quantity.

Source

pub const fn get_acceleration(&self) -> Quantity

Get the acceleration as a Quantity.

Source

pub fn get_value(&self, position_derivative: PositionDerivative) -> Quantity

State contains a position, velocity, and acceleration. This gets the respective field of a given position derivative.

Trait Implementations§

Source§

impl Add for State

Source§

type Output = State

The resulting type after applying the + operator.
Source§

fn add(self, other: State) -> Self

Performs the + operation. Read more
Source§

impl AddAssign for State

Source§

fn add_assign(&mut self, other: State)

Performs the += operation. Read more
Source§

impl Clone for State

Source§

fn clone(&self) -> State

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for State

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for State

Source§

fn default() -> State

Returns the “default value” for a type. Read more
Source§

impl Div<f32> for State

Source§

type Output = State

The resulting type after applying the / operator.
Source§

fn div(self, dvsr: f32) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<f32> for State

Source§

fn div_assign(&mut self, dvsr: f32)

Performs the /= operation. Read more
Source§

impl From<State> for Command

Source§

fn from(state: State) -> Self

Converts to this type from the input type.
Source§

impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for AccelerationToState<G, E>

Source§

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

Get something.
Source§

impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for PositionToState<G, E>

Source§

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

Get something.
Source§

impl<E: Copy + Debug> Getter<State, E> for Terminal<'_, E>

Source§

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

Get something.
Source§

impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for VelocityToState<G, E>

Source§

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

Get something.
Source§

impl Mul<f32> for State

Source§

type Output = State

The resulting type after applying the * operator.
Source§

fn mul(self, coef: f32) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<f32> for State

Source§

fn mul_assign(&mut self, coef: f32)

Performs the *= operation. Read more
Source§

impl Neg for State

Source§

type Output = State

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for State

Source§

fn eq(&self, other: &State) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for State

Source§

type Output = State

The resulting type after applying the - operator.
Source§

fn sub(self, other: State) -> Self

Performs the - operation. Read more
Source§

impl SubAssign for State

Source§

fn sub_assign(&mut self, other: State)

Performs the -= operation. Read more
Source§

impl Copy for State

Source§

impl StructuralPartialEq for State

Auto Trait Implementations§

§

impl Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnwindSafe for State

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.