mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 03:23:34 +08:00
Merge branch 'master' into vector_control2
This commit is contained in:
@@ -46,6 +46,10 @@ namespace math
|
||||
void LowPassFilter2p::set_cutoff_frequency(float sample_freq, float cutoff_freq)
|
||||
{
|
||||
_cutoff_freq = cutoff_freq;
|
||||
if (_cutoff_freq <= 0.0f) {
|
||||
// no filtering
|
||||
return;
|
||||
}
|
||||
float fr = sample_freq/_cutoff_freq;
|
||||
float ohm = tanf(M_PI_F/fr);
|
||||
float c = 1.0f+2.0f*cosf(M_PI_F/4.0f)*ohm + ohm*ohm;
|
||||
@@ -58,6 +62,10 @@ void LowPassFilter2p::set_cutoff_frequency(float sample_freq, float cutoff_freq)
|
||||
|
||||
float LowPassFilter2p::apply(float sample)
|
||||
{
|
||||
if (_cutoff_freq <= 0.0f) {
|
||||
// no filtering
|
||||
return sample;
|
||||
}
|
||||
// do the filtering
|
||||
float delay_element_0 = sample - _delay_element_1 * _a1 - _delay_element_2 * _a2;
|
||||
if (isnan(delay_element_0) || isinf(delay_element_0)) {
|
||||
|
||||
Reference in New Issue
Block a user