Skip to content
Snippets Groups Projects
Commit 2ac1b955 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Rename getCaptureMotionContainingTimeStamp() -> findCaptureContainingTimeStamp() !...

Discovered an existing findCaptureContainingTimeStamp() !

So all this was done:
 - rename
 - select most elegant implementation
 - make it const (one was const, the other was not)
 - comment out the discarded implementation
parent 7a36f8bd
No related branches found
No related tags found
1 merge request!181Rename getCaptureMotionContainingTimeStamp() -> findCaptureContainingTimeStamp() !...
Pipeline #
...@@ -264,7 +264,7 @@ void ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXs& _x) ...@@ -264,7 +264,7 @@ void ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXs& _x)
capture_motion = last_ptr_; capture_motion = last_ptr_;
else else
// We need to search in previous keyframes for the capture containing a motion buffer with the queried time stamp // We need to search in previous keyframes for the capture containing a motion buffer with the queried time stamp
capture_motion = getCaptureMotionContainingTimeStamp(_ts); capture_motion = findCaptureContainingTimeStamp(_ts);
if (capture_motion) // We found a CaptureMotion whose buffer contains the time stamp if (capture_motion) // We found a CaptureMotion whose buffer contains the time stamp
{ {
...@@ -294,34 +294,34 @@ void ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXs& _x) ...@@ -294,34 +294,34 @@ void ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXs& _x)
} }
} }
CaptureMotionPtr ProcessorMotion::findCaptureContainingTimeStamp(const TimeStamp& _ts) const //CaptureMotionPtr ProcessorMotion::findCaptureContainingTimeStamp(const TimeStamp& _ts) const
{ //{
//std::cout << "ProcessorMotion::findCaptureContainingTimeStamp: ts = " << _ts.getSeconds() << "." << _ts.getNanoSeconds() << std::endl; // //std::cout << "ProcessorMotion::findCaptureContainingTimeStamp: ts = " << _ts.getSeconds() << "." << _ts.getNanoSeconds() << std::endl;
CaptureMotionPtr capture_ptr = last_ptr_; // CaptureMotionPtr capture_ptr = last_ptr_;
while (capture_ptr != nullptr) // while (capture_ptr != nullptr)
{ // {
// capture containing motion previous than the ts found: // // capture containing motion previous than the ts found:
if (capture_ptr->getBuffer().get().front().ts_ < _ts) // if (capture_ptr->getBuffer().get().front().ts_ < _ts)
return capture_ptr; // return capture_ptr;
else // else
{ // {
// go to the previous motion capture // // go to the previous motion capture
if (capture_ptr == last_ptr_) // if (capture_ptr == last_ptr_)
capture_ptr = origin_ptr_; // capture_ptr = origin_ptr_;
else if (capture_ptr->getOriginFramePtr() == nullptr) // else if (capture_ptr->getOriginFramePtr() == nullptr)
return nullptr; // return nullptr;
else // else
{ // {
CaptureBasePtr capture_base_ptr = capture_ptr->getOriginFramePtr()->getCaptureOf(getSensorPtr()); // CaptureBasePtr capture_base_ptr = capture_ptr->getOriginFramePtr()->getCaptureOf(getSensorPtr());
if (capture_base_ptr == nullptr) // if (capture_base_ptr == nullptr)
return nullptr; // return nullptr;
else // else
capture_ptr = std::static_pointer_cast<CaptureMotion>(capture_base_ptr); // capture_ptr = std::static_pointer_cast<CaptureMotion>(capture_base_ptr);
} // }
} // }
} // }
return capture_ptr; // return capture_ptr;
} //}
FrameBasePtr ProcessorMotion::setOrigin(const Eigen::VectorXs& _x_origin, const TimeStamp& _ts_origin) FrameBasePtr ProcessorMotion::setOrigin(const Eigen::VectorXs& _x_origin, const TimeStamp& _ts_origin)
{ {
...@@ -515,27 +515,28 @@ Motion ProcessorMotion::interpolate(const Motion& _ref, Motion& _second, TimeSta ...@@ -515,27 +515,28 @@ Motion ProcessorMotion::interpolate(const Motion& _ref, Motion& _second, TimeSta
} }
CaptureMotionPtr ProcessorMotion::getCaptureMotionContainingTimeStamp(const TimeStamp& _ts) CaptureMotionPtr ProcessorMotion::findCaptureContainingTimeStamp(const TimeStamp& _ts) const
{ {
// We need to search in previous keyframes for the capture containing a motion buffer with the queried time stamp // We need to search in previous keyframes for the capture containing a motion buffer with the queried time stamp
// Note: since the buffer goes from a FK through the past until the previous KF, we need to: // Note: since the buffer goes from a FK through the past until the previous KF, we need to:
// 1. See that the KF contains a CaptureMotion // 1. See that the KF contains a CaptureMotion
// 2. See that the TS is smaller than the KF's TS // 2. See that the TS is smaller than the KF's TS
// 3. See that the TS is bigger than the KF's first Motion in the CaptureMotion's buffer // 3. See that the TS is bigger than the KF's first Motion in the CaptureMotion's buffer
FrameBasePtr frame = nullptr; FrameBasePtr frame = nullptr;
CaptureBasePtr capture = nullptr; CaptureBasePtr capture = nullptr;
CaptureMotionPtr capture_motion = nullptr; CaptureMotionPtr capture_motion = nullptr;
for (auto frame_iter = getProblem()->getTrajectoryPtr()->getFrameList().rbegin(); for (auto frame_rev_iter = getProblem()->getTrajectoryPtr()->getFrameList().rbegin();
frame_iter != getProblem()->getTrajectoryPtr()->getFrameList().rend(); ++frame_iter) frame_rev_iter != getProblem()->getTrajectoryPtr()->getFrameList().rend();
++frame_rev_iter)
{ {
frame = *frame_iter; frame = *frame_rev_iter;
capture = frame->getCaptureOf(getSensorPtr()); capture = frame->getCaptureOf(getSensorPtr());
if (capture != nullptr) if (capture != nullptr)
{ {
// We found a Capture belonging to this processor's Sensor ==> it is a CaptureMotion // We found a Capture belonging to this processor's Sensor ==> it is a CaptureMotion
capture_motion = std::static_pointer_cast<CaptureMotion>(capture); capture_motion = std::static_pointer_cast<CaptureMotion>(capture);
if (_ts >= capture_motion->getBuffer().get().front().ts_) if (_ts >= capture_motion->getBuffer().get().front().ts_)
// Found time stamp satisfying rule 3 above !! // Found time stamp satisfying rule 3 above !! ==> break for loop
break; break;
} }
} }
......
...@@ -397,7 +397,6 @@ class ProcessorMotion : public ProcessorBase ...@@ -397,7 +397,6 @@ class ProcessorMotion : public ProcessorBase
virtual ConstraintBasePtr emplaceConstraint(FeatureBasePtr _feature_motion, CaptureBasePtr _capture_origin) = 0; virtual ConstraintBasePtr emplaceConstraint(FeatureBasePtr _feature_motion, CaptureBasePtr _capture_origin) = 0;
Motion motionZero(const TimeStamp& _ts); Motion motionZero(const TimeStamp& _ts);
CaptureMotionPtr getCaptureMotionContainingTimeStamp(const TimeStamp& _ts);
public: public:
virtual CaptureMotionPtr getOriginPtr(); virtual CaptureMotionPtr getOriginPtr();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment