GithubHelp home page GithubHelp logo

tinyekf's Introduction

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

TinyEKF is a simple, header-only C/C++ implementation of the Extended Kalman Filter that is general enough to use on different projects. It supports both single- and double-precision floating-point computation. In order to make it practical for running on Arduino, STM32, and other microcontrollers, it uses static (compile-time) memory allocation (no "new" or "malloc"). The examples folder includes both a "pure C" example from the literature, as well as an Arduino example of sensor fusion. The python folder includes a Python class that you can use to prototype your EKF before implementing it in C or C++.

Arduino users can simply install or drag the whole TinyEKF folder into their Arduino libraries folder. The examples/SensorFusion folder contains a little sensor fusion example using a BMP180 barometer and LM35 temperature sensor. I have run this example on an Arduino Uno and a Teensy 3.2. The BMP180, being an I^2C sensor, should be connected to pins 4 (SDA) and 5 (SCL) of the Uno, or pins 18 (SDA) and 19 (SCL) of the Teensy. For other Arduino boards, consult the documentation on the Wire library. The analog output from the LM35 should go to the A0 pin of your Arduino or Teensy.

In addition to the class definition, the python folder has an example of mouse tracking, using OpenCV. So you will have to install OpenCV to run this example. There is also a sensor-fusion example in this folder.

tinyekf's People

Contributors

guglie avatar jenskern avatar simondlevy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinyekf's Issues

SensorFusion Example

Is Line 50 correct ???

        hx[2] = this->x[1]; // LM35 temperature from previous state

Should it be (index 2 for LM35) ???:

        hx[2] = this->x[2]; // LM35 temperature from previous state

Use library - get matrix

Hi,
I'm looking to correct the position given by my GPS (NEO-M8T) with the use of an IMU.
How can I get the matrix to use your algorithm?

I tried your example with the temperature readings and worked pretty well, But now I want to fuse two different things.

Best Regards

Have no SFE_BMP180.h

When i use the code and have the error :no such decirtory SFE_BMP180.h,i don't know why .I just have imu and magnetometer.Looking forward your reply!

Predicting translation xyz values?

Hi, thank you for making this code available. I have some sensor measurements that come in at 30Hz. I need to 'upsample' this data to 60Hz, so am looking at the kalman filter to predict the measurements in between the samples. Is your filter suitable for this? If you have a minute, would you be able to point me in the right direction to do this using your code? Thank you!

Examples ekf.step(z) call does return an failure value (=1) - Why?

Hello I tried to get the Arduino examples working. Started with the Benchmark example - does run OK. Then the SensorFusion example. I have adapted this to the BME280 and mentioned than every cycle ekf.step(z) does return an '1' value which is a failure as read in tiny_ekf.h "caused by non-positive-definite matrix" from (trapped in choldc1()).
I have checked all, but couldn't find any issue. Then I had a look to the Benchmark example. The result is the same.
The estimated x values vector does reach their target value after some steps.
I'm not sure what does failure really mean. Is this correct? Is it a real problem - or an bad model?

Asynchronous sensor readings

Great tutorial and codebase Simon. It cleared up quite a bit of the concepts behind an EKF.

I am seeing some limitations with TinyEKF and I would like to know if this is right:

  • The filter cannot handle null data. If new measurements are received for only one sensor, we can either filter using old data for the other sensor (making it appear as if it was new data that just happened to be exactly the same), or wait until we have new data for each sensor.

  • The filter cannot handle variable timesteps. The measurement function is not based on any timestamps and I assume needs to be hardcoded for a specific timestep.

To be clearer, I was planning on using this filter to fuse orientation data coming from 2 sensors at different rates. I can deal with a fixed timestep, but reusing old data for the slower sensor is problematic, as well as waiting for it to update.

Delta t Variable in Model Method

I may be reading this wrong, but I don't see a delta t passed to the model method. I'm trying to find the position using the previous velocity is integrated with respect to dt: Fx[0] = this->x[0] + this->x[1]*dt. In this case position is the zero index and velocity is the one index.

I must be missing something, am I supposed to pass delta t via the state vector?

Matrix dimensions in error covariance update step incorrect?

On this line, the vector z-hx of size m is multiplied by the matrix G, of size n x m:
https://github.com/simondlevy/TinyEKF/blob/master/src/tiny_ekf.c#L321

The result of which is a vector of size n, not the m x n matrix tmp2 that the result is written into.

Now I'm not using the provided matrix functions so I can't say if this works or not, but regardless it's confusing when reading the code and could introduce issues. There should be a tmp6 array of size n that the multiplication of G with z-hx is written into, and used in the subsequent addition with fx to obtain x.

Help needed in velocity estimation

Hi,
I am new to kalman filters and this library has proved very useful to me as a stepping stone to learn more about them. I wish to implement the estimation of velocity using this library. I have one sensor giving out only velocity values and another sensor giving me acceleration values. So my model would be-
V(k)=V(k-1)+a.t
A(k)= A(k-1)
However i am unsure where to put this. Does this go in the process model or my measurement function? I am confused and would be grateful if you could help. Thanks.

TinyEKF For GPS filtering?

Is that possible to use this library for GPS Coordinates, I'm getting GPS latitude and longitude from my gps module, is that possible to filtered out the noise using this library?

C#

Any chance of a C# implementation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.