diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/state.cpp | 38 | ||||
-rw-r--r-- | 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<double,3,3> &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<rows; row+=3, ++i) { + q.block<3,3>(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<double,9,9> 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); |