Skip to main content

QuadratureScale

Struct QuadratureScale 

Source
pub struct QuadratureScale { /* private fields */ }
Expand description

Converts encoder ticks into the distance and speed a wheel has travelled.

§Examples

use pamoja_kit::QuadratureScale;

// 360 ticks per revolution on a wheel of 0.05 m radius.
let scale = QuadratureScale::new(360.0, 0.05);
// One full revolution rolls out one circumference.
assert!((scale.distance(360) - (2.0 * core::f32::consts::PI * 0.05)).abs() < 1e-6);

Implementations§

Source§

impl QuadratureScale

Source

pub fn new(counts_per_rev: f32, wheel_radius: f32) -> Self

Creates a scale from the encoder resolution and wheel size.

§Arguments
  • counts_per_rev - ticks per wheel revolution; its magnitude is used.
  • wheel_radius - the wheel radius in metres; its magnitude is used.
§Returns

The scale.

Source

pub fn distance(&self, count: i64) -> f32

Returns the distance rolled for a tick count.

§Arguments
  • count - the signed tick count.
§Returns

The distance in metres, zero when the resolution is zero.

Source

pub fn velocity(&self, delta_count: i64, dt: f32) -> f32

Returns the speed for a tick count accumulated over a time step.

§Arguments
  • delta_count - the ticks counted during the step.
  • dt - the length of the step.
§Returns

The speed in metres per second, zero when dt is zero.

Trait Implementations§

Source§

impl Clone for QuadratureScale

Source§

fn clone(&self) -> QuadratureScale

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for QuadratureScale

Source§

impl Debug for QuadratureScale

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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.