Loading...
Searching...
No Matches
LinearContainerFactor.h
Go to the documentation of this file.
#pragma once
#include <gtsam/nonlinear/NonlinearFactorGraph.h>
namespace gtsam {
// Forward declarations
class JacobianFactor;
class HessianFactor;
class GTSAM_EXPORT LinearContainerFactor : public NonlinearFactor {
protected:
GaussianFactor::shared_ptr factor_;
boost::optional<Values> linearizationPoint_;
LinearContainerFactor(const GaussianFactor::shared_ptr& factor, const boost::optional<Values>& linearizationPoint);
// Some handy typedefs
typedef NonlinearFactor Base;
typedef LinearContainerFactor This;
public:
typedef boost::shared_ptr<This> shared_ptr;
LinearContainerFactor() {}
LinearContainerFactor(const JacobianFactor& factor, const Values& linearizationPoint = Values());
LinearContainerFactor(const HessianFactor& factor, const Values& linearizationPoint = Values());
LinearContainerFactor(const GaussianFactor::shared_ptr& factor, const Values& linearizationPoint = Values());
// Access
const GaussianFactor::shared_ptr& factor() const { return factor_; }
// Testable
void print(const std::string& s = "", const KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter) const override;
bool equals(const NonlinearFactor& f, double tol = 1e-9) const override;
// NonlinearFactor
double error(const Values& c) const override;
size_t dim() const override;
const boost::optional<Values>& linearizationPoint() const { return linearizationPoint_; }
GaussianFactor::shared_ptr linearize(const Values& c) const override;
GaussianFactor::shared_ptr negateToGaussian() const;
NonlinearFactor::shared_ptr negateToNonlinear() const;
NonlinearFactor::shared_ptr clone() const override {
return NonlinearFactor::shared_ptr(new LinearContainerFactor(factor_,linearizationPoint_));
}
NonlinearFactor::shared_ptr rekey(
const std::map<Key, Key>& rekey_mapping) const override;
NonlinearFactor::shared_ptr rekey(const KeyVector& new_keys) const override;
inline bool hasLinearizationPoint() const { return linearizationPoint_.is_initialized(); }
bool isJacobian() const;
bool isHessian() const;
boost::shared_ptr<JacobianFactor> toJacobian() const;
boost::shared_ptr<HessianFactor> toHessian() const;
static NonlinearFactorGraph ConvertLinearGraph(const GaussianFactorGraph& linear_graph,
const Values& linearizationPoint = Values());
protected:
void initializeLinearizationPoint(const Values& linearizationPoint);
private:
friend class boost::serialization::access;
template<class ARCHIVE>
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
ar & boost::serialization::make_nvp("NonlinearFactor",
boost::serialization::base_object<Base>(*this));
ar & BOOST_SERIALIZATION_NVP(factor_);
ar & BOOST_SERIALIZATION_NVP(linearizationPoint_);
}
}; // \class LinearContainerFactor
template<> struct traits<LinearContainerFactor> : public Testable<LinearContainerFactor> {};
} // \namespace gtsam
NonlinearFactorGraph.h
Factor Graph consisting of non-linear factors.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::GaussianFactor::shared_ptr
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition GaussianFactor.h:42
gtsam::GaussianFactorGraph
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition GaussianFactorGraph.h:75
gtsam::HessianFactor
A Gaussian factor using the canonical parameters (information form).
Definition HessianFactor.h:101
gtsam::JacobianFactor
A Gaussian factor in the squared-error form.
Definition JacobianFactor.h:91
gtsam::LinearContainerFactor
Dummy version of a generic linear factor to be injected into a nonlinear factor graph.
Definition LinearContainerFactor.h:26
gtsam::LinearContainerFactor::clone
NonlinearFactor::shared_ptr clone() const override
Creates a shared_ptr clone of the factor - needs to be specialized to allow for subclasses.
Definition LinearContainerFactor.h:119
gtsam::LinearContainerFactor::LinearContainerFactor
LinearContainerFactor()
Default constructor - necessary for serialization.
Definition LinearContainerFactor.h:44
gtsam::LinearContainerFactor::linearizationPoint
const boost::optional< Values > & linearizationPoint() const
Extract the linearization point used in recalculating error.
Definition LinearContainerFactor.h:83
gtsam::LinearContainerFactor::LinearContainerFactor
LinearContainerFactor(const GaussianFactor::shared_ptr &factor, const boost::optional< Values > &linearizationPoint)
direct copy constructor
Definition LinearContainerFactor.cpp:29
gtsam::LinearContainerFactor::hasLinearizationPoint
bool hasLinearizationPoint() const
Casting syntactic sugar.
Definition LinearContainerFactor.h:138
gtsam::NonlinearFactor::NonlinearFactor
NonlinearFactor()
Default constructor for I/O only.
Definition NonlinearFactor.h:58
gtsam::NonlinearFactorGraph
Definition NonlinearFactorGraph.h:55
gtsam::Values
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65
Values
In nonlinear factors, the error function returns the negative log-likelihood as a non-linear function...