Tetrapod Project
filter_utils.cpp
Go to the documentation of this file.
2 
3 ThirdOrderFilter::ThirdOrderFilter(double _dt, double _x_current, double _x_goal, double _frequency, double _damping)
4 {
5  dt = _dt;
6 
7  X = Eigen::Matrix<double, 3, 1>::Zero();
8  X(0) = _x_current;
9 
10  x_goal = _x_goal;
11 
12  A_d = Eigen::Matrix<double, 3, 3>::Zero();
13  A_d(0, 1) = 1.0;
14  A_d(1, 2) = 1.0;
15  A_d(2, 0) = -_frequency*_frequency*_frequency;
16  A_d(2, 1) = -(2*_damping + 1.0)*_frequency*_frequency;
17  A_d(2, 2) = -(2*_damping + 1.0)*_frequency;
18 
19  B_d = Eigen::Matrix<double, 3, 1>::Zero();
20  B_d(2) = _frequency*_frequency*_frequency;
21 }
22 
24 {
25  Eigen::Matrix<double, 3, 1> X_dot = A_d*X + B_d*x_goal;
26  X += X_dot*dt;
27 }
28 
29 void ThirdOrderFilter::setParameters(double _frequency, double _damping)
30 {
31  A_d = Eigen::Matrix<double, 3, 3>::Zero();
32  A_d(0, 1) = 1.0;
33  A_d(1, 2) = 1.0;
34  A_d(2, 0) = -_frequency*_frequency*_frequency;
35  A_d(2, 1) = -(2*_damping + 1.0)*_frequency*_frequency;
36  A_d(2, 2) = -(2*_damping + 1.0)*_frequency;
37 
38  B_d = Eigen::Matrix<double, 3, 1>::Zero();
39  B_d(2) = _frequency*_frequency*_frequency;
40 }
Eigen::Matrix< double, 3, 1 > X
Definition: filter_utils.h:22
void setParameters(double _frequency, double _damping)
Eigen::Matrix< double, 3, 3 > A_d
Definition: filter_utils.h:25
Eigen::Matrix< double, 3, 1 > B_d
Definition: filter_utils.h:26