pamoja-kit 0.1.8

Goal-named helper math for the pamoja device SDK: smoothing/filtering, calibration and units, PID and on/off control, prediction and anomaly detection, rolling stats, differential-drive kinematics, and geo/IMU/weather helpers; no_std-friendly.
Documentation

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] - convert between a robot's motion and its two wheel speeds.
  • [Coordinate] / [Geofence] - great-circle distance and bearing, and leaving a safe area (behind the default geo feature).
  • [imu] - roll and pitch from a three-axis accelerometer (behind the imu feature).
  • [weather] - the dew point from temperature and humidity (behind the weather feature).

The geo, imu, and weather features each pull in libm for no_std float math and can be turned off on the most constrained targets.

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);