-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
AP_InertialSensor: init all notch center frequencies #25355
Conversation
@IamPete1 @andyp1per this fixes part of the problem but not all of it, at least with 4.4.x. With this fix we no longer get the filters down at 1Hz, but with 4.4.x we end up with 48 notch filters all at 40Hz with the following parameters:
for 4 motors we should end up with 12 at 40Hz, 12 at 80Hz, 12 at 120Hz and 12 at 160Hz. When ESC telemetry gives zero RPM we squash them all down to 40Hz (they are actually 39.68Hz, 40Hz and 40.3Hz as that is the triple notch spread) instead of correctly spreading them out on the harmonics. |
@tridge Any tips to reproduce? I'm haven't been able to on master. For frequencies under the cut off we could "phase out" the filter. The lower frequency then becomes a attenuation limit. So the notch will track under, but it will end up with 0 attenuation. Betaflight does something like this, uses is weighted average between notched and un-notched. Something like this so we track that amplitude set by the user cutoff: Or just pick our own easier to work out method. The key thing it to bring them in and out smoothly. I don't think we would want a straight enable/disable threshold. The other question is what should be done if the ESC telem becomes unavailable completely. Currently we will fall back to throttle notch, but that is extremely unlikely to do anything sensible with the configuration set for ESC's. We have inadvertently created a case where loss of ESC telem can crash a vehicle. |
@IamPete1 here are 3 logs showing the problem in SITL:
I propose we merge my simple fix now, and work towards something more comprehensive in future |
@IamPete1 this is the phase lag with your change: |
@tridge All 6 notches at set min frequency is the correct behavior in this case? If it crashes there then it will also crash with all the motors anywhere between 0 and 2400 rpm (40 Hz)? If the cut off is set so low that the vehicle crashes isn't that just a miss configuration? |
I don't think the cutoff was set low was it? I agree that if it crashes with the notches sitting at the configured value then that's down to misconfiguration, but I thought what actually happened was the frequencies went far below this because of the bad initialization. I do think we should do something simple here for 4.4 - more complicated things will need much more testing as the outcomes are not always predictable. Presumably switching the filter on and off could generate shot noise? If that's true then you phasing idea seems reasonable to me. I do think we should get some input from @priseborough and @lthall on whatever is proposed. |
that assumes they ever could all be non-zero but below min freq. On both the SITL test and in the real aircraft this is not actually true. |
I would argue that that is a scripting bug in that case not a AP one. All this patch does is make all the notches behave the same as the first one. If that is incorrect then the bug already exists now for the first notch. |
I think removing the init of the first one would be better |
I have been looking over this and I think the best way forward is to initially fix the current code then add the new functionality that Tridge has described. After a quick look this PR looks like it takes care of the first step and is probably going to be safe to back port if needed. I would suggest we start with the simplest fix then add the extra features Tridge is suggesting as a separate PR afterwards. edit: I have moved the rest of the points to #25461 as it isn't relevant here. |
@lthall thanks Leonard! |
@@ -962,7 +962,9 @@ AP_InertialSensor::init(uint16_t loop_rate) | |||
if (!notch.params.enabled() && !fft_enabled) { | |||
continue; | |||
} | |||
notch.calculated_notch_freq_hz[0] = notch.params.center_freq_hz(); |
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.
for 4.5.x I want to remove all these lines and leave the value as zero, meaning unitialised.
The calculated_notch_freq_hz array is an array of observed frequencies from ESCs. We have not observed this frequency in the init, so we should not be filling in a false value
we should handle the zero in the filter
this has helped find multiple bugs
this gets the right number of notches on quadplanes, but is still very bad in fwd flight
465c415
to
dc5373a
Compare
this was flown successfully on 2 vehicles, one a quadplane with throttle notch and a 5" quad with ESC multi-source notch |
We were only setting the first notch center freq. If multi source data is missing it just does a hold on that channel so if never init and never getting data it can be stuck holding at that 0 value.