-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LULU filter by C.H. Rohwer -- nonlinear filter which seems to work nicely on the d-term #748
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of idea/considerations. I'm going to try this filter on a mine feature where I need a good dTerm filtering!
I added the changes to my repo as requested, and fixed an OSD issue I caused that didn't allow LULU to be selected as a DTERM filter from the OSD. It was only accessible via CLI. |
Let me know how it goes! I'm unreasonably excited about this, it took me a month to test and optimize until it worked fast enough for use in a flight controller at reasonable speed. |
all tabs in |
care to rebase on master? |
This LULU needs to be made up to date with the LULU in Inav as its more up to date. |
Added the LULU filter as an option for D-term and gyro filter It's garbage for gyro filtering. Don't do it. Set the DTerm filter to type LULU in the CLI. Not accessible via GUI. This has been fixed to N=10 in filter.h, changeable to anything you like PROTOTYPE CODE USE AT OWN RISK
Added debug info Removed LULU on gyro
Fixed IMU menu Fixed trailing commas
to reduce aliasing and remove all bump sizes up to N Heavily optimized Roadmaker's algorithm
Added lulu.c to speed-optimized part of compiled code
I've rebased, still to test. Please don't merge yet! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've batched together a few tab-to-spaces recommendations.
Co-authored-by: nerdCopter <[email protected]>
Thanks for the review, appreciate it! Please let me know if I need to change anything else :) |
Please change the code from Allman indentation to K&R indentation style. https://en.wikipedia.org/wiki/Indentation_style |
Updated indentation
Tested this morning, pretty happy with it. If you're happy, I'm happy to get it merged. :) Apologies if I missed any tabs-to-spaces things, please note if I did, will search again. |
It actually works best on gyro, and a simple pt1 lowpass on dterm sorts out all the relevant noise on there on all my quads. Might differ for others, but it's quite alright. Note it runs slowly so check CPU use when testing!! |
you mentioned gyro, but it seems this code is only for dTerm, correct? |
@Quick-Flash , many things are gated |
Co-authored-by: nerdCopter <[email protected]>
Hi! I did lots of tests, but the bottom line is one LULU on gyro, one dynamic filter one notch and one PT1 on dterm sorts out the filtering on all my crafts tested. 40mm, 2", 3", 5". I did experimental tests on removing the gyrofiltering before calculating the slope, then doing LULU on the "raw" derivative, which worked very well too. This was not implemented, so I think only gyro is best option here. |
|
Yeah, I think it's already available to put on the gyro in the code here if you can select it as an alternative to PT1, right? I'll pull it again and make sure, but I think so.
I understand. This version is improved beyond the current iNav one, and I intend to push the update to iNav as well. Thank you for considering to merge!
I understand. Thank you for noting this!! |
ah wow, even my comments were incorrect, sorry. Thanks for fixing! |
Id like to see it as a CLI or OSD thing that can be added independently of the other gyro filters. |
I'll put that in my queue, thank you for letting me know!
|
Hi!
As in the title :)
It's an implementation of the LULU filter by C.H. Rohwer at a university in our country.
For reference: https://en.wikipedia.org/wiki/Lulu_smoothing
I've optimized it to O(N) complexity and it seems to work OK now. It's still quite slow so check CPU use before flying.
I've enabled it on the d-term only. If anyone wants a gyro filter with this, I checked it and I don't think it's the best use of it, but perhaps my experience was not the most representative so let me know?
In the CLI or on the OSD you can set a new lowpass filter type, LULU. In the advanced PID options on the OSD, right at the end there's now a LULU N value. Set N to an appropriate value, see the CPU usage, test, repeat. It's a global N value as a two LULU filters over each other with different N values just keep the highest N value, it's the nature of the mathematics. Don't do two lulu filters, it's supposed to do nothing except add delay (assuming I implemented correctly).
I've added OSD elements and a debug trace in case someone wants to see what the D-term looks like before and after the d-term. Debug on the pitch and roll only, before and after d-term filter. The debug bit still needs to be properly tested, it was a late night.
Above is too little LULU. It makes squarewave type stuff on the d-term. N=6 .
This is a better amount of LULU, 8kpid N=12. Still not perfect, but given that this is the only static filter I use on the above in addition to dynamic filter and kalman, think that's quite alright.
If someone wants to test it, here it is. I believe the delay in the filter is approximately N+1 samples, so if you're running 8kpid with lulu_n_val at 12, that's 13/8000 = 1.625ms delay for this filter, which I believe is quite alright!
I've found my MATEKF411 target likes N=6 or N=7 at 4k pid, while my HGLRCF722 is alright with N=12 about at 8kpid. Graphs from HGLRCF722, don't have a logger on the other one.
Kind regards,
pjpei