From c7af11e6a252a7dfbacd9a702bbe3ee0a9127b17 Mon Sep 17 00:00:00 2001 From: Martin Miller Date: Sun, 26 Mar 2017 15:21:00 -0500 Subject: Set height above water. --- src/state.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/state.cpp') diff --git a/src/state.cpp b/src/state.cpp index eac80d8..57ebbfa 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -49,8 +49,10 @@ State::enu ( const UTM &utm ) *-------------------------------------------------------------------------------------- */ MatrixXd -State::H ( const Vector3d &pos, const Quaterniond &q, const std::vector &z ) +State::H ( const Quaterniond &q, const std::vector &z ) { + Vector3d pos; + pos = body->ned(); MatrixXd h; // Determine the size of H int cols = 9 + 3*features.size(); @@ -161,7 +163,6 @@ State::kalmanUpdate( const MatrixXd &h, const MatrixXd &S, const std::vector &z, const Quaterniond &q) { MatrixXd K; - K = P*h.transpose()*S; // P^T is implied here since P is symmetric K = S.partialPivLu().solve(h*P).transpose(); P = (MatrixXd::Identity(P.rows(),P.rows())-K*h)*P; @@ -229,12 +230,11 @@ State::innovation( const std::vector &z, const Quaterniond &q) } void -State::update ( const Vector3d &pos, const Quaterniond &q, const std::vector &z ) +State::update ( const Quaterniond &q, const std::vector &z ) { - #ifdef FULLS MatrixXd h; - h = H(pos,q,z); + h = H(q,z); MatrixXd S; S = h*P*h.transpose() + R(z); kalmanUpdate(h,S,z,q); @@ -255,14 +255,19 @@ void State::feature_update ( const std::vector &z, const Quaterniond &q) { std::vector featuresToAdd; + std::vector featuresToUpdate; for (auto i=z.begin(); i!=z.end(); ++i) { - if (i->z_type==HEIGHT) continue; - if (exists(i->id)) { - ; + if (i->z_type==HEIGHT) { + featuresToUpdate.push_back(*i); + } else if (exists(i->id)) { + featuresToUpdate.push_back(*i); } else { featuresToAdd.push_back(*i); } } + if (featuresToUpdate.size()>0) { + update(q, featuresToUpdate); + } addFeatures( featuresToAdd, q); return ; -- cgit v1.1