The Micro Kalman Filter Library
A library for Kalman filtering, state estimation, and sensor fusion on memory constrained microncontrollers and embedded systems. The library is built on top of μLAPack, a micro linear algebra package optimized for memory constrained systems, and can run on any target that C can be compiled for.
μKal is a full discrete-time Kalman Filtering library. The library can filter linear, and non-linear, systems via an Extended Kalman Filter (EKF) or second-order filter (SOF).
All μKal functions are "safe" in that the matrix/vector operations are checked for initialization and mathematic dimensional legality before an operation takes place. The library contains various operations and manipulations that can be configured to your needs. The library can be configured to run safely in even the most constrained environments where memory allocation is a concern.
- Create a state space model filter
- Set the filter type:
- Set the filter type:
- Predict state values (Kalman Predictions)
- Filter Sensor measurements (Kalman Updates)
- Update functions -
- For non-linear systems, you may set the nonlinear state vector and observation dynamics
- Safe getters and setters for the state vector, covariance matrix, and more!
If you have model that looks like this:
And you have a measurement model that looks like this:
And you know your covariance matrices:
Then you can immediately begin filtering after creating your filter, and initializing the matrix/vector values:
ukal_filter_create(&my_filter, <linear, ekf, or sof>, n_states, n_measurements,
&Phi, &gamma, &x, &Q,
Don't have a system that looks like that? Want to learn how to make your system fit that form? See an example using μKal for an EKF to learn more about modeling a system, and using μKal to filter noisy sensor measurements for linear and nonlinear systems.
Want to predict the current state vector and covariance matrix value?
Got a sensor measurement, and want to update your estimate of the state and the covariance matrix?
For a build example, see tests/Makefile for an example of how to compile the project with proper option settings and linking.
Some basic building options are configured in the project, but any μLAPack option can be configured as desired.
Static Memory Allocation
The library is implemented on top of μLAPack, and is configured to run only with statically allocated memory. This library is safe and ready to use on an embedded system where dynamic memory allocation is not feasible.
Choose Your Entry Container Type
The user of this library has the option of setting the matrix/vector element data type to a desired type via the
Clear Upon Initialization
All new matrix/vector objects made can be initialized to zeros if
ULAPACK_INITIALIZE_MEMORY is defined at compile time.
Matrix Inversion Options
ULAPACK_INVERSE_VIA_LU to use LU decomposition for matrix inversions.
μLAPack was developed using test-driven practices. The unit tests and
Makefile for building and running the unit tests are in the
tests/ directory. Included is an implementation of an Extended Kalman Filter to serve as an example.
The following error codes can be returned from the library functions. See the in-file documentation for the function to check its return codes of type
ukal_error- general error code
ukal_invalid_argument- bad argument given to function
ukal_uninit_obj- uninitialized object passed into function
ukal_success- general success code
Licensing & Support
μKal is free to use for personal and/or educational use without profit and for development purposes in your project(s) to verify if μKal is right for you.
For developers and for derivative commercial use (with redistribution rights): Fill out the licensing inquiry form, and I will promptly reply with a response and proposed license agreement.
Refer to the LICENSE document for licensing details.
- Make the README look prettier
- Add examples to README file itself and not just the examples directory.
Have a suggestion for a new feature/function? File an issue in this repository with your requests.