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

Completely remove ConstraintCategory enum

parent 4c88ec46
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,6 @@ ConstraintBase::ConstraintBase(ConstraintType _tp, bool _apply_loss_function, Co ...@@ -11,7 +11,6 @@ ConstraintBase::ConstraintBase(ConstraintType _tp, bool _apply_loss_function, Co
feature_ptr_(), // nullptr feature_ptr_(), // nullptr
constraint_id_(++constraint_id_count_), constraint_id_(++constraint_id_count_),
type_id_(_tp), type_id_(_tp),
category_(CTR_ABSOLUTE),
status_(_status), status_(_status),
apply_loss_function_(_apply_loss_function), apply_loss_function_(_apply_loss_function),
frame_other_ptr_(), // nullptr frame_other_ptr_(), // nullptr
...@@ -30,7 +29,6 @@ ConstraintBase::ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr ...@@ -30,7 +29,6 @@ ConstraintBase::ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr
feature_ptr_(), feature_ptr_(),
constraint_id_(++constraint_id_count_), constraint_id_(++constraint_id_count_),
type_id_(_tp), type_id_(_tp),
category_(CTR_FRAME),
status_(_status), status_(_status),
apply_loss_function_(_apply_loss_function), apply_loss_function_(_apply_loss_function),
frame_other_ptr_(_frame_other_ptr), frame_other_ptr_(_frame_other_ptr),
...@@ -40,53 +38,6 @@ ConstraintBase::ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr ...@@ -40,53 +38,6 @@ ConstraintBase::ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr
// std::cout << "constructed +c" << id() << std::endl; // std::cout << "constructed +c" << id() << std::endl;
} }
//ConstraintBase::ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr, bool _apply_loss_function, ConstraintStatus _status) :
// NodeBase("CONSTRAINT", "Base"),
// feature_ptr_(),
// constraint_id_(++constraint_id_count_),
// type_id_(_tp),
// category_(CTR_FRAME),
// status_(_status),
// apply_loss_function_(_apply_loss_function),
// frame_other_ptr_(_frame_other_ptr),
// feature_other_ptr_(),
// landmark_other_ptr_()
//{
//// std::cout << "constructed +c" << id() << std::endl;
//}
//
//
//ConstraintBase::ConstraintBase(ConstraintType _tp, FeatureBasePtr _feature_other_ptr, bool _apply_loss_function, ConstraintStatus _status) :
// NodeBase("CONSTRAINT"),
// feature_ptr_(),
// constraint_id_(++constraint_id_count_),
// type_id_(_tp),
// category_(CTR_FEATURE),
// status_(_status),
// apply_loss_function_(_apply_loss_function),
// frame_other_ptr_(),
// feature_other_ptr_(_feature_other_ptr),
// landmark_other_ptr_()
//{
//// std::cout << "constructed +c" << id() << std::endl;
//}
//
//
//ConstraintBase::ConstraintBase(ConstraintType _tp, LandmarkBasePtr _landmark_other_ptr, bool _apply_loss_function, ConstraintStatus _status) :
// NodeBase("CONSTRAINT"),
// feature_ptr_(),
// constraint_id_(++constraint_id_count_),
// type_id_(_tp),
// category_(CTR_LANDMARK),
// status_(_status),
// apply_loss_function_(_apply_loss_function),
// frame_other_ptr_(),
// feature_other_ptr_(),
// landmark_other_ptr_(_landmark_other_ptr)
//{
//// std::cout << "constructed +c" << id() << std::endl;
//}
ConstraintBase::~ConstraintBase() ConstraintBase::~ConstraintBase()
{ {
// std::cout << "destructed -c" << id() << std::endl; // std::cout << "destructed -c" << id() << std::endl;
...@@ -109,20 +60,7 @@ void ConstraintBase::remove() ...@@ -109,20 +60,7 @@ void ConstraintBase::remove()
if (getProblem() != nullptr) if (getProblem() != nullptr)
getProblem()->removeConstraintPtr(shared_from_this()); getProblem()->removeConstraintPtr(shared_from_this());
// remove other: {Frame, feature, Landmark} // remove other: {Frame, feature, Landmark}
// switch (category_)
// {
// case CTR_FRAME:
// {
// if (frame_other_ptr_ != nullptr)
// {
FrameBasePtr frm_o = frame_other_ptr_.lock(); FrameBasePtr frm_o = frame_other_ptr_.lock();
if (frm_o) if (frm_o)
{ {
...@@ -130,12 +68,7 @@ void ConstraintBase::remove() ...@@ -130,12 +68,7 @@ void ConstraintBase::remove()
if (frm_o->getConstrainedByList().empty() && frm_o->getCaptureList().empty()) if (frm_o->getConstrainedByList().empty() && frm_o->getCaptureList().empty())
frm_o->remove(); frm_o->remove();
} }
// }
// break;
// case CTR_FEATURE:
// {
// if (feature_other_ptr_ != nullptr)
// {
FeatureBasePtr ftr_o = feature_other_ptr_.lock(); FeatureBasePtr ftr_o = feature_other_ptr_.lock();
if (ftr_o) if (ftr_o)
{ {
...@@ -143,12 +76,7 @@ void ConstraintBase::remove() ...@@ -143,12 +76,7 @@ void ConstraintBase::remove()
if (ftr_o->getConstrainedByList().empty() && ftr_o->getConstraintList().empty()) if (ftr_o->getConstrainedByList().empty() && ftr_o->getConstraintList().empty())
ftr_o->remove(); ftr_o->remove();
} }
// break;
// }
// case CTR_LANDMARK:
// {
// if (landmark_other_ptr_ != nullptr)
// {
LandmarkBasePtr lmk_o = landmark_other_ptr_.lock(); LandmarkBasePtr lmk_o = landmark_other_ptr_.lock();
if (lmk_o) if (lmk_o)
{ {
...@@ -156,13 +84,7 @@ void ConstraintBase::remove() ...@@ -156,13 +84,7 @@ void ConstraintBase::remove()
if (lmk_o->getConstrainedByList().empty()) if (lmk_o->getConstrainedByList().empty())
lmk_o->remove(); lmk_o->remove();
} }
// break;
// }
// case CTR_ABSOLUTE:
// break;
// default:
// break;
// }
// std::cout << "Removed c" << id() << std::endl; // std::cout << "Removed c" << id() << std::endl;
} }
} }
......
...@@ -26,7 +26,6 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons ...@@ -26,7 +26,6 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons
protected: protected:
unsigned int constraint_id_; unsigned int constraint_id_;
ConstraintType type_id_; ///< type of constraint (types defined at wolf.h) ConstraintType type_id_; ///< type of constraint (types defined at wolf.h)
ConstraintCategory category_; ///< category of constraint (types defined at wolf.h)
ConstraintStatus status_; ///< status of constraint (types defined at wolf.h) ConstraintStatus status_; ///< status of constraint (types defined at wolf.h)
bool apply_loss_function_; ///< flag for applying loss function to this constraint bool apply_loss_function_; ///< flag for applying loss function to this constraint
FrameBaseWPtr frame_other_ptr_; ///< FrameBase pointer (for category CTR_FRAME) FrameBaseWPtr frame_other_ptr_; ///< FrameBase pointer (for category CTR_FRAME)
...@@ -43,18 +42,6 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons ...@@ -43,18 +42,6 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons
**/ **/
ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr, FeatureBasePtr _feature_other_ptr, LandmarkBasePtr _landmark_other_ptr, bool _apply_loss_function, ConstraintStatus _status); ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr, FeatureBasePtr _feature_other_ptr, LandmarkBasePtr _landmark_other_ptr, bool _apply_loss_function, ConstraintStatus _status);
// /** \brief Constructor of category CTR_FRAME
// **/
// ConstraintBase(ConstraintType _tp, FrameBasePtr _frame_other_ptr, bool _apply_loss_function, ConstraintStatus _status);
//
// /** \brief Constructor of category CTR_FEATURE
// **/
// ConstraintBase(ConstraintType _tp, FeatureBasePtr _feature_other_ptr, bool _apply_loss_function, ConstraintStatus _status);
//
// /** \brief Constructor of category CTR_LANDMARK
// **/
// ConstraintBase(ConstraintType _tp, LandmarkBasePtr _landmark_other_ptr, bool _apply_loss_function, ConstraintStatus _status);
virtual ~ConstraintBase(); virtual ~ConstraintBase();
void remove(); void remove();
...@@ -101,10 +88,6 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons ...@@ -101,10 +88,6 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons
**/ **/
virtual unsigned int getSize() const = 0; virtual unsigned int getSize() const = 0;
/** \brief Gets the category
*/
ConstraintCategory getCategory() const;
/** \brief Gets the status /** \brief Gets the status
*/ */
ConstraintStatus getStatus() const; ConstraintStatus getStatus() const;
...@@ -183,10 +166,10 @@ inline FeatureBasePtr ConstraintBase::getFeaturePtr() const ...@@ -183,10 +166,10 @@ inline FeatureBasePtr ConstraintBase::getFeaturePtr() const
return feature_ptr_.lock(); return feature_ptr_.lock();
} }
inline ConstraintCategory ConstraintBase::getCategory() const //inline ConstraintCategory ConstraintBase::getCategory() const
{ //{
return category_; // return category_;
} //}
inline ConstraintStatus ConstraintBase::getStatus() const inline ConstraintStatus ConstraintBase::getStatus() const
{ {
......
...@@ -674,7 +674,7 @@ void Problem::print(int depth, bool constr_by, bool metric, bool state_blocks) ...@@ -674,7 +674,7 @@ void Problem::print(int depth, bool constr_by, bool metric, bool state_blocks)
for (auto c : f->getConstraintList()) for (auto c : f->getConstraintList())
{ {
cout << " c" << c->id() << " -->"; cout << " c" << c->id() << " -->";
if (c->getCategory() == CTR_ABSOLUTE) if (c->getFrameOtherPtr() != nullptr && c->getFeatureOtherPtr() != nullptr && c->getLandmarkOtherPtr() != nullptr)
cout << " A"; cout << " A";
if (c->getFrameOtherPtr() != nullptr) if (c->getFrameOtherPtr() != nullptr)
cout << " F" << c->getFrameOtherPtr()->id(); cout << " F" << c->getFrameOtherPtr()->id();
...@@ -806,69 +806,66 @@ bool Problem::check(int verbose_level) ...@@ -806,69 +806,66 @@ bool Problem::check(int verbose_level)
{ {
if (verbose_level > 0) if (verbose_level > 0)
std::cout << " c" << c->id() << " @" << C.get(); std::cout << " c" << c->id() << " @" << C.get();
switch (c->getCategory()) if ( !(c->getFrameOtherPtr()) && !(c->getFeatureOtherPtr()) && !(c->getLandmarkOtherPtr()) ) // case ABSOLUTE:
{ {
case CTR_ABSOLUTE: if (verbose_level > 0)
if (verbose_level > 0) std::cout << " --> A" << std::endl;
std::cout << " --> A" << std::endl; }
break;
case CTR_FRAME: if (!(c->getFrameOtherPtr()) ) // case FRAME:
{
auto Fo = c->getFrameOtherPtr();
if (verbose_level > 0)
std::cout << " --> F" << Fo->id() << " <- ";
bool found = false;
for (auto cby : Fo->getConstrainedByList())
{ {
auto Fo = c->getFrameOtherPtr();
if (verbose_level > 0)
std::cout << " --> F" << Fo->id() << " <- ";
bool found = false;
for (auto cby : Fo->getConstrainedByList())
{
if (verbose_level > 0)
std::cout << " c" << cby->id();
found = found || (c == cby);
}
if (verbose_level > 0) if (verbose_level > 0)
std::cout << std::endl; std::cout << " c" << cby->id();
is_consistent = is_consistent && found; found = found || (c == cby);
break;
} }
case CTR_FEATURE: if (verbose_level > 0)
std::cout << std::endl;
is_consistent = is_consistent && found;
}
if ( !(c->getFeatureOtherPtr()) ) // case FEATURE:
{
auto fo = c->getFeatureOtherPtr();
if (verbose_level > 0)
std::cout << " --> f" << fo->id() << " <- ";
bool found = false;
for (auto cby : fo->getConstrainedByList())
{ {
auto fo = c->getFeatureOtherPtr();
if (verbose_level > 0) if (verbose_level > 0)
std::cout << " --> f" << fo->id() << " <- "; std::cout << " c" << cby->id();
bool found = false; found = found || (c == cby);
for (auto cby : fo->getConstrainedByList())
{
if (verbose_level > 0)
std::cout << " c" << cby->id();
found = found || (c == cby);
}
if (verbose_level > 0)
std::cout << std::endl;
is_consistent = is_consistent && found;
break;
} }
case CTR_LANDMARK: if (verbose_level > 0)
std::cout << std::endl;
is_consistent = is_consistent && found;
}
if ( !(c->getLandmarkOtherPtr()) ) // case LANDMARK:
{
auto Lo = c->getLandmarkOtherPtr();
if (verbose_level > 0)
std::cout << " --> L" << Lo->id() << " <- ";
bool found = false;
for (auto cby : Lo->getConstrainedByList())
{ {
auto Lo = c->getLandmarkOtherPtr();
if (verbose_level > 0)
std::cout << " --> L" << Lo->id() << " <- ";
bool found = false;
for (auto cby : Lo->getConstrainedByList())
{
if (verbose_level > 0)
std::cout << " c" << cby->id();
found = found || (c == cby);
}
if (verbose_level > 0) if (verbose_level > 0)
std::cout << std::endl; std::cout << " c" << cby->id();
is_consistent = is_consistent && found; found = found || (c == cby);
break;
} }
if (verbose_level > 0)
std::cout << std::endl;
is_consistent = is_consistent && found;
} }
if (verbose_level > 0) if (verbose_level > 0)
{ {
std::cout << " -> P @ " << c->getProblem().get() << std::endl; std::cout << " -> P @ " << c->getProblem().get() << std::endl;
std::cout << " -> f" << c->getFeaturePtr()->id() << " @ " << c->getFeaturePtr().get() std::cout << " -> f" << c->getFeaturePtr()->id() << " @ " << c->getFeaturePtr().get() << std::endl;
<< std::endl;
} }
is_consistent = is_consistent && (c->getProblem().get() == P_raw); is_consistent = is_consistent && (c->getProblem().get() == P_raw);
is_consistent = is_consistent && (c->getFeaturePtr() == f); is_consistent = is_consistent && (c->getFeaturePtr() == f);
......
...@@ -150,18 +150,6 @@ typedef enum ...@@ -150,18 +150,6 @@ typedef enum
} ConstraintType; } ConstraintType;
/** \brief Enumeration of constraint categories
*
* You may add items to this list as needed. Be concise with names, and document your entries.
*/
typedef enum
{
CTR_ABSOLUTE = 1, ///< Constraint established with absolute reference.
CTR_FRAME, ///< Constraint established with a frame (odometry).
CTR_FEATURE, ///< Constraint established with a feature (correspondence).
CTR_LANDMARK ///< Constraint established with a landmark (correpondence).
} ConstraintCategory;
/** \brief Enumeration of constraint status /** \brief Enumeration of constraint status
* *
* You may add items to this list as needed. Be concise with names, and document your entries. * You may add items to this list as needed. Be concise with names, and document your entries.
......
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