30 typename ExtendedKalmanFilter<VALUE>::T ExtendedKalmanFilter<VALUE>::solve_(
31 const GaussianFactorGraph& linearFactorGraph,
32 const Values& linearizationPoint,
Key lastKey,
38 Ordering lastKeyAsOrdering;
39 lastKeyAsOrdering += lastKey;
41 linearFactorGraph.marginalMultifrontalBayesNet(lastKeyAsOrdering)->front();
44 VectorValues result = marginal->solve(VectorValues());
45 const T& current = linearizationPoint.at<T>(lastKey);
46 T x = traits<T>::Retract(current, result[lastKey]);
52 assert(marginal->nrFrontals() == 1);
53 assert(marginal->nrParents() == 0);
54 *newPrior = boost::make_shared<JacobianFactor>(
55 marginal->keys().front(),
56 marginal->getA(marginal->begin()),
57 marginal->getb() - marginal->getA(marginal->begin()) * result[lastKey],
58 marginal->get_model());
64 template <
class VALUE>
65 ExtendedKalmanFilter<VALUE>::ExtendedKalmanFilter(
66 Key key_initial, T x_initial, noiseModel::Gaussian::shared_ptr P_initial)
72 int n = traits<T>::GetDimension(x_initial);
73 priorFactor_ = JacobianFactor::shared_ptr(
74 new JacobianFactor(key_initial, P_initial->R(), Vector::Zero(n),
75 noiseModel::Unit::Create(n)));
82 const auto keys = motionFactor.
keys();
88 linearFactorGraph.
push_back(priorFactor_);
92 linearizationPoint.
insert(keys[0], x_);
93 linearizationPoint.
insert(keys[1], x_);
98 x_ = solve_(linearFactorGraph, linearizationPoint, keys[1], &priorFactor_);
104 template<
class VALUE>
107 const auto keys = measurementFactor.
keys();
113 linearFactorGraph.
push_back(priorFactor_);
116 Values linearizationPoint;
117 linearizationPoint.
insert(keys[0], x_);
122 x_ = solve_(linearFactorGraph, linearizationPoint, keys[0], &priorFactor_);
void insert(Key j, const Value &val)
Add a variable with the given j, throws KeyAlreadyExists<J> if j is already present.
Definition: Values.cpp:133
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:70
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianConditional.h:42
Class to perform generic Kalman Filtering using nonlinear factor graphs.
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: JacobianFactor.h:93
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Chordal Bayes Net, the result of eliminating a factor graph.
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition: GaussianFactorGraph.h:65
boost::shared_ptr< GaussianFactor > linearize(const Values &x) const
Linearize a non-linearFactorN to get a GaussianFactor, Hence .
Definition: NonlinearFactor.cpp:111
A nonlinear sum-of-squares factor with a zero-mean noise model implementing the density Templated on...
Definition: NonlinearFactor.h:161
Non-linear factor base classes.
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:118
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Linear Factor Graph where all factors are Gaussians.
This is a generic Extended Kalman Filter class implemented using nonlinear factors.
Definition: ExtendedKalmanFilter.h:45
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value >::type push_back(boost::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
Definition: FactorGraph.h:159