From bd36055542b49b0bb7611ec9c320f7bbabaf6c27 Mon Sep 17 00:00:00 2001 From: Martin Miller Date: Sat, 25 Mar 2017 18:47:40 -0500 Subject: Add State::R() method, refactor H() Method to compute R for given vector of z measurements. Added a method State::Hrows(z) to return number of rows in H(z). --- src/state.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++----------- src/state.h | 2 ++ 2 files changed, 64 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/state.cpp b/src/state.cpp index 281fac3..243c34b 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -53,6 +53,46 @@ State::H ( const Vector3d &pos, const Quaterniond &q, const std::vector(row,0) = fi->Hx(pos,q); + h.block<6,3>(row,col) = fi->Hy(pos,q); + row += 6; + break; + + case MONO: + fprintf(stderr, "mono points not supported.\n"); + exit(1); + break; + + case HEIGHT: + h.block<1,9>(row,0) = body->H(); + row += 1; + break; + + default: + break; + } /* ----- end switch ----- */ + } + return h; +} /* ----- end of method State::H ----- */ + +int +State::Hrows ( const std::vector &z) +{ int rows = 0; for (auto i=z.begin(); i!=z.end(); ++i) { switch ( i->z_type ) { @@ -72,22 +112,22 @@ State::H ( const Vector3d &pos, const Quaterniond &q, const std::vector &z ) +{ + int rows = Hrows(z); + MatrixXd r; + r = MatrixXd::Zero(rows,rows); + for (int i=0,row=0; i(row,0) = fi->Hx(pos,q); - h.block<6,3>(row,col) = fi->Hy(pos,q); + r.block<6,6>(row,row) = fi->R(); row += 6; break; @@ -97,7 +137,7 @@ State::H ( const Vector3d &pos, const Quaterniond &q, const std::vector(row,0) = body->H(); + r.block<1,1>(row,row) = body->R(); row += 1; break; @@ -105,14 +145,22 @@ State::H ( const Vector3d &pos, const Quaterniond &q, const std::vector &z ) { MatrixXd h; h = H(pos,q,z); + +#ifdef FULLS + MatrixXd S; + S = h*P*h.transpose() + R(z); +#else /* ----- not FULLS ----- */ + <+ELSE PART+> +#endif /* ----- not FULLS ----- */ /* Matrix S; S=body->S(Pxx()); diff --git a/src/state.h b/src/state.h index 43342a7..2a18e36 100644 --- a/src/state.h +++ b/src/state.h @@ -38,7 +38,9 @@ class State Feature *featureById(int id); MatrixXd F(const Quaterniond &q, const Vector3d &w, double dt); MatrixXd H ( const Vector3d &pos, const Quaterniond &q, const std::vector &z ); + int Hrows( const std::vector &z ); MatrixXd Q(double dt); + MatrixXd R( const std::vector &z ); Matrix Pxx(); Matrix L(); -- cgit v1.1