diff --git a/include/base/problem/problem.h b/include/base/problem/problem.h index 46f20f1b749070869b568ef128758eb2a7320160..b7070994829419d35c20b3e602fd37b1f6390d45 100644 --- a/include/base/problem/problem.h +++ b/include/base/problem/problem.h @@ -199,22 +199,38 @@ class Problem : public std::enable_shared_from_this<Problem> FrameBasePtr closestImportantFrameToTimeStamp(const TimeStamp& _ts) const; FrameBasePtr closestEstimatedFrameToTimeStamp(const TimeStamp& _ts) const; - /** \brief Give the permission to a processor to create a new keyFrame + /** \brief Give the permission to a processor to create a new important Frame * - * This should implement a black list of processors that have forbidden keyframe creation. + * This should implement a black list of processors that have forbidden important frame creation. * - This decision is made at problem level, not at processor configuration level. - * - Therefore, if you want to permanently configure a processor for not creating keyframes, see Processor::voting_active_ and its accessors. + * - Therefore, if you want to permanently configure a processor for not creating important frames, see Processor::voting_active_ and its accessors. */ - bool permitKeyFrame(ProcessorBasePtr _processor_ptr); + bool permitImportantFrame(ProcessorBasePtr _processor_ptr); - /** \brief New key frame callback + /** \brief New important frame callback * - * New key frame callback: It should be called by any processor that creates a new keyframe. It calls the keyFrameCallback of the rest of processors. + * New important frame callback: It should be called by any processor that creates a new important frame. It calls the importantFrameCallback of the rest of processors. */ - void keyFrameCallback(FrameBasePtr _keyframe_ptr, // + void importantFrameCallback(FrameBasePtr _frame_ptr, // ProcessorBasePtr _processor_ptr, // const Scalar& _time_tolerance); + /** \brief Give the permission to a processor to create a new estimated Frame + * + * This should implement a black list of processors that have forbidden estimated frame creation. + * - This decision is made at problem level, not at processor configuration level. + * - Therefore, if you want to permanently configure a processor for not creating estimated frames, see Processor::voting_active_ and its accessors. + */ + bool permitEstimatedFrame(ProcessorBasePtr _processor_ptr); + + /** \brief New estimated frame callback + * + * New estimated frame callback: It should be called by any processor that creates a new estimated frame. It calls the estimatedFrameCallback of the processor motion. + */ + void estimatedFrameCallback(FrameBasePtr _frame_ptr, // + ProcessorBasePtr _processor_ptr, // + const Scalar& _time_tolerance); + // State getters Eigen::VectorXs getCurrentState ( ); void getCurrentState (Eigen::VectorXs& state); @@ -241,7 +257,7 @@ 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); - bool getLastKeyFrameCovariance(Eigen::MatrixXs& _covariance); + bool getLastImportantFrameCovariance(Eigen::MatrixXs& _covariance); bool getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr, Eigen::MatrixXs& _covariance); // Solver management ---------------------------------------- diff --git a/src/ceres_wrapper/ceres_manager.cpp b/src/ceres_wrapper/ceres_manager.cpp index 590f8de1d0ff37e6e9c27d11f79f0f54dc5d4372..a237f5ee029eb3a888329ddf310891e81a1df61c 100644 --- a/src/ceres_wrapper/ceres_manager.cpp +++ b/src/ceres_wrapper/ceres_manager.cpp @@ -144,7 +144,7 @@ void CeresManager::computeCovariances(const CovarianceBlocksToBeComputed _blocks case CovarianceBlocksToBeComputed::ROBOT_LANDMARKS: { //robot-robot - auto last_key_frame = wolf_problem_->getLastKeyFrame(); + auto last_key_frame = wolf_problem_->getLastImportantFrame(); state_block_pairs.emplace_back(last_key_frame->getP(), last_key_frame->getP()); state_block_pairs.emplace_back(last_key_frame->getP(), last_key_frame->getO()); diff --git a/test/gtest_IMU.cpp b/test/gtest_IMU.cpp index 84b7a0c05c09a8d20e4d2aafc80a3a02fdd0b53b..202f566a6eca49236165a2a2c8a10bb111a4b20d 100644 --- a/test/gtest_IMU.cpp +++ b/test/gtest_IMU.cpp @@ -490,7 +490,7 @@ class Process_Factor_IMU : public testing::Test capture_imu = make_shared<CaptureIMU>(t+dt, sensor_imu, data, sensor_imu->getNoiseCov()); processor_imu->process(capture_imu); - KF_1 = problem->getLastKeyFrame(); + KF_1 = problem->getLastEstimatedFrame(); C_1 = KF_1->getCaptureList().front(); // front is IMU CM_1 = static_pointer_cast<CaptureMotion>(C_1); diff --git a/test/gtest_processor_base.cpp b/test/gtest_processor_base.cpp index 904dfd7646f1194892e0845b003cd20d17916c4b..0a3a0ffacb2f58249dfde5d48b14693fc5de19af 100644 --- a/test/gtest_processor_base.cpp +++ b/test/gtest_processor_base.cpp @@ -59,7 +59,7 @@ TEST(ProcessorBase, KeyFrameCallback) std::cout << "sensor & processor created and added to wolf problem" << std::endl; - // Sequence to test KeyFrame creations (callback calls) + // Sequence to test Important Frame creations (callback calls) // initialize TimeStamp t(0.0); @@ -89,7 +89,7 @@ TEST(ProcessorBase, KeyFrameCallback) // problem->print(4,1,1,0); // Only odom creating KFs - ASSERT_TRUE( problem->getLastKeyFrame()->getType().compare("PO 2D")==0 ); + ASSERT_TRUE( problem->getLastImportantFrame()->getType().compare("PO 2D")==0 ); } } diff --git a/test/gtest_processor_frame_nearest_neighbor_filter_2D.cpp b/test/gtest_processor_frame_nearest_neighbor_filter_2D.cpp index 9f47c647b8531a09c51d9c0d12ca5de78542488e..9bb2238ed38ef20e0a9fd51734a3968fdfe81945 100644 --- a/test/gtest_processor_frame_nearest_neighbor_filter_2D.cpp +++ b/test/gtest_processor_frame_nearest_neighbor_filter_2D.cpp @@ -147,8 +147,9 @@ TEST(ProcessorFrameNearestNeighborFilter, PointInEllipseRotated) incomming_dummy = std::make_shared<wolf::CaptureBase>("DUMMY", 1.2, sensor_ptr); - // Make 3rd frame last Keyframe - problem->getTrajectory()->setLastKeyFrame(F3); + // Make 3rd frame last Important frame + F3->setTimeStamp(wolf::TimeStamp(2.0)); + problem->getTrajectory()->sortFrame(F3); // trigger search for loopclosure processor_ptr_point2d->process(incomming_dummy); @@ -180,8 +181,9 @@ TEST(ProcessorFrameNearestNeighborFilter, EllipseEllipseRotatedCrosscovariance) problem->addCovarianceBlock( F4->getP(), F4->getP(), position_covariance_matrix); - // Make 3rd frame last Keyframe - problem->getTrajectory()->setLastKeyFrame(F3); + // Make 3rd frame last Important frame + F3->setTimeStamp(wolf::TimeStamp(2.0)); + problem->getTrajectory()->sortFrame(F3); // trigger search for loopclosure processor_ptr_ellipse2d->process(incomming_dummy); @@ -192,8 +194,9 @@ TEST(ProcessorFrameNearestNeighborFilter, EllipseEllipseRotatedCrosscovariance) ASSERT_EQ(testloops[0]->id(), (unsigned int) 1); ASSERT_EQ(testloops[1]->id(), (unsigned int) 2); - // Make 4th frame last Keyframe - problem->getTrajectory()->setLastKeyFrame(F4); + // Make 4th frame last Important frame + F4->setTimeStamp(wolf::TimeStamp(3.0)); + problem->getTrajectory()->sortFrame(F4); // trigger search for loopclosure again processor_ptr_ellipse2d->process(incomming_dummy); diff --git a/test/gtest_trajectory.cpp b/test/gtest_trajectory.cpp index d2f73a2fb601ae07a0c59700fdf19b4b947e370d..7b2849760750077590692300c3c13823d1ac46ea 100644 --- a/test/gtest_trajectory.cpp +++ b/test/gtest_trajectory.cpp @@ -60,7 +60,7 @@ struct DummyNotificationProcessor /// Set to true if you want debug info bool debug = false; -TEST(TrajectoryBase, ClosestKeyFrame) +TEST(TrajectoryBase, ClosestEstimatedFrame) { ProblemPtr P = Problem::create("PO 2D"); @@ -80,19 +80,19 @@ TEST(TrajectoryBase, ClosestKeyFrame) FrameBasePtr kf; // closest key-frame queried - kf = T->closestKeyFrameToTimeStamp(-0.8); // before all keyframes --> return f0 + kf = T->closestEstimatedFrameToTimeStamp(-0.8); // before all keyframes --> return f0 ASSERT_EQ(kf->id(), f1->id()); // same id! - kf = T->closestKeyFrameToTimeStamp(1.1); // between keyframes --> return f1 + kf = T->closestEstimatedFrameToTimeStamp(1.1); // between keyframes --> return f1 ASSERT_EQ(kf->id(), f1->id()); // same id! - kf = T->closestKeyFrameToTimeStamp(1.9); // between keyframes --> return f2 + kf = T->closestEstimatedFrameToTimeStamp(1.9); // between keyframes --> return f2 ASSERT_EQ(kf->id(), f2->id()); // same id! - kf = T->closestKeyFrameToTimeStamp(2.6); // between keyframe and frame, but closer to frame --> return f2 + kf = T->closestEstimatedFrameToTimeStamp(2.6); // between keyframe and frame, but closer to frame --> return f2 ASSERT_EQ(kf->id(), f2->id()); // same id! - kf = T->closestKeyFrameToTimeStamp(3.2); // after the last frame --> return f2 + kf = T->closestEstimatedFrameToTimeStamp(3.2); // after the last frame --> return f2 ASSERT_EQ(kf->id(), f2->id()); // same id! }