# [Submission] Unscented Kalman Filter Library

So I wanted an unscented Kalman Filter (UKF) for my project, so after putting in the effort for it, I thought I’d share it with the rest of the world. It’s based on a Matlab UKF from here, with matrix functions from the MatrixMath arduino library. I think that it should work for most scenarios, but no guarantees. I haven’t even had a chance to try it on a live Core, so all I really know is that it compiles, and it runs on an Arduino emulator. Anyways, feel free to use it, and let me know if there are problems that you find! Here is the Github page for it, and I believe I published it on the Web IDE.

7 Likes

Hi MumblePins,

I want to use this library in my Arduino project. I successfully imported the library to Arduino, but I don’t know how it works… also, I need to adapt to my project but IDK how to start dealing with it. Could you please give to me some examples? If possible, there’s another implementation of UKF for an Arduino?

Many thanks.

Manuel

As far as I know, there isn’t another implementation of the UKF on the Arduino. I wrote up the example as just a simple test of the code, and nothing more. The Arducopter code uses an Extended Kalman Filter (another non-linear adaptation of the Kalman Filter) when running on the Pixhawk hardware, which is also a Cortex proc. I never got around to using this library in my own project, and just went with a PID controller and manual tuning. I’d suggest lots of reading on the control and filtering theory before trying to use this. At a minimum, you need to know some a priori info about your system response and measurement error. And then figure out how to make it useful. Good luck!

2 Likes

Thanks, I’m working on adapt the example to my work. I’ve a problem of interpretation of the information in your example, can you help me please?

I had the following generated temperatures:
0.00 0.31 0.61 0.92 1.22 1.53 1.84 2.14 2.45 2.76 3.06 3.37 3.67 3.98 4.29

and the result is presented as:
xv
0.00 0.31 0.61 0.92 1.22 1.53 1.84 2.14 2.45 2.76 3.06 3.37 3.67 3.98 4.29 (first row)
3.92 3.82 3.70 3.55 3.39 3.22 3.05 2.88 2.73 2.58 2.46 2.36 2.29 2.25 2.25 (second row)
200.07 200.08 200.10 200.13 200.16 200.19 200.23 200.27 200.31 200.36 200.41 200.47 200.53 200.59 200.65 (third row)

I assume that the first row is the measured temp, the second row is the Kalman Estimation for Temp. and the third row is… (I’ve no clue about it), but, the current/inital state is set as x[] = {15, 2, 200};

Thanks again Mumblepins.

1 Like

Well, if you’re following the example in the library, it’s intended for a simple heating problem, such as an electric oven or something, and the three state values are temperature, insulation value, and thermal mass. Temp is assumed to be a perfect measurement, so that’s why it perfectly matches the given value. Instead of trying to smooth out the data (like it would be used on Ardupilot), what it’s trying to do here is characterize the heating system on the fly, to probably be used in conjunction with an autotuning PID loop or something like that. I probably could have done a better job of commenting the example… Sorry As I said, a lot of the code was relatively copied from the Matlab example, so take a look at that for some more details.

Thanks Mumblepins, I was unsure about that but now all is clear many thanks for your patience.

1 Like