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

Add topology API to factors

parent 54a7025a
No related branches found
No related tags found
1 merge request!330Resolve "in factors: getTopology()"
Pipeline #4742 passed
Showing
with 85 additions and 0 deletions
......@@ -48,6 +48,11 @@ class FactorRangeBearing : public FactorAutodiff<FactorRangeBearing, 2, 2, 1, 2,
//
}
virtual std::string getTopology() const override
{
return "LMK";
}
template<typename T>
bool operator ()(const T* const _p_w_r, // robot position
const T* const _o_w_r, // robot orientation
......
......@@ -38,6 +38,11 @@ class FactorAutodiffDistance3D : public FactorAutodiff<FactorAutodiffDistance3D,
virtual ~FactorAutodiffDistance3D() { /* nothing */ }
virtual std::string getTopology() const override
{
return std::string("GEOM");
}
template<typename T>
bool operator () (const T* const _pos1,
const T* const _pos2,
......
......@@ -84,6 +84,21 @@ class FactorBase : public NodeBase, public std::enable_shared_from_this<FactorBa
unsigned int id() const;
/** \brief get the main topological characteristic
* Possible outputs:
* - "ABS" absolute factor
* - "MOTION" motion factor, e.g. odometry, IMU
* - "LOOP" loop closure factor
* - "LMK" landmark observation factor
* - "GEOM" some geometric relation, e.g. distance
* - "UNDEFINED" undefined topology
* - "OTHER" other topologies
* You can add you own return strings if you wish. But the strings above may already have a function in WOLF.
*
* This function needs to be implemented in all derived classes
*/
virtual std::string getTopology() const = 0;
/** \brief Evaluate the factor given the input parameters and returning the residuals and jacobians
**/
virtual bool evaluate(Scalar const* const* _parameters, Scalar* _residuals, Scalar** _jacobians) const = 0;
......
......@@ -62,6 +62,11 @@ class FactorBlockAbsolute : public FactorAnalytic
virtual ~FactorBlockAbsolute() = default;
virtual std::string getTopology() const override
{
return std::string("ABS");
}
/** \brief Returns the residual evaluated in the states provided
*
* Returns the residual evaluated in the states provided in std::vector of mapped Eigen::VectorXs
......
......@@ -80,6 +80,12 @@ class FactorDiffDrive : public FactorAutodiff<FactorDiffDrive,
**/
virtual ~FactorDiffDrive() = default;
virtual std::string getTopology() const override
{
return std::string("MOTION");
}
template<typename T>
bool operator ()(const T* const _p1, const T* const _o1, const T* const _p2,
const T* const _o2, const T* const _c, T* _residuals) const;
......
......@@ -33,6 +33,12 @@ class FactorOdom2D : public FactorAutodiff<FactorOdom2D, 3, 2, 1, 2, 1>
virtual ~FactorOdom2D() = default;
virtual std::string getTopology() const override
{
return std::string("MOTION");
}
template<typename T>
bool operator ()(const T* const _p1, const T* const _o1, const T* const _p2, const T* const _o2,
T* _residuals) const;
......
......@@ -26,6 +26,12 @@ class FactorOdom2DAnalytic : public FactorRelative2DAnalytic
virtual ~FactorOdom2DAnalytic() = default;
virtual std::string getTopology() const override
{
return std::string("MOTION");
}
// /** \brief Returns the factor residual size
// *
// * Returns the factor residual size
......
......@@ -28,6 +28,12 @@ class FactorOdom3D : public FactorAutodiff<FactorOdom3D,6,3,4,3,4>
virtual ~FactorOdom3D() = default;
virtual std::string getTopology() const override
{
return std::string("MOTION");
}
template<typename T>
bool operator ()(const T* const _p_current,
const T* const _q_current,
......
......@@ -25,6 +25,12 @@ class FactorPose2D: public FactorAutodiff<FactorPose2D,3,2,1>
virtual ~FactorPose2D() = default;
virtual std::string getTopology() const override
{
return std::string("ABS");
}
template<typename T>
bool operator ()(const T* const _p, const T* const _o, T* _residuals) const;
......
......@@ -24,6 +24,11 @@ class FactorPose3D: public FactorAutodiff<FactorPose3D,6,3,4>
virtual ~FactorPose3D() = default;
virtual std::string getTopology() const override
{
return std::string("ABS");
}
template<typename T>
bool operator ()(const T* const _p, const T* const _o, T* _residuals) const;
......
......@@ -32,6 +32,11 @@ class FactorQuaternionAbsolute: public FactorAutodiff<FactorQuaternionAbsolute,3
virtual ~FactorQuaternionAbsolute() = default;
virtual std::string getTopology() const override
{
return std::string("ABS");
}
template<typename T>
bool operator ()(const T* const _o, T* _residuals) const;
......
......@@ -54,6 +54,11 @@ class FactorRelative2DAnalytic : public FactorAnalytic
//
}
virtual std::string getTopology() const override
{
return std::string("GEOM");
}
virtual ~FactorRelative2DAnalytic() = default;
/** \brief Returns the factor residual size
......
......@@ -18,6 +18,11 @@ class FactorFeatureDummy : public FactorBase
virtual ~FactorFeatureDummy() = default;
virtual std::string getTopology() const override
{
return "DUMMY";
}
/** \brief Evaluate the factor given the input parameters and returning the residuals and jacobians
**/
virtual bool evaluate(Scalar const* const* parameters, Scalar* residuals, Scalar** jacobians) const override {return true;};
......
......@@ -18,6 +18,11 @@ class FactorLandmarkDummy : public FactorBase
virtual ~FactorLandmarkDummy() = default;
virtual std::string getTopology() const override
{
return "DUMMY";
}
/** \brief Evaluate the factor given the input parameters and returning the residuals and jacobians
**/
virtual bool evaluate(Scalar const* const* parameters, Scalar* residuals, Scalar** jacobians) const override {return true;};
......
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