pub struct AxisConfig { /* private fields */ }Expand description
Unit conversion for a rotary/linear axis with a known encoder resolution.
Stores the encoder’s counts-per-revolution and an optional user-unit scale (e.g. 360.0 for degrees, 5.0 for mm-per-rev on a ballscrew). All conversion methods are pure arithmetic — no state, no side effects.
§Examples
use autocore_std::ethercat::AxisConfig;
// Revolutions (default)
let cfg = AxisConfig::new(12_800);
assert_eq!(cfg.rev(0.125), 1_600);
assert_eq!(cfg.rev(1.0), 12_800);
// Degrees
let deg = AxisConfig::new(12_800).with_user_scale(360.0);
assert_eq!(deg.user(45.0), 1_600);
assert_eq!(deg.user(360.0), 12_800);
// mm on a 5 mm/rev ballscrew
let mm = AxisConfig::new(12_800).with_user_scale(5.0);
assert_eq!(mm.user(5.0), 12_800);
assert_eq!(mm.user(2.5), 6_400);Implementations§
Source§impl AxisConfig
impl AxisConfig
Sourcepub const fn new(counts_per_rev: u32) -> Self
pub const fn new(counts_per_rev: u32) -> Self
Create from encoder resolution (e.g. 12_800 counts/rev). Default user units = revolutions (1.0 user unit = 1 revolution).
Sourcepub const fn with_user_scale(self, user_per_rev: f64) -> Self
pub const fn with_user_scale(self, user_per_rev: f64) -> Self
Set user-units-per-revolution for application-specific units.
- Degrees:
.with_user_scale(360.0) - mm on 5 mm/rev ballscrew:
.with_user_scale(5.0)
Sourcepub fn user_per_s(&self, units_per_sec: f64) -> u32
pub fn user_per_s(&self, units_per_sec: f64) -> u32
Convert user-units/s to counts/s (velocity).
Sourcepub fn user_per_s2(&self, units_per_sec2: f64) -> u32
pub fn user_per_s2(&self, units_per_sec2: f64) -> u32
Convert user-units/s² to counts/s² (acceleration).
Sourcepub fn to_user_per_s(&self, counts_per_sec: u32) -> f64
pub fn to_user_per_s(&self, counts_per_sec: u32) -> f64
Convert counts/s to user-units/s.
Trait Implementations§
Source§impl Clone for AxisConfig
impl Clone for AxisConfig
Source§fn clone(&self) -> AxisConfig
fn clone(&self) -> AxisConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AxisConfig
impl Debug for AxisConfig
impl Copy for AxisConfig
Auto Trait Implementations§
impl Freeze for AxisConfig
impl RefUnwindSafe for AxisConfig
impl Send for AxisConfig
impl Sync for AxisConfig
impl Unpin for AxisConfig
impl UnsafeUnpin for AxisConfig
impl UnwindSafe for AxisConfig
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