peterhinch / micropython-filters

Digital filters impemented in MicroPython's inline ARM Thumb assembler (e.g. Pyboard, RP2).
MIT License
64 stars 13 forks source link

Kalman? #1

Open street-grease-coder opened 3 years ago

street-grease-coder commented 3 years ago

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

peterhinch commented 3 years ago

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.

street-grease-coder commented 3 years ago

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 commented 3 years ago

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

peterhinch commented 3 years ago

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?

street-grease-coder commented 3 years ago

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