micropython-filters icon indicating copy to clipboard operation
micropython-filters copied to clipboard

Kalman?

Open street-grease-coder opened this issue 5 years ago • 5 comments

Looking for an easy implementation of a Kalman filter... in case this is a valid enhancement idea/request

street-grease-coder avatar Oct 30 '20 23:10 street-grease-coder

It's certainly a good idea. Have you done a search to see if it's already been done?

I did experiment with them when playing with my balancing robot but settled on a complementary filter. It's perhaps worth noting that I developed these filters before the advent of loadable C modules. These have the advantage of portability. In the case of my DFT implementation there is evidence that C code can actually be faster. So any new filter work would have to weigh up the relative advantages of C and asm.

At the moment I'm working on other things so I won't be able to look at this for at least a couple of months.

peterhinch avatar Oct 31 '20 08:10 peterhinch

extensive search, I did not find any standalone github code unfortunately :-( it's something I was counting on when switching away from Arduino libraries, I'll try to learn and write it

street-grease-coder avatar Oct 31 '20 11:10 street-grease-coder

Here's some code I found, finally, from a talk https://github.com/lblackhall/pyconau2016

street-grease-coder avatar Oct 31 '20 14:10 street-grease-coder

That's pure Python which is undoubtedly the easy way to do it if performance is not an issue. The focus of this repo is on realtime performance for hardware projects. If your interest is in non-realtime applications I'd consider porting the code you cited above. Perhaps there is a way to take advantage of ulab - a numpy subset here?

peterhinch avatar Nov 01 '20 15:11 peterhinch

I posted here as an idea for efficient implementation. Numpy is for bleeding beginners like me out of range because micropython has to be compiled for it to be included (i.e. to include ulab) - at least if you want to use the latest version. Personally porting the cited code will take beginners like me a suborbitant amount of time, it's sad that to be time efficient this (in all likelihood) forces me to use the moving average filter

street-grease-coder avatar Nov 03 '20 12:11 street-grease-coder