pub struct Quadrature { /* private fields */ }Expand description
Decodes a quadrature (A/B) encoder into a running tick count.
An incremental encoder reports motion as two square waves a quarter-cycle apart; their order of
change tells direction. Feeding successive A/B readings to update returns
the per-step direction and accumulates a signed count, the foundation for wheel odometry. Pair
it with a QuadratureScale to turn that count into metres.
§Examples
use pamoja_kit::Quadrature;
let mut enc = Quadrature::new();
// One full cycle forward: 00 -> 01 -> 11 -> 10 -> 00, one tick each.
for &(a, b) in &[(false, true), (true, true), (true, false), (false, false)] {
assert_eq!(enc.update(a, b), 1);
}
assert_eq!(enc.count(), 4);Implementations§
Source§impl Quadrature
impl Quadrature
Sourcepub fn starting(a: bool, b: bool) -> Self
pub fn starting(a: bool, b: bool) -> Self
Creates a decoder seeded with the encoder’s current channel levels.
Seeding the initial state avoids a spurious first tick when the encoder does not happen to rest with both channels low.
§Arguments
a- the current A channel level.b- the current B channel level.
§Returns
A decoder with a zero count and the given starting state.
Trait Implementations§
Source§impl Clone for Quadrature
impl Clone for Quadrature
Source§fn clone(&self) -> Quadrature
fn clone(&self) -> Quadrature
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Quadrature
Source§impl Debug for Quadrature
impl Debug for Quadrature
Source§impl Default for Quadrature
impl Default for Quadrature
Source§fn default() -> Quadrature
fn default() -> Quadrature
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Quadrature
impl RefUnwindSafe for Quadrature
impl Send for Quadrature
impl Sync for Quadrature
impl Unpin for Quadrature
impl UnsafeUnpin for Quadrature
impl UnwindSafe for Quadrature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more