From 12bef0d99563f2bb140f08d6c42d3e5aacdc0f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu> Date: Sat, 19 Dec 2020 01:28:40 +0100 Subject: [PATCH] Remode FrameType and API. setKey() becomes link() --- include/core/frame/frame_base.h | 26 +++++++------------------- src/frame/frame_base.cpp | 15 ++------------- src/processor/processor_motion.cpp | 2 +- src/processor/processor_tracker.cpp | 2 +- test/gtest_has_state_blocks.cpp | 6 +++--- test/gtest_track_matrix.cpp | 4 ++-- 6 files changed, 16 insertions(+), 39 deletions(-) diff --git a/include/core/frame/frame_base.h b/include/core/frame/frame_base.h index ec6b987af..d1cb69dc4 100644 --- a/include/core/frame/frame_base.h +++ b/include/core/frame/frame_base.h @@ -8,14 +8,6 @@ namespace wolf{ class TrajectoryBase; class CaptureBase; class StateBlock; - -/** \brief Enumeration of frame types - */ -typedef enum -{ - KEY = 1, ///< key frame. It plays at optimizations (estimated). - REGULAR = 0 ///< regular frame. It does not play at optimization. -} FrameType; } //Wolf includes @@ -44,7 +36,6 @@ class FrameBase : public NodeBase, public HasStateBlocks, public std::enable_sha protected: unsigned int frame_id_; - FrameType type_; ///< type of frame. Either NON_KEY_FRAME or KEY_FRAME. (types defined at wolf.h) TimeStamp time_stamp_; ///< frame time stamp public: @@ -77,12 +68,8 @@ class FrameBase : public NodeBase, public HasStateBlocks, public std::enable_sha public: unsigned int id() const; - // get type - bool isKey() const; - - // set type - void setKey(ProblemPtr _prb); - void unsetKey(); + // link to problem + void link(ProblemPtr _prb); // Frame values ------------------------------------------------ public: @@ -178,10 +165,11 @@ inline unsigned int FrameBase::id() const return frame_id_; } -inline bool FrameBase::isKey() const -{ - return (type_ == KEY); -} +//inline bool FrameBase::isKey() const +//{ +// return true; +//// return (type_ == KEY); +//} inline void FrameBase::getTimeStamp(TimeStamp& _ts) const { diff --git a/src/frame/frame_base.cpp b/src/frame/frame_base.cpp index a2a3deb19..6207d6f17 100644 --- a/src/frame/frame_base.cpp +++ b/src/frame/frame_base.cpp @@ -126,20 +126,9 @@ void FrameBase::setTimeStamp(const TimeStamp& _ts) time_stamp_ = _ts; } -void FrameBase::unsetKey() +void FrameBase::link(ProblemPtr _prb) { - // unregister if previously estimated - if (isKey()) - for (const auto& sb : getStateBlockVec()) - getProblem()->notifyStateBlock(sb, REMOVE); - - type_ = REGULAR; -} - -void FrameBase::setKey(ProblemPtr _prb) -{ - assert(_prb != nullptr && "setting Key fram with a null problem pointer"); - type_ = KEY; + assert(_prb != nullptr && "Trying to link Frame with a null problem pointer!"); this->link(_prb->getTrajectory()); } diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp index 70ffce8ac..17919a7b9 100644 --- a/src/processor/processor_motion.cpp +++ b/src/processor/processor_motion.cpp @@ -423,7 +423,7 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr) // Set the frame of last_ptr as key auto key_frame = last_ptr_->getFrame(); - key_frame ->setKey(getProblem()); + key_frame ->link(getProblem()); // create motion feature and add it to the key_capture auto key_feature = emplaceFeature(last_ptr_); diff --git a/src/processor/processor_tracker.cpp b/src/processor/processor_tracker.cpp index e1d2e1c26..860b9867f 100644 --- a/src/processor/processor_tracker.cpp +++ b/src/processor/processor_tracker.cpp @@ -187,7 +187,7 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr) // We create a KF // set KF on last last_ptr_->getFrame()->setState(getProblem()->getState(last_ptr_->getTimeStamp())); - last_ptr_->getFrame()->setKey(getProblem()); + last_ptr_->getFrame()->link(getProblem()); // // make F; append incoming to new F // FrameBasePtr frm = FrameBase::createNonKeyFrame<FrameBase>(incoming_ptr_->getTimeStamp()); diff --git a/test/gtest_has_state_blocks.cpp b/test/gtest_has_state_blocks.cpp index b1baad456..0d42d8132 100644 --- a/test/gtest_has_state_blocks.cpp +++ b/test/gtest_has_state_blocks.cpp @@ -68,7 +68,7 @@ TEST_F(HasStateBlocksTest, Notifications_add_makeKF) ASSERT_FALSE(problem->getStateBlockNotification(sbv0, n)); - F0->setKey(problem); + F0->link(problem); ASSERT_TRUE(problem->getStateBlockNotification(sbp0, n)); ASSERT_EQ(n, ADD); @@ -85,7 +85,7 @@ TEST_F(HasStateBlocksTest, Notifications_makeKF_add) // first make KF, then add SB // F1->link(problem->getTrajectory()); - F1->setKey(problem); + F1->link(problem); F1->addStateBlock('P', sbp1); @@ -116,7 +116,7 @@ TEST_F(HasStateBlocksTest, Add_solve_notify_solve_add) ASSERT_FALSE(problem->getStateBlockNotification(sbp0, n)); F0->addStateBlock('V', sbv0); - F0->setKey(problem); + F0->link(problem); ASSERT_TRUE(problem->getStateBlockNotification(sbv0, n)); ASSERT_EQ(n, ADD); diff --git a/test/gtest_track_matrix.cpp b/test/gtest_track_matrix.cpp index 9bb9eec22..a14c436dd 100644 --- a/test/gtest_track_matrix.cpp +++ b/test/gtest_track_matrix.cpp @@ -52,8 +52,8 @@ class TrackMatrixTest : public testing::Test f4 = FeatureBase::emplace<FeatureBase>(nullptr, "FeatureBase", m, m_cov); // F0 and F4 are keyframes - F0->setKey(problem); - F4->setKey(problem); + F0->link(problem); + F4->link(problem); // link captures C0->link(F0); -- GitLab