Expand description
Goal-named helper math for the pamoja SDK.
The hardest part of building something real on a cheap sensor is rarely reading
the sensor; it is turning that reading into a decision that holds up in the
field. pamoja-kit is the layer that closes that gap for people who are not
signal-processing engineers. Each helper is named for the goal rather than the
technique, ships with correct defaults, and documents the real algorithm one
layer down, so it teaches as it abstracts.
The first helpers cover the jobs the cookbook leans on most:
Smoother- smooth a noisy reading (exponential moving average).Kalman- settle to a steady value from a noisy sensor (one-dimensional Kalman).Complementary- fuse a fast rate with a slow absolute reading (complementary filter).Median- reject spikes with a rolling median (robust to a lone bad reading).Debounce- clean a chattering on/off signal into one event (counter debounce).Calibration- turn a raw reading into real units (two-point linear map).deadband- ignore small wiggle around a setpoint so an actuator does not chatter.Thermostat- keep a reading near a setpoint (on/off control with hysteresis).Pid- hold a value at a target with a smooth, proportional command (PID control).Ramp- ease a command toward a target at a limited rate (slew-rate limiter).Depletion- warn before a falling level runs out (linear extrapolation).Surge- warn when a reading changes dangerously fast (first difference).Trend- tell whether a value is rising or falling and how fast (least-squares slope).Anomaly- flag a reading that departs from its recent history (three-sigma rule).Window- keep a rolling window of recent readings and read their spread (min, max, range, mean, population variance).units- convert a reading to the unit a person reads (Celsius and Fahrenheit, pascals to hPa/kPa/psi, ratio and percent).DiffDrive,Ackermann,SkidSteer,Mecanum- wheel kinematics for the common differential, car-like, skid-steer, and omnidirectional chassis (behindrobotics).TwoLinkArm/forward_kinematics- manipulator kinematics: the planar two-link inverse, and Denavit-Hartenberg forward kinematics for any serial arm.Odometry- dead-reckon aPosefrom a body motion or wheel deltas, exact-arc.WaypointFollower/obstacle_stop- steer toward a waypoint and stop for an obstacle (behindroboticsandgeo).SafetyGate- the gate every motion command passes through: emergencyEStop, deadmanWatchdog, and bounded motion (Limits).ServoMap/Esc/Quadrature/QuadratureScale- servo and ESC pulse widths and quadrature-encoder decoding.Twist/Pose- the shared body-velocity and world-pose types the robotics helpers use.Coordinate/Geofence- great-circle distance and bearing, and leaving a safe area (behind the defaultgeofeature).imu- roll and pitch from a three-axis accelerometer (behind theimufeature).weather- the dew point from temperature and humidity (behind theweatherfeature).
The geo, imu, weather, and robotics features each pull in libm for no_std float
math and can be turned off on the most constrained targets; the waypoint guidance needs both
robotics and geo.
The crate is no_std and allocation-free, so the same helpers run on a
microcontroller and on a server.
§Examples
Compose two helpers to hold a noisy fridge probe near 4 C:
use pamoja_kit::{Smoother, Thermostat};
let mut probe = Smoother::new(0.5);
let mut fridge = Thermostat::cooling(4.0, 0.5);
// A warm, noisy reading is smoothed, then drives the cooler on.
let cooler_on = fridge.update(probe.update(7.8));
assert!(cooler_on);Modules§
- imu
- Tilt from a three-axis accelerometer.
- units
- Converting readings between real-world units.
- weather
- Humidity-derived values: the dew point.
Structs§
- Ackermann
- Car-like (Ackermann) steering: one steered axle and a driven axle a wheelbase apart.
- Anomaly
- Flags a reading that lies far from the recent norm.
- Calibration
- A linear map from raw sensor counts to calibrated units.
- Complementary
- Blends a drifting rate measurement with a noisy absolute one into a steady estimate.
- Coordinate
- A position on the Earth, in decimal degrees.
- Debounce
- Cleans a noisy boolean signal by requiring it to hold steady before reporting a change.
- Depletion
- Predicts how soon a falling level will reach a threshold.
- DhParameters
- The four Denavit-Hartenberg parameters describing one joint-to-joint step of a serial arm.
- Diff
Drive - Converts between a robot’s motion and its two wheel speeds (differential drive).
- EStop
- An emergency stop that latches: once engaged it holds until explicitly reset.
- Esc
- Maps a normalized throttle to an electronic speed controller’s RC pulse width.
- Geofence
- Keeping a tracked point inside an area, and noticing when it leaves.
- Guidance
- The steering command toward a waypoint, with the geometry behind it.
- Kalman
- Estimates a steady value from noisy readings with a one-dimensional Kalman filter.
- Limits
- Bounds a robot’s speed and acceleration so commands stay within what the machine can do safely.
- Mecanum
- Mecanum (four-wheel omnidirectional) drive: forward, sideways, and turning at once.
- Median
- A median filter over the most recent
Nreadings. - Odometry
- Tracks a robot’s
Poseby accumulating its motion over time (odometry). - Pid
- Drives a measured value to a target by blending proportional, integral, and derivative terms.
- Pose
- A planar pose in the world frame: position and heading.
- Quadrature
- Decodes a quadrature (A/B) encoder into a running tick count.
- Quadrature
Scale - Converts encoder ticks into the distance and speed a wheel has travelled.
- Ramp
- Moves a value toward a target by at most a fixed step each update.
- Safety
Gate - The single gate every motion command passes through, composing e-stop, watchdog, and limits.
- Servo
Map - Maps a servo angle to its RC pulse width in microseconds, and back.
- Skid
Steer - Skid-steer (tracked or four-wheel) drive: turning by spinning each side at a different speed.
- Smoother
- Smooths a noisy signal with an exponential moving average.
- Surge
- Warns when a reading changes faster than a safe rate.
- Thermostat
- A hysteresis (bang-bang) controller for a single on/off actuator.
- Transform
- A 4x4 homogeneous transform: a rotation and a translation in one matrix.
- Trend
- Tracks the linear trend of the most recent
Nreadings. - Twist
- A planar body velocity: the command a wheeled robot is driven with.
- TwoLink
Arm - A planar two-link arm: the textbook arm with a closed-form inverse.
- Watchdog
- A deadman timer: it expires unless fed often enough, catching a stalled controller or link.
- Waypoint
Follower - Guides a robot from waypoint to waypoint by GPS-style coordinates (carrot following).
- Wheel
Speeds - The four wheel speeds of a mecanum or omni base, front and rear, left and right.
- Window
- A fixed-capacity window over the most recent
Nreadings.
Enums§
- Boundary
- Where a fix sits relative to a
Geofence, including the moment it crosses. - Elbow
- Which way a two-link arm’s elbow bends; both reach the same point.
Functions§
- deadband
- Holds a reading at a center value while it stays within a band, ignoring small wiggle.
- forward_
kinematics - Returns the transform from the base to the tool for a serial arm of DH joints.
- obstacle_
stop - Stops forward motion when an obstacle is within the stopping distance, leaving turning free.