Skip to main content

Limits

Struct Limits 

Source
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 s

Implementations§

Source§

impl Limits

Source

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.

Source

pub fn reset(&mut self)

Resets the remembered motion to rest, so the next command eases up from zero.

Source

pub fn apply(&mut self, desired: Twist, dt: f32) -> Twist

Bounds a desired command in speed and acceleration and returns the safe command.

§Arguments
  • desired - the requested body motion.
  • dt - the time since the previous call, setting the acceleration step.
§Returns

The command after capping speed and easing toward it within the acceleration limit.

Trait Implementations§

Source§

impl Clone for Limits

Source§

fn clone(&self) -> Limits

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 Limits

Source§

impl Debug for Limits

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.