Class ScalarFactorGraph

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public mrpt::system::COutputLogger

Class Documentation

class ScalarFactorGraph : public mrpt::system::COutputLogger

Sparse solver for GMRF (Gaussian Markov Random Fields) graphical models. The design of this class is optimized for large problems (e.g. >1e3 nodes, >1e4 constrainst) by leaving to the user/caller the responsibility of allocating all “nodes” and constraints. This class can be seen as an intermediary solution between current methods in mrpt::graphslam and the well-known G2O library:

Assumptions/limitations:

  • Linear error functions (for now).

  • Scalar (1-dim) error functions.

  • Gaussian factors.

  • Solver: Eigen SparseQR.

Usage:

  • Call initialize() to set the number of nodes.

  • Call addConstraints() to insert constraints. This may be called more than once.

  • Call updateEstimation() to run one step of the linear SparseQR solver.

Public Functions

ScalarFactorGraph()
void clear()

Reset state: remove all constraints and nodes.

void initialize(size_t nodeCount)

Initialize the GMRF internal state and copy the prior factors.

Parameters:

nodeCount – Number of unknown nodes in the MRF graph

void addConstraint(const UnaryFactorVirtualBase &listOfConstraints)

Insert constraints into the GMRF problem.

Parameters:

listOfConstraints – List of user-implemented constraints. A pointer to the passed object is kept, but memory ownship REMAINS being responsibility of the caller. This is done such that arrays/vectors of constraints can be more efficiently allocated if their type is known at build time.

void addConstraint(const BinaryFactorVirtualBase &listOfConstraints)
bool eraseConstraint(const FactorBase &c)

Removes a constraint. Return true if found and deleted correctly.

inline void clearAllConstraintsByType_Unary()
inline void clearAllConstraintsByType_Binary()
void updateEstimation(mrpt::math::CVectorDouble &solved_x_inc, mrpt::math::CVectorDouble *solved_variances = nullptr)
Parameters:
  • solved_x_inc – Output increment of the current estimate. Caller must add this vector to current state vector to obtain the optimal estimation.

  • solved_variances – If !=nullptr, the variances of each estimate will be stored here.

inline bool isProfilerEnabled() const
inline void enableProfiler(bool enable = true)
struct BinaryFactorVirtualBase : public mrpt::graphs::ScalarFactorGraph::FactorBase

Simple, scalar (1-dim) constraint (edge) for a GMRF

Public Functions

virtual void evalJacobian(double &dr_dxi, double &dr_dxj) const = 0

Returns the derivative of the residual wrt the node values

Public Members

size_t node_id_i
size_t node_id_j
struct FactorBase

Subclassed by mrpt::graphs::ScalarFactorGraph::BinaryFactorVirtualBase, mrpt::graphs::ScalarFactorGraph::UnaryFactorVirtualBase

Public Functions

virtual ~FactorBase()
virtual double evaluateResidual() const = 0

Return the residual/error of this observation.

virtual double getInformation() const = 0

Return the inverse of the variance of this constraint

struct UnaryFactorVirtualBase : public mrpt::graphs::ScalarFactorGraph::FactorBase

Simple, scalar (1-dim) constraint (edge) for a GMRF

Public Functions

virtual void evalJacobian(double &dr_dx) const = 0

Returns the derivative of the residual wrt the node value

Public Members

size_t node_id