From e972a0a111e35132f87e77d2bac096ba4e2728b2 Mon Sep 17 00:00:00 2001 From: jgoppert Date: Mon, 9 Nov 2015 19:52:55 -0500 Subject: [PATCH] Made kalman filter correction function usable. --- matrix/filter.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/matrix/filter.hpp b/matrix/filter.hpp index e202bb8827..53fc99d92a 100644 --- a/matrix/filter.hpp +++ b/matrix/filter.hpp @@ -6,17 +6,20 @@ namespace matrix { template void kalman_correct( - const Matrix & P, + const SquareMatrix & P, const Matrix & C, - const Matrix & R, + const SquareMatrix & R, const Vector &r, Vector & dx, + SquareMatrix & dP, float & beta ) { SquareMatrix S_I = SquareMatrix(C*P*C.T() + R).I(); - dx = P*C.T()*S_I*r; + Matrix K = P*C.T()*S_I; + dx = K*r; beta = Scalar(r.T()*S_I*r); + dP = K*C*P*(-1); } }; // namespace matrix