pub struct Limits { /* private fields */ }Expand description
Bounds a robot’s speed and acceleration so commands stay within what the machine can do safely.
A raw command can be too fast or too sudden: a full-speed setpoint snaps the wheels, a hard
reverse strips traction. Limits caps the planar speed and yaw rate, then eases each toward
the capped target at a bounded acceleration, so motion is smooth and within envelope. The
easing reuses Ramp as its slew-rate limiter, with the step set to accel * dt each update.
§Examples
use pamoja_kit::{Limits, Twist};
// Up to 1 m/s and 2 rad/s, easing on at 0.5 m/s^2 and 4 rad/s^2.
let mut limits = Limits::new(1.0, 2.0, 0.5, 4.0);
// Asking for full speed from rest: the first 0.1 s step is acceleration-limited.
let cmd = limits.apply(Twist::planar(1.0, 0.0), 0.1);
assert!((cmd.vx - 0.05).abs() < 1e-6); // 0.5 m/s^2 * 0.1 sImplementations§
Source§impl Limits
impl Limits
Sourcepub fn new(
max_linear: f32,
max_angular: f32,
max_linear_accel: f32,
max_angular_accel: f32,
) -> Self
pub fn new( max_linear: f32, max_angular: f32, max_linear_accel: f32, max_angular_accel: f32, ) -> Self
Creates limits from the speed and acceleration ceilings.
§Arguments
max_linear- the largest planar speed; its magnitude is used.max_angular- the largest yaw rate; its magnitude is used.max_linear_accel- the largest change in linear speed per second; its magnitude is used.max_angular_accel- the largest change in yaw rate per second; its magnitude is used.
§Returns
Limits starting from rest.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets the remembered motion to rest, so the next command eases up from zero.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Limits
impl RefUnwindSafe for Limits
impl Send for Limits
impl Sync for Limits
impl Unpin for Limits
impl UnsafeUnpin for Limits
impl UnwindSafe for Limits
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