libfixkalman is a Kalman filter computation library for microcontrollers. It is based on the libfixmatrix and libfixmath libraries, which use 16.16 bit fixed point values. The main focus is processors without an FPU, such as ARM Cortex-M0 or M3.
A 🦀 Rust variant, albeit not a direct port, is available at sunsided/minikalman-rs.
Matrix inversion in the correction step is implemented using Cholesky decomposition and an optimized inversion algorithm ported from EJML.
See the function reference for further details and example_gravity.c for example code.
The library depends on libfixmath and libfixmatrix. These are not published on
any current package remote, so the CMake build fetches them straight from GitHub
(pinned commits) via FetchContent - no package manager required.
With CMake:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failureOr with go-task (see Taskfile.dist.yaml):
task build # configure + compile
task example # run the gravity example
task test # run the ctest suiteCompile-time options (pass as -D<option>=ON, or via task build -- -D...):
| Option | Effect |
|---|---|
FIXMATRIX_MAX_SIZE (=8) |
Max matrix dimension; >= #states / #inputs / #measurements |
KALMAN_JOSEPH_FORM |
Joseph-form covariance update |
KALMAN_TIME_VARYING |
Covariance prediction uses B*Q*B' |
KALMAN_DISABLE_C |
Drop functions for systems with control inputs |
KALMAN_DISABLE_UC |
Drop functions for systems without control inputs |
KALMAN_DISABLE_LAMBDA |
Drop certainty (lambda) tuning |
Continuous integration builds and runs the example across these configurations;
see .github/workflows/ci.yml.
