55 T process_noise_pimu =
57 T process_noise_vimu =
59 T process_noise_pfoot =
61 T sensor_noise_pimu_rel_foot =
63 T sensor_noise_vimu_rel_foot =
65 T sensor_noise_zfoot =
68 Eigen::Matrix<T, 18, 18> Q = Eigen::Matrix<T, 18, 18>::Identity();
69 Q.block(0, 0, 3, 3) =
_Q0.block(0, 0, 3, 3) * process_noise_pimu;
70 Q.block(3, 3, 3, 3) =
_Q0.block(3, 3, 3, 3) * process_noise_vimu;
71 Q.block(6, 6, 12, 12) =
_Q0.block(6, 6, 12, 12) * process_noise_pfoot;
73 Eigen::Matrix<T, 28, 28> R = Eigen::Matrix<T, 28, 28>::Identity();
74 R.block(0, 0, 12, 12) =
_R0.block(0, 0, 12, 12) * sensor_noise_pimu_rel_foot;
75 R.block(12, 12, 12, 12) =
76 _R0.block(12, 12, 12, 12) * sensor_noise_vimu_rel_foot;
77 R.block(24, 24, 4, 4) =
_R0.block(24, 24, 4, 4) * sensor_noise_zfoot;
92 p0 <<
_xhat[0], _xhat[1], _xhat[2];
93 v0 << _xhat[3], _xhat[4], _xhat[5];
95 for (
int i = 0; i < 4; i++) {
116 T trust_window = T(0.2);
118 if (phase < trust_window) {
119 trust = phase / trust_window;
120 }
else if (phase > (T(1) - trust_window)) {
121 trust = (T(1) - phase) / trust_window;
125 Q.block(qindex, qindex, 3, 3) =
126 (T(1) + (T(1) - trust) * T(100)) * Q.block(qindex, qindex, 3, 3);
127 R.block(rindex1, rindex1, 3, 3) = 1 * R.block(rindex1, rindex1, 3, 3);
128 R.block(rindex2, rindex2, 3, 3) =
129 (T(1) + (T(1) - trust) * 100.0
f) * R.block(rindex2, rindex2, 3, 3);
130 R(rindex3, rindex3) =
131 (T(1) + (T(1) - trust) * T(100)) * R(rindex3, rindex3);
135 _ps.segment(i1, 3) = -p_f;
136 _vs.segment(i1, 3) = (1.0f - trust) * v0 + trust * (-dp_f);
137 pzs(i) = (1.0f - trust) * (p0(2) + p_f(2));
141 Eigen::Matrix<T, 28, 1> y;
143 _xhat =
_A * _xhat +
_B * a;
144 Eigen::Matrix<T, 18, 18> At =
_A.transpose();
145 Eigen::Matrix<T, 18, 18> Pm =
_A *
_P * At + Q;
146 Eigen::Matrix<T, 18, 28> Ct =
_C.transpose();
147 Eigen::Matrix<T, 28, 1> yModel =
_C *
_xhat;
148 Eigen::Matrix<T, 28, 1> ey = y - yModel;
149 Eigen::Matrix<T, 28, 28> S =
_C * Pm * Ct + R;
152 Eigen::Matrix<T, 28, 1> S_ey = S.lu().solve(ey);
153 _xhat += Pm * Ct * S_ey;
155 Eigen::Matrix<T, 28, 18> S_C = S.lu().solve(
_C);
156 _P = (Eigen::Matrix<T, 18, 18>::Identity() - Pm * Ct * S_C) * Pm;
158 Eigen::Matrix<T, 18, 18> Pt =
_P.transpose();
159 _P = (
_P + Pt) / T(2);
161 if (
_P.block(0, 0, 2, 2).determinant() > T(0.000001)) {
162 _P.block(0, 2, 2, 16).setZero();
163 _P.block(2, 0, 16, 2).setZero();
164 _P.block(0, 0, 2, 2) /= T(10);
typename Eigen::Matrix< T, 3, 3 > Mat3
typename Eigen::Matrix< T, 3, 1 > Vec3
Eigen::Matrix< T, 28, 28 > _R0
Vec3< T > getHipLocation(int leg)
Eigen::Matrix< T, 18, 18 > _P
Eigen::Matrix< T, 18, 1 > _xhat
Eigen::Matrix< T, 18, 18 > _A
typename Eigen::Matrix< T, 4, 1 > Vec4
Eigen::Matrix< T, 28, 18 > _C
Eigen::Matrix< T, 12, 1 > _ps
Eigen::Matrix< T, 18, 3 > _B
Eigen::Matrix< T, 18, 18 > _Q0
Eigen::Matrix< T, 12, 1 > _vs
StateEstimatorData< T > _stateEstimatorData
MX f(const MX &x, const MX &u)