simondlevy/TinyEKF logo

simondlevy/TinyEKF

Free

Lightweight C/C++ Extended Kalman Filter with Python for prototyping

FreeFree tier
Type
Open Source

About simondlevy/TinyEKF

TinyEKF is a lightweight, header-only C/C++ implementation of the Extended Kalman Filter (EKF) designed for embedded systems and rapid prototyping. It uses static (compile-time) memory allocation, making it suitable for microcontrollers such as Arduino and STM32, and supports both single- and double-precision floating-point computation. The repository includes examples for pure C sensor fusion (using a BMP180 barometer and LM35 temperature sensor) and a Python class with an OpenCV mouse-tracking example for prototyping before deploying to C/C++.

Key Features

Header-only C/C++ implementation of Extended Kalman Filter
Static (compile-time) memory allocation – no dynamic memory (no new/malloc)
Supports both single- and double-precision floating-point
Includes Python class for prototyping EKF before C/C++ deployment
Arduino-compatible with example sensor fusion using BMP180 and LM35
Python mouse-tracking example using OpenCV

Pros & Cons

Pros
  • Lightweight and efficient for resource-constrained devices
  • No dynamic memory allocation reduces memory fragmentation risk
  • Supports both single and double precision for flexibility
  • Python prototyping allows rapid iteration of filter models
  • Includes practical examples for sensor fusion and mouse tracking
Cons
  • Only implements the Extended Kalman Filter (no UKF, particle filter, etc.)
  • Requires manual formulation of system and measurement models (Jacobians)
  • No built-in noise estimation or adaptive tuning
  • Limited to static memory allocation – may not suit all applications

Best For

Sensor fusion on Arduino/STM32 microcontrollersState estimation for robotics and embedded systemsPrototyping Kalman filters in Python before porting to C/C++Academic projects teaching Extended Kalman Filter concepts

FAQ

What is TinyEKF?
TinyEKF is a simple, header-only C/C++ implementation of the Extended Kalman Filter that is general enough for different projects and supports both single- and double-precision floating-point.
Does TinyEKF support Arduino?
Yes. It uses static (compile-time) memory allocation, making it suitable for Arduino and other microcontrollers. An Arduino sensor fusion example using BMP180 barometer and LM35 temperature sensor is included.
Can I prototype my EKF in Python before using C/C++?
Yes, the python folder includes a Python class that you can use to prototype your EKF before implementing it in C or C++. There is also a mouse-tracking example using OpenCV.
Does TinyEKF use dynamic memory allocation?
No, it uses static (compile-time) memory allocation. No new or malloc is used, making it practical for running on microcontrollers.