diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h index 7f32daba5f16e446b061eb4e1402ab9db44ff0d2..fd74ef35fd35da344e70755a02924f9c7b094ae9 100644 --- a/include/core/processor/processor_motion.h +++ b/include/core/processor/processor_motion.h @@ -488,6 +488,8 @@ class ProcessorMotion : public ProcessorBase, public MotionProvider */ virtual FactorBasePtr emplaceFactor(FeatureBasePtr _feature_motion, CaptureBasePtr _capture_origin) = 0; + virtual void emplaceFeaturesAndFactors(CaptureBasePtr _capture_origin, CaptureMotionPtr _capture_own) {}; // TODO make pure virtual + virtual void setCalibration(const CaptureBasePtr _capture, const VectorXd& _calibration) = 0; Motion motionZero(const TimeStamp& _ts) const; diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp index f8f2ce217c40cf791a22cb8ce6a600e57c55bd79..0d34672fd0c47bfb798e78c1939d40cc887786d0 100644 --- a/src/processor/processor_motion.cpp +++ b/src/processor/processor_motion.cpp @@ -119,8 +119,10 @@ void ProcessorMotion::mergeCaptures(CaptureMotionPtr cap_prev, // 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()); + // auto new_feature = emplaceFeature(cap_target); + // emplaceFactor(new_feature, cap_prev->getOriginCapture()); + + emplaceFeaturesAndFactors(cap_prev->getOriginCapture(), cap_target); } } @@ -312,11 +314,13 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr) // and give the part of the buffer before the new keyframe to the capture for the KF callback splitBuffer(capture_existing, timestamp_from_callback, capture_for_keyframe_callback); - // create motion feature and add it to the capture - auto feature_new = emplaceFeature(capture_for_keyframe_callback); + // // create motion feature and add it to the capture + // auto feature_new = emplaceFeature(capture_for_keyframe_callback); + + // // create motion factor and add it to the feature, and constrain to the other capture (origin) + // emplaceFactor(feature_new, capture_origin ); - // create motion factor and add it to the feature, and constrain to the other capture (origin) - emplaceFactor(feature_new, capture_origin ); + emplaceFeaturesAndFactors(capture_origin, capture_for_keyframe_callback); // modify existing feature and factor (if they exist in the existing capture) if (!capture_existing->getFeatureList().empty()) @@ -326,9 +330,11 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr) assert(capture_existing->getFeatureList().empty());// there was only one feature! - auto new_feature_existing = emplaceFeature(capture_existing); + // auto new_feature_existing = emplaceFeature(capture_existing); - emplaceFactor(new_feature_existing, capture_for_keyframe_callback); + // emplaceFactor(new_feature_existing, capture_for_keyframe_callback); + + emplaceFeaturesAndFactors(capture_for_keyframe_callback, capture_existing); } break; @@ -405,11 +411,13 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr) // and give the part of the buffer before the new keyframe to the capture for the KF callback splitBuffer(capture_existing, timestamp_from_callback, capture_for_keyframe_callback); - // create motion feature and add it to the capture - auto feature_for_keyframe_callback = emplaceFeature(capture_for_keyframe_callback); + // // create motion feature and add it to the capture + // auto feature_for_keyframe_callback = emplaceFeature(capture_for_keyframe_callback); + + // // create motion factor and add it to the feature, and constrain to the other capture (origin) + // emplaceFactor(feature_for_keyframe_callback, capture_origin ); - // create motion factor and add it to the feature, and constrain to the other capture (origin) - emplaceFactor(feature_for_keyframe_callback, capture_origin ); + emplaceFeaturesAndFactors(capture_origin, capture_for_keyframe_callback); // reset processor origin origin_ptr_ = capture_for_keyframe_callback; @@ -476,11 +484,15 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr) auto keyframe = last_ptr_->getFrame(); keyframe ->link(getProblem()); - // create motion feature and add it to the key_capture - auto key_feature = emplaceFeature(last_ptr_); + // // create motion feature and add it to the key_capture + // auto key_feature = emplaceFeature(last_ptr_); + + // // create motion factor and link it to parent feature and other frame (which is origin's frame) + // auto factor = emplaceFactor(key_feature, origin_ptr_); + // create motion feature and add it to the key_capture // create motion factor and link it to parent feature and other frame (which is origin's frame) - auto factor = emplaceFactor(key_feature, origin_ptr_); + emplaceFeaturesAndFactors(origin_ptr_, last_ptr_); // create a new frame auto frame_new = std::make_shared<FrameBase>(getTimeStamp(),