diff --git a/src/capture/capture_motion.cpp b/src/capture/capture_motion.cpp index 9158849ff0cf195c4883fb68a1453970ed4aa7ff..bb482951e75f481825b2a685761642b6e513dc3f 100644 --- a/src/capture/capture_motion.cpp +++ b/src/capture/capture_motion.cpp @@ -64,15 +64,16 @@ CaptureMotion::~CaptureMotion() bool CaptureMotion::containsTimeStamp(const TimeStamp& _ts, double _time_tolerance) const { assert(_ts.ok() and this->time_stamp_.ok()); - assert(this->time_stamp_ == this->getBuffer().back().ts_ and - "CaptureMotion::containsTimeStamp: The time stamp of the capture is not equal to the last motion in the " - "buffer"); - // the same capture is within tolerance - if (this->time_stamp_ - _time_tolerance <= _ts && _ts <= this->time_stamp_ + _time_tolerance) return true; - - // buffer is empty (and the capture is not within tolerance) - if (this->getBuffer().empty()) return false; + // if buffer is empty, check if the capture is within tolerance + if (this->getBuffer().empty()) + { + if (this->time_stamp_ - _time_tolerance <= _ts and _ts <= this->time_stamp_ + _time_tolerance) + return true; + else + // buffer is empty (and the capture is not within tolerance) + return false; + } // buffer encloses timestamp, if ts is: // from : buffer.first.ts - tt diff --git a/src/common/node_state_blocks.cpp b/src/common/node_state_blocks.cpp index a8ecdce30be2b3e11c6889d7b7a878b85480bb23..13fbcd8682a0b010dfdbac7142795052626d8a7e 100644 --- a/src/common/node_state_blocks.cpp +++ b/src/common/node_state_blocks.cpp @@ -256,13 +256,6 @@ void NodeStateBlocks::emplaceFactorStateBlock(const char& _key, void NodeStateBlocks::emplacePriors() { - WOLF_DEBUG_COND(state_priors_.empty(), - "Emplacing priors of ", - this->getType(), - " named ", - this->getName(), - ". No priors stored (either not specified or already applied)"); - for (auto prior_pair : state_priors_) { auto key = prior_pair.first; diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp index 0af47ab5d9c472c974190691eeb33689a3514249..3bf21c11e04f2414d47c6233132d46d125dd8485 100644 --- a/src/processor/processor_motion.cpp +++ b/src/processor/processor_motion.cpp @@ -211,6 +211,8 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr) FrameBasePtr keyframe_from_callback = computeProcessingStep(); if (keyframe_from_callback) buffer_frame_.removeUpTo(keyframe_from_callback->getTimeStamp()); + WOLF_DEBUG(getType(), ": '", getName(), "' processing_step_: ", processing_step_); + switch (processing_step_) // Things to do before integrating motion data { case FIRST_TIME_WITHOUT_KF: { @@ -263,13 +265,11 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr) break; } - // callback new keyframe to other processors + // callback new keyframe (origin) to other processors if (new_keyframe) getProblem()->keyFrameCallback(new_keyframe, shared_from_this()); // integrate motion data - // Done at this place because emplaceFirstFrame() needs integrateOneStep(); - last_ptr_->setTimeStamp(getBuffer().back().ts_); // perform bootstrap steps (usually only IMU requires this) if (bootstrapping_) bootstrap(); @@ -445,6 +445,9 @@ 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(last_ptr_, timestamp_from_callback, capture_for_keyframe_callback); + // correct the capture timestamp after splitting (motion buffer precision) + capture_for_keyframe_callback->setTimeStamp(capture_for_keyframe_callback->getBuffer().back().ts_); + // emplace motion features and factors emplaceFeaturesAndFactors(capture_origin, capture_for_keyframe_callback); @@ -725,11 +728,21 @@ VectorComposite ProcessorMotion::getState(const TimeStamp& _ts, StateKeys _keys) // Get calibration preint -- stored in last capture auto calib_preint = capture_motion->getCalibrationPreint(); + if (cap_orig->getTimeStamp() != capture_motion->getBuffer().front().ts_) + { + WOLF_ERROR("origin capture's ts != first motion capture's ts", + cap_orig->getTimeStamp(), + " != ", + capture_motion->getBuffer().front().ts_); + throw std::runtime_error("ProcessorMotion::getState: origin capture's ts != first motion capture's ts"); + } + // dt double dt = _ts - cap_orig->getTimeStamp(); if (dt < 0) { WOLF_ERROR("negative dt!", + dt, "\ttimestamp requested: ", _ts, "\tCapture found id:", @@ -886,6 +899,9 @@ void ProcessorMotion::integrateOneStep() VectorComposite odom; statePlusDelta(getOdometry(), delta_, dt_, odom); setOdometry(odom); + + // update last capture timestamp + last_ptr_->setTimeStamp(getBuffer().back().ts_); } void ProcessorMotion::reintegrateBuffer(CaptureMotionPtr _capture_ptr) const