From 457847229ba58ac7eaaff82bbff8337d60b3993b Mon Sep 17 00:00:00 2001 From: Martin Miller Date: Fri, 24 Mar 2017 13:47:17 -0500 Subject: Compute Pk|k-1 using full state. Previously State::Pkk1() was only being computed for the body states. Methods State::F() and State::Q() were written to compose the full versions of their respective matrices and the results are used to update Pk|k-1. --- src/state.cpp | 38 +++++++++++++++++++++++++++++++++----- src/state.h | 1 + 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/state.cpp b/src/state.cpp index f2344f0..959cf22 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -119,6 +119,36 @@ State::initializePi ( int i, const Matrix &Pi ) return ; } /* ----- end of method State::initializePi ----- */ +/* + *-------------------------------------------------------------------------------------- + * Class: State + * Method: State :: Q + * Description: Compose full Q from body and features. + *-------------------------------------------------------------------------------------- + */ +MatrixXd +State::Q ( double dt ) +{ + MatrixXd q; + int rows = 9 + 3*features.size(); + q = MatrixXd::Zero(rows,rows); + q.topLeftCorner<9,9>() = body->Q(dt); + { // limit i's scope + auto i = features.begin(); + for (int row=9; row(row,row) = (*i)->Q(dt); + } + } + return q; +} /* ----- end of method State::q ----- */ + +/* + *-------------------------------------------------------------------------------------- + * Class: State + * Method: State :: F + * Description: Compose full F from body and features + *-------------------------------------------------------------------------------------- + */ MatrixXd State::F ( const Quaterniond &q, const Vector3d &w, double dt ) { @@ -153,12 +183,10 @@ State::F ( const Quaterniond &q, const Vector3d &w, double dt ) void State::Pkk1 ( const Vector3d &ang, const Quaterniond &q, const double dt) { - Matrix Q; - Q = body->Q(dt); - MatrixXd f; + MatrixXd f,fullQ; + fullQ = Q(dt); f = F ( q, ang, dt ); - //cout << f << endl; - P = f*P*f.transpose()+Q; + P = f*P*f.transpose()+fullQ; // Enforce symmetry P = 0.5*(P+P.transpose()); return ; diff --git a/src/state.h b/src/state.h index 0bb8215..1d8dd63 100644 --- a/src/state.h +++ b/src/state.h @@ -33,6 +33,7 @@ class State /* ==================== ACCESSORS ======================================= */ bool exists(int id); MatrixXd F(const Quaterniond &q, const Vector3d &w, double dt); + MatrixXd Q(double dt); /* ==================== MUTATORS ======================================= */ void accelerometer_bias(const Vector3d &b); -- cgit v1.1