|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
27 #ifndef LOW_PASS_FILTER_H
28 #define LOW_PASS_FILTER_H
33 #define INT32_FILT_FRAC 8
144 float K = tanf(sample_time / (2.0
f * tau));
145 float poly =
K *
K +
K / Q + 1.0f;
146 filter->
a[0] = 2.0f * (
K *
K - 1.0f) / poly;
147 filter->
a[1] = (
K *
K -
K / Q + 1.0f) / poly;
148 filter->
b[0] =
K *
K / poly;
149 filter->
b[1] = 2.0f * filter->
b[0];
150 filter->
i[0] = filter->
i[1] = filter->
o[0] = filter->
o[1] = value;
161 float out = filter->
b[0] * value
162 + filter->
b[1] * filter->
i[0]
163 + filter->
b[0] * filter->
i[1]
164 - filter->
a[0] * filter->
o[0]
165 - filter->
a[1] * filter->
o[1];
166 filter->
i[1] = filter->
i[0];
167 filter->
i[0] = value;
168 filter->
o[1] = filter->
o[0];
200 float sample_time,
int32_t value)
203 float tau = 7.0f / (44.0f * cut_off);
204 float K = sample_time / (2.0f * tau);
205 float poly =
K *
K +
K / Q + 1.0f;
208 filter_temp.
a[0] = 2.0f * (
K *
K - 1.0f) / poly;
209 filter_temp.
a[1] = (
K *
K -
K / Q + 1.0f) / poly;
210 filter_temp.
b[0] =
K *
K / poly;
211 filter_temp.
b[1] = 2.0f * filter_temp.
b[0];
212 loop_gain_f = 1.0f / filter_temp.
b[0];
217 filter->
b[1] = 2 * filter->
b[0];
218 filter->
i[0] = filter->
i[1] = filter->
o[0] = filter->
o[1] = value;
231 + filter->
b[1] * filter->
i[0]
232 + filter->
b[0] * filter->
i[1]
233 - filter->
a[0] * filter->
o[0]
234 - filter->
a[1] * filter->
o[1];
236 filter->
i[1] = filter->
i[0];
237 filter->
i[0] = value;
238 filter->
o[1] = filter->
o[0];
387 return filter->
lp2.
o[0];
440 return filter->
lp2.
o[0];
static void init_second_order_low_pass(struct SecondOrderLowPass *filter, float tau, float Q, float sample_time, float value)
Init second order low pass filter.
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
Fourth order Butterworth low pass filter(fixed point version).
static int32_t get_butterworth_4_low_pass_int(Butterworth4LowPass_int *filter)
Get current value of the fourth order Butterworth low pass filter(fixed point version).
static void init_first_order_low_pass(struct FirstOrderLowPass *filter, float tau, float sample_time, float value)
Init first order low pass filter.
static float update_first_order_low_pass(struct FirstOrderLowPass *filter, float value)
Update first order low pass filter state with a new value.
Second order low pass filter structure.
static float get_butterworth_4_low_pass(Butterworth4LowPass *filter)
Get current value of the fourth order Butterworth low pass filter.
int32_t o[2]
output history
static void init_second_order_low_pass_int(struct SecondOrderLowPass_int *filter, float cut_off, float Q, float sample_time, int32_t value)
Init second order low pass filter(fixed point version).
static float update_second_order_low_pass(struct SecondOrderLowPass *filter, float value)
Update second order low pass filter state with a new value.
Paparazzi fixed point algebra.
static int32_t update_butterworth_2_low_pass_int(Butterworth2LowPass_int *filter, int32_t value)
Update second order Butterworth low pass filter state with a new value(fixed point version).
int32_t b[2]
numerator gains
int32_t a[2]
denominator gains
int32_t i[2]
input history
float a[2]
denominator gains
static int32_t update_butterworth_4_low_pass_int(Butterworth4LowPass_int *filter, int32_t value)
Update fourth order Butterworth low pass filter state with a new value(fixed point version).
static float update_butterworth_4_low_pass(Butterworth4LowPass *filter, float value)
Update fourth order Butterworth low pass filter state with a new value.
static int32_t get_second_order_low_pass_int(struct SecondOrderLowPass_int *filter)
Get current value of the second order low pass filter(fixed point version).
struct SecondOrderLowPass lp2
struct SecondOrderLowPass lp1
#define BFP_OF_REAL(_vr, _frac)
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
static int32_t get_butterworth_2_low_pass_int(Butterworth2LowPass_int *filter)
Get current value of the second order Butterworth low pass filter(fixed point version).
struct SecondOrderLowPass_int lp1
static void init_butterworth_2_low_pass_int(Butterworth2LowPass_int *filter, float cut_off, float sample_time, int32_t value)
Init a second order Butterworth filter.
static float get_butterworth_2_low_pass(Butterworth2LowPass *filter)
Get current value of the second order Butterworth low pass filter.
int32_t loop_gain
loop gain
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
static float get_first_order_low_pass(struct FirstOrderLowPass *filter)
Get current value of the first order low pass filter.
static void init_butterworth_4_low_pass(Butterworth4LowPass *filter, float tau, float sample_time, float value)
Init a fourth order Butterworth filter.
static void init_butterworth_4_low_pass_int(Butterworth4LowPass_int *filter, float cut_off, float sample_time, int32_t value)
Init a fourth order Butterworth filter(fixed point version).
float b[2]
numerator gains
static float get_second_order_low_pass(struct SecondOrderLowPass *filter)
Get current value of the second order low pass filter.
Fourth order Butterworth low pass filter.
First order low pass filter structure.
static int32_t update_second_order_low_pass_int(struct SecondOrderLowPass_int *filter, int32_t value)
Update second order low pass filter state with a new value(fixed point version).
struct SecondOrderLowPass_int lp2