diff --git a/include/base/frame_base.h b/include/base/frame_base.h index be97eb80a333fac1391f7b19bf12d1895e9dbb6d..0177bd8e9253dbd9840ec8fe3a765720a0754fc6 100644 --- a/include/base/frame_base.h +++ b/include/base/frame_base.h @@ -113,7 +113,6 @@ class FrameBase : public NodeBase, public std::enable_shared_from_this<FrameBase void getState(Eigen::VectorXs& _state) const; unsigned int getSize() const; bool getCovariance(Eigen::MatrixXs& _cov) const; - Eigen::MatrixXs getCovariance() const; // Wolf tree access --------------------------------------------------- public: diff --git a/include/base/landmark/landmark_base.h b/include/base/landmark/landmark_base.h index 9019ee85efd04f54ddfa920e98413c8aabf3846e..e3b61d65bf86a7690a9350d3d089bec156637092 100644 --- a/include/base/landmark/landmark_base.h +++ b/include/base/landmark/landmark_base.h @@ -72,7 +72,6 @@ class LandmarkBase : public NodeBase, public std::enable_shared_from_this<Landma Eigen::VectorXs getState() const; void getState(Eigen::VectorXs& _state) const; bool getCovariance(Eigen::MatrixXs& _cov) const; - Eigen::MatrixXs getCovariance() const; protected: virtual void removeStateBlocks(); diff --git a/include/base/problem.h b/include/base/problem.h index 84b51c2a6ce9638fef140c84c86240ebb596738d..a9f8e5e4a28c857a4061ec2296cb81cf31858dfa 100644 --- a/include/base/problem.h +++ b/include/base/problem.h @@ -236,10 +236,8 @@ class Problem : public std::enable_shared_from_this<Problem> bool getCovarianceBlock(std::map<StateBlockPtr, unsigned int> _sb_2_idx, Eigen::MatrixXs& _cov); bool getCovarianceBlock(StateBlockPtr _state, Eigen::MatrixXs& _cov, const int _row_and_col = 0); bool getFrameCovariance(FrameBaseConstPtr _frame_ptr, Eigen::MatrixXs& _covariance); - Eigen::MatrixXs getFrameCovariance(FrameBaseConstPtr _frame_ptr); - Eigen::MatrixXs getLastKeyFrameCovariance(); + bool getLastKeyFrameCovariance(Eigen::MatrixXs& _covariance); bool getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr, Eigen::MatrixXs& _covariance); - Eigen::MatrixXs getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr); // Solver management ---------------------------------------- diff --git a/src/frame_base.cpp b/src/frame_base.cpp index ccd51dc7f71cf6e696ed68c5e77a50f314b5bf45..3a7b4eed484e225be0c6ce2280ffceb4aa441752 100644 --- a/src/frame_base.cpp +++ b/src/frame_base.cpp @@ -221,11 +221,6 @@ bool FrameBase::getCovariance(Eigen::MatrixXs& _cov) const return getProblem()->getFrameCovariance(shared_from_this(), _cov); } -Eigen::MatrixXs FrameBase::getCovariance() const -{ - return getProblem()->getFrameCovariance(shared_from_this()); -} - FrameBasePtr FrameBase::getPreviousFrame() const { //std::cout << "finding previous frame of " << this->frame_id_ << std::endl; diff --git a/src/landmark/landmark_base.cpp b/src/landmark/landmark_base.cpp index d1fb63043ac989955ab8954c9cc9a19754184bec..c9f2e125b049509679abe58a346a6692dcbefef5 100644 --- a/src/landmark/landmark_base.cpp +++ b/src/landmark/landmark_base.cpp @@ -94,11 +94,6 @@ void LandmarkBase::registerNewStateBlocks() } } -Eigen::MatrixXs LandmarkBase::getCovariance() const -{ - return getProblem()->getLandmarkCovariance(shared_from_this()); -} - bool LandmarkBase::getCovariance(Eigen::MatrixXs& _cov) const { return getProblem()->getLandmarkCovariance(shared_from_this(), _cov); diff --git a/src/problem.cpp b/src/problem.cpp index b9cd0a1e6bd63bfb40a3eb67bda35e1b5c6096b2..0b3728d2cc3abbc4e7868e32545243a37c926e3a 100644 --- a/src/problem.cpp +++ b/src/problem.cpp @@ -564,6 +564,16 @@ bool Problem::getFrameCovariance(FrameBaseConstPtr _frame_ptr, Eigen::MatrixXs& const auto& state_bloc_vec = _frame_ptr->getStateBlockVec(); + // computing size + SizeEigen sz = 0; + for (const auto& sb : state_bloc_vec) + if (sb) + sz += sb->getSize(); + + // resizing + _covariance = Eigen::MatrixXs(sz, sz); + + // filling covariance for (const auto& sb_i : state_bloc_vec) { if (sb_i) @@ -583,23 +593,10 @@ bool Problem::getFrameCovariance(FrameBaseConstPtr _frame_ptr, Eigen::MatrixXs& return success; } -Eigen::MatrixXs Problem::getFrameCovariance(FrameBaseConstPtr _frame_ptr) -{ - SizeEigen sz = 0; - for (const auto& sb : _frame_ptr->getStateBlockVec()) - if (sb) - sz += sb->getSize(); - - Eigen::MatrixXs covariance(sz, sz); - - getFrameCovariance(_frame_ptr, covariance); - return covariance; -} - -Eigen::MatrixXs Problem::getLastKeyFrameCovariance() +bool Problem::getLastKeyFrameCovariance(Eigen::MatrixXs& cov) { FrameBasePtr frm = getLastKeyFrame(); - return getFrameCovariance(frm); + return getFrameCovariance(frm, cov); } bool Problem::getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr, Eigen::MatrixXs& _covariance) @@ -609,6 +606,17 @@ bool Problem::getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr, Eigen::M const auto& state_bloc_vec = _landmark_ptr->getStateBlockVec(); + // computing size + SizeEigen sz = 0; + for (const auto& sb : state_bloc_vec) + if (sb) + sz += sb->getSize(); + + // resizing + _covariance = Eigen::MatrixXs(sz, sz); + + // filling covariance + for (const auto& sb_i : state_bloc_vec) { if (sb_i) @@ -628,19 +636,6 @@ bool Problem::getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr, Eigen::M return success; } -Eigen::MatrixXs Problem::getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr) -{ - SizeEigen sz = 0; - for (const auto& sb : _landmark_ptr->getStateBlockVec()) - if (sb) - sz += sb->getSize(); - - Eigen::MatrixXs covariance(sz, sz); - - getLandmarkCovariance(_landmark_ptr, covariance); - return covariance; -} - MapBasePtr Problem::getMap() { return map_ptr_;