Multicalc: Scientific computing for real-time embedded systems in no_std Rust

3d_drone_showcase

multicalc is my Rust crate for scientific computing on real-time embedded systems. Estimation, control, kinematics, dynamics, Lie groups, calculus, autodiff and linear algebra in safe no_std Rust.

What you're seeing: A Skydio X2 loaded from its MuJoCo model, localizes itself with particle filter, then flies a minimum-snap waypoints on a noisy IMU plus GPS. Also features a 15-state error-state EKF, an LQR position loop and a geometric attitude controller. The whole stack in a median ~2 µs of each 1 ms tick.

What's new:

  • MuJoCo integration: Load MuJoCo robot models directly into native multicalc types. Perform kinematics, control and dyanamics in rust on the MuJoCo managerie.
  • Estimation: unscented KF, error-state KF with IMU bias estimation, Madgwick and Mahony attitude filters.
  • Control: infinite-horizon Lqr, GeometricAttitudeController, solve_discrete_riccati / solve_discrete_lyapunov.
  • Signal processing: biquads (low/high/band/notch), cascades, rotor-harmonic notches, moving average, running median, Savitzky-Golay, deadband/hysteresis/slew limiting.
  • Polynomials: closed-form real roots to quartic, piecewise and multivariate polynomials with symbolic partials, MinimumSnapPlanner.

Still enforced:

  • 1 kHz loops. No heap, fixed-size types, bounded work per call.
  • Six embedded targets: x86_64 and aarch64 Linux hosts plus four bare-metal ABIs (thumbv7em soft-float and hard-FPU, thumbv6m, riscv32imc), running under QEMU with no_std, no-alloc and no-panic rules enforced on each.
  • Measured against external references: Per-module fixtures from numpy, scipy, filterpy, mpmath and mujoco agreeing to ~1 ulp. Tables are in the repo.

We are over a dozen contributors strong now, with roughly one external contribution coming in every single day! Lets gooooo! Coming up next is articulated whole body dynamics (RNEA/CRBA/ABA), robot arm kinematics and dynamics natively in rust validated against Pinocchio.

Come build it. 50 open good first issues right now, each small and self-contained, out of 87 open total. If you like numerical methods, autodiff, embedded Rust, or robotics, I'd love the help.

You may want to keep an eye open for my zero-cost unit-safe linear algebra library, WhippyAlgebra, within the next week or two. Initial release will wrap nalgebra, but other adapters can/will be added. Seems like it might integrate well :slight_smile:

Here's a sample of a fully unit-safe LQR for optimal DC motor control gains: unitsafe lqr · GitHub

Same post a few days ago... Here it is better to reuse the previous thread if you are announcing a new version.

no_std numerics always hits the same fork: depend on libm for transcendentals, or ship your own approximations. Which way did you go?

Asking because on real-time targets the usual complaint is not accuracy, it is that sin/cos have data-dependent timing. If you have bounded-iteration implementations with a worst case you can actually state, that belongs near the top of the README. For anyone writing a control loop it is the thing that decides adoption.

Also, is there fixed-point support, or f32/f64 only? A good chunk of the real-time embedded crowd cannot use floats at all.