add a function that dynamically casts gaussian factor graph into jacobian factor graph
parent
9cb903fe08
commit
9fe0b66be5
|
|
@ -102,6 +102,21 @@ void transposeMultiply(const JacobianFactorGraph& fg, const VectorValues &r, Vec
|
|||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
JacobianFactorGraph::shared_ptr dynamicCastFactors(const GaussianFactorGraph &gfg) {
|
||||
JacobianFactorGraph::shared_ptr jfg(new JacobianFactorGraph());
|
||||
jfg->reserve(gfg.size());
|
||||
BOOST_FOREACH(const GaussianFactor::shared_ptr& factor, gfg) {
|
||||
JacobianFactor::shared_ptr castedFactor(boost::dynamic_pointer_cast<JacobianFactor>(factor));
|
||||
if(castedFactor) jfg->push_back(castedFactor);
|
||||
else throw std::invalid_argument("dynamicCastFactors(), dynamic_cast failed, meaning an invalid cast was requested.");
|
||||
}
|
||||
return jfg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@
|
|||
|
||||
#include <gtsam/linear/Errors.h>
|
||||
#include <gtsam/inference/FactorGraph.h>
|
||||
#include <gtsam/linear/GaussianFactorGraph.h>
|
||||
#include <gtsam/linear/JacobianFactor.h>
|
||||
#include <gtsam/linear/VectorValues.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace gtsam {
|
||||
|
||||
|
|
@ -65,4 +67,7 @@ namespace gtsam {
|
|||
void multiply(const JacobianFactorGraph& fg, const VectorValues &x, VectorValues &r);
|
||||
void transposeMultiply(const JacobianFactorGraph& fg, const VectorValues &r, VectorValues &x);
|
||||
|
||||
/** dynamic_cast the gaussian factors down to jacobian factors */
|
||||
JacobianFactorGraph::shared_ptr dynamicCastFactors(const GaussianFactorGraph &gfg);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue