Skip to content
Snippets Groups Projects
Commit d62a109f authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

implemented move() and use it in PT

parent e783e3d4
No related branches found
No related tags found
1 merge request!292Resolve "Allowed changes in wolf nodes"
...@@ -103,6 +103,7 @@ class CaptureBase : public NodeBase, public std::enable_shared_from_this<Capture ...@@ -103,6 +103,7 @@ class CaptureBase : public NodeBase, public std::enable_shared_from_this<Capture
SizeEigen getCalibSize() const; SizeEigen getCalibSize() const;
virtual Eigen::VectorXs getCalibration() const; virtual Eigen::VectorXs getCalibration() const;
void setCalibration(const Eigen::VectorXs& _calib); void setCalibration(const Eigen::VectorXs& _calib);
void move(FrameBasePtr);
void link(FrameBasePtr); void link(FrameBasePtr);
template<typename classType, typename... T> template<typename classType, typename... T>
static std::shared_ptr<CaptureBase> emplace(FrameBasePtr _frm_ptr, T&&... all); static std::shared_ptr<CaptureBase> emplace(FrameBasePtr _frm_ptr, T&&... all);
......
...@@ -289,16 +289,36 @@ void CaptureBase::setCalibration(const VectorXs& _calib) ...@@ -289,16 +289,36 @@ void CaptureBase::setCalibration(const VectorXs& _calib)
} }
} }
void CaptureBase::link(FrameBasePtr _frm_ptr) void CaptureBase::move(FrameBasePtr _frm_ptr)
{ {
assert((this->getFrame() == nullptr || !this->getFrame()->isKey()) && "linking a capture already linked to a KF"); WOLF_WARN_COND(this->getFrame() == nullptr, "moving a capture not linked to any frame");
WOLF_WARN_COND(_frm_ptr != nullptr, "moving a capture to a null FrameBasePtr");
// unlink from previous non-key frame // Unlink
if (this->getFrame()) if (this->getFrame())
{
if (this->getFrame()->isKey())
{
WOLF_ERROR("moving a capture linked to a KF");
return;
}
// unlink from previous non-key frame
this->getFrame()->removeCapture(shared_from_this()); this->getFrame()->removeCapture(shared_from_this());
}
// link
link(_frm_ptr);
}
void CaptureBase::link(FrameBasePtr _frm_ptr)
{
assert(this->getFrame() == nullptr && "linking a capture already linked");
if(_frm_ptr) if(_frm_ptr)
{ {
_frm_ptr->addCapture(shared_from_this()); _frm_ptr->addCapture(shared_from_this());
this->setFrame(_frm_ptr); this->setFrame(_frm_ptr);
this->setProblem(_frm_ptr->getProblem()); this->setProblem(_frm_ptr->getProblem());
......
...@@ -58,7 +58,6 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr) ...@@ -58,7 +58,6 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr)
WOLF_DEBUG( "PT ", getName(), " FIRST_TIME_WITH_PACK: KF" , pack->key_frame->id() , " callback unpacked with ts= " , pack->key_frame->getTimeStamp() ); WOLF_DEBUG( "PT ", getName(), " FIRST_TIME_WITH_PACK: KF" , pack->key_frame->id() , " callback unpacked with ts= " , pack->key_frame->getTimeStamp() );
// Append incoming to KF // Append incoming to KF
// pack->key_frame->addCapture(incoming_ptr_);
incoming_ptr_->link(pack->key_frame); incoming_ptr_->link(pack->key_frame);
// Process info // Process info
...@@ -137,7 +136,7 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr) ...@@ -137,7 +136,7 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr)
// Capture last_ is added to the new keyframe // Capture last_ is added to the new keyframe
FrameBasePtr last_old_frame = last_ptr_->getFrame(); FrameBasePtr last_old_frame = last_ptr_->getFrame();
last_ptr_->link(pack->key_frame); // automatically calling last_ptr_->unlink(); last_ptr_->move(pack->key_frame);
last_old_frame->remove(); last_old_frame->remove();
// Create new frame // Create new frame
...@@ -204,7 +203,7 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr) ...@@ -204,7 +203,7 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr)
// make F; append incoming to new F // make F; append incoming to new F
FrameBasePtr frm = getProblem()->emplaceFrame(NON_ESTIMATED, incoming_ptr_->getTimeStamp()); FrameBasePtr frm = getProblem()->emplaceFrame(NON_ESTIMATED, incoming_ptr_->getTimeStamp());
frm->addCapture(incoming_ptr_); incoming_ptr_->link(frm);
// Establish factors // Establish factors
establishFactors(); establishFactors();
...@@ -227,10 +226,9 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr) ...@@ -227,10 +226,9 @@ void ProcessorTracker::processCapture(CaptureBasePtr _incoming_ptr)
// We do not create a KF // We do not create a KF
// Advance this // Advance this
// last_ptr_->getFrame()->addCapture(incoming_ptr_); // Add incoming Capture to the tracker's last Frame FrameBasePtr frm = getProblem()->emplaceFrame(NON_ESTIMATED, last_ptr_->getFrame()->getState(), incoming_ptr_->getTimeStamp());
incoming_ptr_->link(last_ptr_->getFrame()); incoming_ptr_->link(frm);
last_ptr_->remove(); last_ptr_->getFrame()->remove(); // implicitly calling last_ptr_->remove();
incoming_ptr_->getFrame()->setTimeStamp(incoming_ptr_->getTimeStamp());
// Update pointers // Update pointers
advanceDerived(); advanceDerived();
......
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