diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index 0bb18fd52c7ec787c65298afcae06e19abff3230..9c939355a2fc1fcef0f472f8e936f076e210365a 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -176,6 +176,7 @@ ProblemPtr Problem::autoSetup(ParamsServer &_server) // Prior std::string prior_mode = _server.getParam<std::string>("problem/prior/mode"); + assert((prior_mode == "nothing" || prior_mode == "initial_guess" || prior_mode == "fix" || prior_mode == "factor") && "wrong _mode value, it should be: 'nothing', 'initial_guess', 'fix' or 'factor'"); WOLF_TRACE("Prior mode: ", prior_mode); if (prior_mode == "nothing") { diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp index 17aa676f434d049875ecd8405c842b5ec95d1653..11dee8587c0e1ba03a77f23902f6a7a18c00e6ec 100644 --- a/src/processor/processor_motion.cpp +++ b/src/processor/processor_motion.cpp @@ -58,6 +58,8 @@ ProcessorMotion::~ProcessorMotion() void ProcessorMotion::mergeCaptures(CaptureMotionConstPtr cap_prev, CaptureMotionPtr cap_target) { + assert(cap_prev != nullptr); + assert(cap_target != nullptr); assert(cap_prev == cap_target->getOriginCapture() && "merging not consecutive capture motions"); // add prev buffer (discarding the first zero motion) @@ -75,15 +77,18 @@ void ProcessorMotion::mergeCaptures(CaptureMotionConstPtr cap_prev, // reintegrate buffer reintegrateBuffer(cap_target); - // replace existing feature and factor (if they exist) + // remove existing feature and factor (if they exist) if (!cap_target->getFeatureList().empty()) { // remove feature and factor (automatically) cap_target->getFeatureList().back()->remove(); assert(cap_target->getFeatureList().empty());// there should be one feature only + } - // emplace new feature and factor + // emplace new feature and factor (if origin has frame) + if (cap_prev->getOriginCapture() and cap_prev->getOriginCapture()->getFrame()) + { auto new_feature = emplaceFeature(cap_target); emplaceFactor(new_feature, cap_prev->getOriginCapture()); } diff --git a/src/tree_manager/tree_manager_sliding_window_dual_rate.cpp b/src/tree_manager/tree_manager_sliding_window_dual_rate.cpp index c590c4b718504cfd357a15df2bdc27f379a9deea..35c20da4585856df0e18739dce5553c74efb4807 100644 --- a/src/tree_manager/tree_manager_sliding_window_dual_rate.cpp +++ b/src/tree_manager/tree_manager_sliding_window_dual_rate.cpp @@ -43,8 +43,8 @@ void TreeManagerSlidingWindowDualRate::keyFrameCallback(FrameBasePtr _frame) continue; } - auto cap_prev = std::static_pointer_cast<CaptureMotion>(remove_recent_frame->getCaptureOf(proc_motion->getSensor())); - auto cap_next = std::static_pointer_cast<CaptureMotion>(keep_recent_frame->getCaptureOf(proc_motion->getSensor())); + auto cap_prev = std::dynamic_pointer_cast<CaptureMotion>(remove_recent_frame->getCaptureOf(proc_motion->getSensor())); + auto cap_next = std::dynamic_pointer_cast<CaptureMotion>(keep_recent_frame->getCaptureOf(proc_motion->getSensor())); // merge captures (if exist) if (cap_prev and cap_next) diff --git a/test/gtest_processor_motion.cpp b/test/gtest_processor_motion.cpp index e531defd5721e3374308d67e793a01f682701577..92bf678d4ba06af85c6c0da5724f9b7f4908f186 100644 --- a/test/gtest_processor_motion.cpp +++ b/test/gtest_processor_motion.cpp @@ -315,7 +315,7 @@ TEST_F(ProcessorMotion_test, mergeCaptures) FrameBasePtr F_target = problem->emplaceFrame(t_target); CaptureMotionPtr C_source = std::dynamic_pointer_cast<CaptureMotion>(processor->getLast()); CaptureMotionPtr C_target = CaptureBase::emplace<CaptureMotion>(F_target, - "ODOM 2d", + "CaptureOdom2d", t_target, sensor, data,