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

Re-code setStatus() with a for loop over state_blk_vec

parent 4eb5d909
No related branches found
No related tags found
No related merge requests found
...@@ -15,11 +15,8 @@ LandmarkBase::LandmarkBase(const LandmarkType & _tp, const std::string& _type, S ...@@ -15,11 +15,8 @@ LandmarkBase::LandmarkBase(const LandmarkType & _tp, const std::string& _type, S
state_block_vec_(4), // allow for 4 state blocks by default. Should be enough in all applications. state_block_vec_(4), // allow for 4 state blocks by default. Should be enough in all applications.
landmark_id_(++landmark_id_count_), landmark_id_(++landmark_id_count_),
type_id_(_tp), type_id_(_tp),
status_(LANDMARK_CANDIDATE)//, status_(LANDMARK_CANDIDATE)
// p_ptr_(_p_ptr),
// o_ptr_(_o_ptr)
{ {
//
state_block_vec_[0] = _p_ptr; state_block_vec_[0] = _p_ptr;
state_block_vec_[1] = _o_ptr; state_block_vec_[1] = _o_ptr;
state_block_vec_[2] = nullptr; state_block_vec_[2] = nullptr;
...@@ -41,7 +38,6 @@ void LandmarkBase::remove() ...@@ -41,7 +38,6 @@ void LandmarkBase::remove()
std::cout << "Removing L" << id() << std::endl; std::cout << "Removing L" << id() << std::endl;
LandmarkBasePtr this_L = shared_from_this(); // keep this alive while removing it LandmarkBasePtr this_L = shared_from_this(); // keep this alive while removing it
// remove from upstream // remove from upstream
auto M = map_ptr_.lock(); auto M = map_ptr_.lock();
if (M) if (M)
...@@ -66,33 +62,47 @@ void LandmarkBase::setStatus(LandmarkStatus _st) ...@@ -66,33 +62,47 @@ void LandmarkBase::setStatus(LandmarkStatus _st)
// State Blocks // State Blocks
if (status_ == LANDMARK_FIXED) if (status_ == LANDMARK_FIXED)
{ {
if (getPPtr()!=nullptr) for (auto sb : state_block_vec_)
{ if (sb != nullptr)
getPPtr()->fix(); {
if (getProblem() != nullptr) sb->fix();
getProblem()->updateStateBlockPtr(getPPtr()); if (getProblem() != nullptr)
} getProblem()->updateStateBlockPtr(sb);
if (getOPtr()!=nullptr) }
{ // if (getPPtr()!=nullptr)
getOPtr()->fix(); // {
if (getProblem() != nullptr) // getPPtr()->fix();
getProblem()->updateStateBlockPtr(getOPtr()); // if (getProblem() != nullptr)
} // getProblem()->updateStateBlockPtr(getPPtr());
// }
// if (getOPtr()!=nullptr)
// {
// getOPtr()->fix();
// if (getProblem() != nullptr)
// getProblem()->updateStateBlockPtr(getOPtr());
// }
} }
else if(status_ == LANDMARK_ESTIMATED) else if(status_ == LANDMARK_ESTIMATED)
{ {
if (getPPtr()!=nullptr) for (auto sb : state_block_vec_)
{ if (sb != nullptr)
getPPtr()->unfix(); {
if (getProblem() != nullptr) sb->unfix();
getProblem()->updateStateBlockPtr(getPPtr()); if (getProblem() != nullptr)
} getProblem()->updateStateBlockPtr(sb);
if (getOPtr()!=nullptr) }
{ // if (getPPtr()!=nullptr)
getOPtr()->unfix(); // {
if (getProblem() != nullptr) // getPPtr()->unfix();
getProblem()->updateStateBlockPtr(getOPtr()); // if (getProblem() != nullptr)
} // getProblem()->updateStateBlockPtr(getPPtr());
// }
// if (getOPtr()!=nullptr)
// {
// getOPtr()->unfix();
// if (getProblem() != nullptr)
// getProblem()->updateStateBlockPtr(getOPtr());
// }
} }
} }
......
...@@ -39,8 +39,6 @@ class LandmarkBase : public NodeBase, public std::enable_shared_from_this<Landma ...@@ -39,8 +39,6 @@ class LandmarkBase : public NodeBase, public std::enable_shared_from_this<Landma
LandmarkType type_id_; ///< type of landmark. (types defined at wolf.h) LandmarkType type_id_; ///< type of landmark. (types defined at wolf.h)
LandmarkStatus status_; ///< status of the landmark. (types defined at wolf.h) LandmarkStatus status_; ///< status of the landmark. (types defined at wolf.h)
TimeStamp stamp_; ///< stamp of the creation of the landmark (and stamp of destruction when status is LANDMARK_OLD) TimeStamp stamp_; ///< stamp of the creation of the landmark (and stamp of destruction when status is LANDMARK_OLD)
// StateBlockPtr p_ptr_; ///< Position state block pointer
// StateBlockPtr o_ptr_; ///< Orientation state block pointer
Eigen::VectorXs descriptor_; //TODO: agree? JS: No: It is not general enough as descriptor to be in LmkBase. Eigen::VectorXs descriptor_; //TODO: agree? JS: No: It is not general enough as descriptor to be in LmkBase.
public: public:
...@@ -149,13 +147,11 @@ inline void LandmarkBase::setId(unsigned int _id) ...@@ -149,13 +147,11 @@ inline void LandmarkBase::setId(unsigned int _id)
inline void LandmarkBase::fix() inline void LandmarkBase::fix()
{ {
//std::cout << "Fixing frame " << nodeId() << std::endl;
this->setStatus(LANDMARK_FIXED); this->setStatus(LANDMARK_FIXED);
} }
inline void LandmarkBase::unfix() inline void LandmarkBase::unfix()
{ {
//std::cout << "Unfixing frame " << nodeId() << std::endl;
this->setStatus(LANDMARK_ESTIMATED); this->setStatus(LANDMARK_ESTIMATED);
} }
......
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