Drastically simplified solve
parent
f2da19e4de
commit
4815f9cf5b
|
@ -38,26 +38,15 @@ namespace gtsam {
|
||||||
static KalmanFilter::State solve(const GaussianFactorGraph& factorGraph,
|
static KalmanFilter::State solve(const GaussianFactorGraph& factorGraph,
|
||||||
const GaussianFactorGraph::Eliminate& function) {
|
const GaussianFactorGraph::Eliminate& function) {
|
||||||
|
|
||||||
// We will eliminate the keys in increasing order, except the last key
|
|
||||||
Ordering ordering1(factorGraph.keys());
|
|
||||||
Key lastKey = ordering1.back();
|
|
||||||
ordering1.pop_back();
|
|
||||||
|
|
||||||
// Eliminate the graph using the provided Eliminate function
|
// Eliminate the graph using the provided Eliminate function
|
||||||
GaussianConditional::shared_ptr conditional;
|
Ordering ordering(factorGraph.keys());
|
||||||
GaussianFactor::shared_ptr factor;
|
GaussianBayesNet::shared_ptr bayesNet = //
|
||||||
boost::tie(conditional, factor) = function(factorGraph, ordering1);
|
factorGraph.eliminateSequential(ordering, function);
|
||||||
|
|
||||||
// As this is a filter, all we need is the posterior P(x_t).
|
// As this is a filter, all we need is the posterior P(x_t).
|
||||||
GaussianFactorGraph graphOfRemainingFactor;
|
// This is the last GaussianConditional in the resulting BayesNet
|
||||||
graphOfRemainingFactor += factor;
|
GaussianConditional::shared_ptr posterior = *(--bayesNet->end());
|
||||||
|
return boost::make_shared<GaussianDensity>(*posterior);
|
||||||
// Eliminate it to be upper-triangular.
|
|
||||||
Ordering ordering2;
|
|
||||||
ordering2 += lastKey;
|
|
||||||
boost::tie(conditional, factor) = function(graphOfRemainingFactor, ordering2);
|
|
||||||
|
|
||||||
return boost::make_shared<GaussianDensity>(*conditional);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
Loading…
Reference in New Issue