pub struct SafetyGate { /* private fields */ }Expand description
The single gate every motion command passes through, composing e-stop, watchdog, and limits.
This is the one call a control loop makes to drive safely: feed it the desired motion and the
time step, and it returns what is actually safe to command. It stops hard (commands zero and
forgets its motion history, so resuming eases from rest) whenever the e-stop is engaged or the
watchdog has expired; otherwise it returns the desired motion bounded by the Limits. Call
feed whenever a fresh command arrives to keep the watchdog satisfied.
§Examples
use pamoja_kit::{Limits, SafetyGate, Twist};
let limits = Limits::new(1.0, 2.0, 0.5, 4.0);
let mut gate = SafetyGate::new(limits, 0.2); // stop if unfed for 0.2 s
gate.feed();
let cmd = gate.command(Twist::planar(1.0, 0.0), 0.1);
assert!((cmd.vx - 0.05).abs() < 1e-6); // eased on, acceleration-limited
gate.engage_estop();
assert_eq!(gate.command(Twist::planar(1.0, 0.0), 0.1), Twist::zero());Implementations§
Source§impl SafetyGate
impl SafetyGate
Sourcepub fn engage_estop(&mut self)
pub fn engage_estop(&mut self)
Engages the latching emergency stop.
Sourcepub fn reset_estop(&mut self)
pub fn reset_estop(&mut self)
Clears the emergency stop.
Sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
Returns whether the gate is currently forcing a stop.
§Returns
true if the e-stop is engaged or the watchdog has expired.
Sourcepub fn command(&mut self, desired: Twist, dt: f32) -> Twist
pub fn command(&mut self, desired: Twist, dt: f32) -> Twist
Returns the safe command for a desired motion over a time step.
§Arguments
desired- the requested body motion.dt- the time since the previous call.
§Returns
Twist::zero when stopped, otherwise the desired motion bounded by the limits.
Trait Implementations§
Source§impl Clone for SafetyGate
impl Clone for SafetyGate
Source§fn clone(&self) -> SafetyGate
fn clone(&self) -> SafetyGate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more