-
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
Filter: protect against extremely low notch filter frequencies #25352
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.
I think its better to change the existing limit in the init_with_A_and_Q
function so initialised
is never set true.
This line:
if ((new_center_freq > 0.0) && (new_center_freq < 0.5 * sample_freq_hz) && (Q > 0.0)) { |
Would become:
if ((new_center_freq > 2.0) && (new_center_freq < 0.5 * sample_freq_hz) && (Q > 0.0)) {
I think #25355 is the root of this issue. |
60a1e96
to
5fab0e9
Compare
as noted on that PR, that does not properly fix the issue |
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.
All looks good. I think the zero check on last_update_ms
is needed in lots more places. Might be worth a helper function. There are 8 places that check the timeout.
@@ -107,7 +107,7 @@ uint32_t AP_ESC_Telem::get_active_esc_mask() const { | |||
// have never seen telem from this ESC | |||
continue; | |||
} | |||
if (now - _telem_data[i].last_update_ms >= ESC_TELEM_DATA_TIMEOUT_MS | |||
if ((_telem_data[i].last_update_ms == 0 || now - _telem_data[i].last_update_ms >= ESC_TELEM_DATA_TIMEOUT_MS) |
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 though @WickedShell already had a helper for this?
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 do think a helper woulud make this clearer
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.
added stale() helper
Yes, but its still a valid change. I think we need both changes. |
an incorrectly configured ESC telemetry source can lead to a notch running at very low frequencies. A simple example is a lua script like this: function update() esc_telem:update_rpm(12, 0, 0) return update, 10 end return update() where motor 12 is unused. with that script in place we get a 1.0078 Hz filter which leads to massive phase lag and a crashed aircraft this is a safety protection. We should also try to find out why the INS_HNTCH_FREQ lower limit is not working
5fab0e9
to
b03933b
Compare
prevents use of stale data when close to zero time
b03933b
to
a4c3f67
Compare
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.
LGTM
I think this is the wrong change. I have updated https://github.com/ArduPilot/ardupilot/pull/25355to reflect what I think should go in. I was going to put a blocking review on this and now wish I had. Please, please can we have a little more discussion. |
I had a look, and it doesn't really fix the problem. It still ends up running the uninitialised RPM sources at the min frequency. |
an incorrectly configured ESC telemetry source can lead to a notch running at very low frequencies. A simple example is a lua script like this:
function update()
esc_telem:update_rpm(12, 0, 0)
return update, 10
end
return update()
where motor 12 is unused.
with that script in place we get a 1.0078 Hz filter which leads to massive phase lag and a crashed aircraft. I suspect the 1.0078 is the last value from the slew limiter before we hit 1.0 Hz
Note: this is a safety protection. We should also try to find out why the INS_HNTCH_FREQ lower limit is not working
this is what the filtered (in red) vs unfiltered (in green) looks like with the above lua script for a quadplane takeoff in QLOITER in SITL:
this is the same test with the protection in place: