Complementary Filter
1.0
Complementary Filter for Real-Time Application
Toggle main menu visibility
Loading...
Searching...
No Matches
cf.tpp
Go to the documentation of this file.
1
#include "
cf.h
"
2
3
template
<
typename
T>
4
estimators::cf::CF<T>::CF
()
5
{
6
}
7
8
template
<
typename
T>
9
estimators::cf::CF<T>::~CF
()
10
{
11
}
12
13
template
<
typename
T>
14
void
estimators::cf::CF<T>::init
(T fc_, T dt_)
15
{
16
set_param(fc_, dt_);
17
}
18
19
template
<
typename
T>
20
void
estimators::cf::CF<T>::set_param
(T fc_, T dt_)
21
{
22
fc = fc_;
23
dt = dt_;
24
tau = 1.0 / (6.28318530717958647692528676655900576 * fc);
25
alpha = dt / (dt + tau);
26
}
27
28
template
<
typename
T>
29
T
estimators::cf::CF<T>::update
(T x1_i, T x2_i)
30
{
31
return
alpha * x1_i + (1.0 - alpha) * x2_i;
32
}
33
34
template
<
typename
T>
35
void
estimators::cf::CF<T>::reset
()
36
{
37
}
38
39
template
<
typename
T>
40
void
estimators::cf::CF<T>::set_fc
(T fc_)
41
{
42
set_param(fc_, dt);
43
}
44
45
template
<
typename
T>
46
void
estimators::cf::CF<T>::set_tau
(T tau_)
47
{
48
tau = tau_;
49
fc = 1.0 / (6.28318530717958647692528676655900576 * tau);
50
alpha = dt / (dt + tau);
51
}
52
53
template
<
typename
T>
54
void
estimators::cf::CF<T>::set_dt
(T dt_)
55
{
56
set_param(fc, dt_);
57
}
58
59
template
<
typename
T>
60
void
estimators::cf::CF<T>::set_alpha
(T alpha_)
61
{
62
alpha = alpha_;
63
tau = ((1.0 - alpha) * dt) / alpha;
64
fc = 1.0 / (6.28318530717958647692528676655900576 * tau);
65
}
66
67
template
<
typename
T>
68
T
estimators::cf::CF<T>::get_fc
()
69
{
70
return
fc;
71
}
72
73
template
<
typename
T>
74
T
estimators::cf::CF<T>::get_tau
()
75
{
76
return
tau;
77
}
78
79
template
<
typename
T>
80
T
estimators::cf::CF<T>::get_dt
()
81
{
82
return
dt;
83
}
84
85
template
<
typename
T>
86
T
estimators::cf::CF<T>::get_alpha
()
87
{
88
return
alpha;
89
}
cf.h
Declaration of the complementary filter class.
estimators::cf::CF::update
T update(T x1_i, T x2_i)
Updates the complementary filter with new measurements.
Definition
cf.h:30
estimators::cf::CF::init
void init(T fc_, T dt_)
Initializes the complementary filter.
Definition
cf.h:15
estimators::cf::CF::set_fc
void set_fc(T fc_)
Sets the cutoff frequency.
Definition
cf.h:41
estimators::cf::CF::set_param
void set_param(T fc_, T dt_)
Sets the filter parameters.
Definition
cf.h:21
estimators::cf::CF::~CF
~CF()
Destroys the complementary filter.
Definition
cf.h:10
estimators::cf::CF::set_alpha
void set_alpha(T alpha_)
Sets the complementary filter coefficient.
Definition
cf.h:61
estimators::cf::CF::reset
void reset()
Resets the filter state.
Definition
cf.h:36
estimators::cf::CF::set_dt
void set_dt(T dt_)
Sets the sampling time.
Definition
cf.h:55
estimators::cf::CF::CF
CF()
Constructs a complementary filter.
Definition
cf.h:5
estimators::cf::CF::get_tau
T get_tau()
Gets the filter time constant.
Definition
cf.h:75
estimators::cf::CF::get_dt
T get_dt()
Gets the sampling time.
Definition
cf.h:81
estimators::cf::CF::get_alpha
T get_alpha()
Gets the complementary filter coefficient.
Definition
cf.h:87
estimators::cf::CF::set_tau
void set_tau(T tau_)
Sets the filter time constant.
Definition
cf.h:47
estimators::cf::CF::get_fc
T get_fc()
Gets the cutoff frequency.
Definition
cf.h:69
src
cf.tpp
Generated by
1.17.0