Skip to content

Repository files navigation

Fixed point Kalman filter library

CI

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.

Building

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-failure

Or with go-task (see Taskfile.dist.yaml):

task build      # configure + compile
task example    # run the gravity example
task test       # run the ctest suite

Compile-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.

About

Kalman filter fixed-point implementation based on libfixmatrix, targeted at embedded systems without an FPU and/or need for performance.

Topics

Resources

Stars

78 stars

Watchers

15 watching

Forks

Releases

Packages

Contributors

Languages