27 #ifndef G2O_UNSCENTED_ 28 #define G2O_UNSCENTED_ 31 #include <Eigen/Cholesky> 32 #include<Eigen/StdVector> 36 template <
class SampleType>
39 SigmaPoint(
const SampleType& sample,
double wi,
double wp):
48 template <
class SampleType,
class CovarianceType>
51 const int dim = mean.size();
52 const int numPoints = 2 * dim + 1;
53 assert (covariance.rows() == covariance.cols() && covariance.cols() == mean.size() &&
"Dimension Mismatch");
54 const double alpha = 1e-3;
55 const double beta = 2.;
56 const double lambda = alpha * alpha * dim;
57 const double wi = 1./(2. * (dim + lambda) );
59 sigmaPoints.resize(numPoints);
61 lambda/(dim + lambda),
62 lambda/(dim + lambda) + (1.-alpha*alpha+beta) );
63 Eigen::LLT<CovarianceType> cholDecomp;
64 cholDecomp.compute(covariance*(dim+lambda));
65 if (cholDecomp.info()==Eigen::NumericalIssue)
67 const CovarianceType& L=cholDecomp.matrixL();
69 for (
int i=0; i<dim; i++) {
70 SampleType s(L.col(i));
77 template <
class SampleType,
class CovarianceType>
83 for (
size_t i=0; i<sigmaPoints.size(); i++){
84 mean += sigmaPoints[i]._wi * sigmaPoints[i]._sample;
86 for (
size_t i=0; i<sigmaPoints.size(); i++){
87 SampleType delta = sigmaPoints[i]._sample - mean;
88 covariance += sigmaPoints[i]._wp * ( delta* delta.transpose() ) ;
SigmaPoint(const SampleType &sample, double wi, double wp)
void reconstructGaussian(SampleType &mean, CovarianceType &covariance, const std::vector< SigmaPoint< SampleType >, Eigen::aligned_allocator< SigmaPoint< SampleType > > > &sigmaPoints)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
bool sampleUnscented(std::vector< SigmaPoint< SampleType >, Eigen::aligned_allocator< SigmaPoint< SampleType > > > &sigmaPoints, const SampleType &mean, const CovarianceType &covariance)