diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index d0a250aa1012683bb9a38cce6cd2c8ae495c477a..f3feeb56a3bcc6787d8efeb1355175b989dd3f3e 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -261,10 +261,6 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce unsigned int id() const; protected: - /** - * \brief set the pointer to problem - */ - virtual void setProblem(ProblemPtr) override; /** \brief process an incoming capture * * Each derived processor should implement this function. It will be called if: @@ -354,6 +350,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce void setVotingActive(bool _voting_active = true); + int getDim() const; + void link(SensorBasePtr); template<typename classType, typename... T> static std::shared_ptr<classType> emplace(SensorBasePtr _sen_ptr, T&&... all); @@ -400,6 +398,10 @@ inline void ProcessorBase::setTimeTolerance(double _time_tolerance) { params_->time_tolerance = _time_tolerance; } +inline int ProcessorBase::getDim() const +{ + return dim_; +} template<typename classType, typename... T> std::shared_ptr<classType> ProcessorBase::emplace(SensorBasePtr _sen_ptr, T&&... all) diff --git a/src/frame/frame_base.cpp b/src/frame/frame_base.cpp index a3c679b62a78fd7131bed4f7fee11cf6a76bdf70..e7fabaefc24245604cad750d19461d124a231432 100644 --- a/src/frame/frame_base.cpp +++ b/src/frame/frame_base.cpp @@ -140,7 +140,8 @@ void FrameBase::setNonEstimated() { // unregister if previously estimated if (isKeyOrAux()) - removeStateBlocks(getProblem()); + for (const auto& sb : getStateBlockVec()) + getProblem()->notifyStateBlock(sb, REMOVE); type_ = NON_ESTIMATED; if (getTrajectory()) diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index 5d4459d16d257fd4a09733a74d777ff0c310a73f..5249874fdd4ac78d39c5ed23d01e4bc3446e1b70 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -220,6 +220,12 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // } ProcessorBasePtr prc_ptr = ProcessorFactory::get().create(_prc_type, _unique_processor_name, _prc_params); + + //Dimension check + int prc_dim = prc_ptr->getDim(); + auto prb = this; + assert((prc_dim == 0 or prc_dim == prb->getDim()) && "Processor and Problem do not agree on dimension"); + prc_ptr->configure(_corresponding_sensor_ptr); prc_ptr->link(_corresponding_sensor_ptr); @@ -262,9 +268,16 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); ProcessorBasePtr prc_ptr = AutoConfProcessorFactory::get().create(_prc_type, _unique_processor_name, _server); + + //Dimension check + int prc_dim = prc_ptr->getDim(); + auto prb = this; + assert((prc_dim == 0 or prc_dim == prb->getDim()) && "Processor and Problem do not agree on dimension"); + prc_ptr->configure(sen_ptr); prc_ptr->link(sen_ptr); + // setting the origin in all processor motion if origin already setted if (prc_ptr->isMotion() && prior_is_set_) (std::static_pointer_cast<ProcessorMotion>(prc_ptr))->setOrigin(getLastKeyFrame()); diff --git a/src/processor/processor_base.cpp b/src/processor/processor_base.cpp index 954531df6d99ba8df5ccf310f3ae56cba5e9bc8a..a35097f2c70d3b047117ae6d0c9bf81a5fe2f5da 100644 --- a/src/processor/processor_base.cpp +++ b/src/processor/processor_base.cpp @@ -22,13 +22,6 @@ ProcessorBase::~ProcessorBase() // WOLF_DEBUG("destructed -p" , id()); } -void ProcessorBase::setProblem(ProblemPtr _problem) -{ - std::string str = "Processor works with " + std::to_string(dim_) + "D but problem is " + std::to_string(_problem->getDim()) + "D"; - assert((dim_ == 0 or dim_ == _problem->getDim()) && str.c_str()); - - NodeBase::setProblem(_problem); -} bool ProcessorBase::permittedKeyFrame() { return isVotingActive() && getProblem()->permitKeyFrame(shared_from_this()); diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp index 1818c2fbb57aabadd33af0203a4083483aa931bd..634d1f6d1284997573ef763bd329dcdf37cc94d3 100644 --- a/src/processor/processor_motion.cpp +++ b/src/processor/processor_motion.cpp @@ -366,7 +366,7 @@ bool ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXd& _x) const // Get delta and correct it with new calibration params VectorXd calib_preint = capture_motion->getCalibrationPreint(); Motion motion = capture_motion->getBuffer().getMotion(_ts); - + VectorXd delta_step = motion.jacobian_calib_ * (calib - calib_preint); VectorXd delta = capture_motion->correctDelta( motion.delta_integr_, delta_step); @@ -621,13 +621,7 @@ PackKeyFramePtr ProcessorMotion::computeProcessingStep() void ProcessorMotion::setProblem(ProblemPtr _problem) { - if (_problem == nullptr) - return; - - std::string str = "Processor works with " + std::to_string(dim_) + "D but problem is " + std::to_string(_problem->getDim()) + "D"; - assert(dim_ == 0 or dim_ == _problem->getDim() && str.c_str()); - - if (_problem == this->getProblem()) + if (_problem == nullptr or _problem == this->getProblem()) return; NodeBase::setProblem(_problem);