mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 00:33:34 +08:00
More filter testing.
This commit is contained in:
+10
-10
@@ -6,17 +6,17 @@ namespace matrix {
|
||||
|
||||
template<typename Type, size_t M, size_t N>
|
||||
void kalman_correct(
|
||||
const Matrix<Type, M, M> & P,
|
||||
const Matrix<Type, N, M> & C,
|
||||
const Matrix<Type, N, N> & R,
|
||||
const Vector<Type, N> &r,
|
||||
Vector<Type, M> & dx,
|
||||
float & beta
|
||||
)
|
||||
const Matrix<Type, M, M> & P,
|
||||
const Matrix<Type, N, M> & C,
|
||||
const Matrix<Type, N, N> & R,
|
||||
const Vector<Type, N> &r,
|
||||
Vector<Type, M> & dx,
|
||||
float & beta
|
||||
)
|
||||
{
|
||||
SquareMatrix<Type, N> S_I = SquareMatrix<Type, N>(C*P*C.T() + R).I();
|
||||
dx = P*C.T()*S_I*r;
|
||||
beta = Scalar<Type>(r.T()*S_I*r);
|
||||
SquareMatrix<Type, N> S_I = SquareMatrix<Type, N>(C*P*C.T() + R).I();
|
||||
dx = P*C.T()*S_I*r;
|
||||
beta = Scalar<Type>(r.T()*S_I*r);
|
||||
}
|
||||
|
||||
}; // namespace matrix
|
||||
|
||||
@@ -22,6 +22,12 @@ int main()
|
||||
kalman_correct<float, 6, 5>(P, C, R, r, dx, beta);
|
||||
|
||||
dx.print();
|
||||
printf("beta: %g\n", beta);
|
||||
|
||||
float data_check[] = {0.5,1,1.5,2,2.5,0};
|
||||
Vector<float, n_x> dx_check(data_check);
|
||||
assert(dx == dx_check);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user