25 #ifndef INCLUDED_SigmaPointGenerator_h_GUID_1277DE61_21A1_42BD_0401_78E74169E598 26 #define INCLUDED_SigmaPointGenerator_h_GUID_1277DE61_21A1_42BD_0401_78E74169E598 32 #include <Eigen/Cholesky> 39 inline double computeNu(std::size_t L,
double alpha) {
40 auto lambda = (L * (alpha * alpha - 1));
41 auto nu = std::sqrt(L + lambda);
67 lambda(alphaSquared * (L + p.
kappa) - L),
68 gamma(std::sqrt(L + lambda)), weightMean0(lambda / (L + lambda)),
69 weightCov0(weightMean0 + p.
beta + 1 - alphaSquared),
70 weight(1. / (2. * (L + lambda))) {}
89 template <std::
size_t Dim, std::
size_t OrigDim = Dim>
92 static_assert(OrigDim <= Dim,
"Original, non-augmented dimension must " 93 "be equal or less than the full " 95 static const std::size_t L = Dim;
96 static const std::size_t OriginalDimension = OrigDim;
97 static const std::size_t NumSigmaPoints = L * 2 + 1;
105 : p_(params, L), mean_(mean), covariance_(cov) {
106 weights_ = SigmaPointWeightVec::Constant(p_.weight);
107 weightsForCov_ = weights_;
108 weights_[0] = p_.weightMean0;
109 weightsForCov_[0] = p_.weightCov0;
110 scaledMatrixSqrt_ = cov.llt().matrixL();
112 sigmaPoints_ << mean,
113 (p_.gamma * scaledMatrixSqrt_).colwise() + mean,
114 (-p_.gamma * scaledMatrixSqrt_).colwise() + mean;
117 SigmaPointsMat const &getSigmaPoints()
const {
return sigmaPoints_; }
124 return sigmaPoints_.template block<OrigDim, 1>(0, i);
131 return weightsForCov_;
134 MeanVec const &getMean()
const {
return mean_; }
151 template <std::
size_t Dim>
154 template <std::
size_t XformedDim,
typename SigmaPo
intsGenType>
157 static const std::size_t DIMENSION = XformedDim;
158 using SigmaPointsGen = SigmaPointsGenType;
159 static const std::size_t NumSigmaPoints =
160 SigmaPointsGen::NumSigmaPoints;
163 SigmaPointsGen::OriginalDimension;
172 SigmaPointsGen
const &sigmaPoints,
177 xformedMean_ = MeanVec::Zero();
178 for (std::size_t i = 0; i < NumSigmaPoints; ++i) {
179 auto weight = sigmaPoints.getWeightsForMean()[i];
180 xformedMean_ += weight * xformedPointsMat.col(i);
184 xformedPointsMat.rowwise() * sigmaPoints.getWeightsForMean();
187 xformedPointsMat.colwise() - xformedMean_;
189 for (std::size_t i = 0; i < NumSigmaPoints; ++i) {
190 auto weight = sigmaPoints.getWeightsForCov()[i];
191 xformedCov_ += weight * zeroMeanPoints.col(i) *
192 zeroMeanPoints.col(i).transpose();
193 crossCov_ += weight * (sigmaPoints.getSigmaPoint(i) -
194 sigmaPoints.getOrigMean()) *
195 zeroMeanPoints.col(i).transpose();
199 MeanVec const &getMean()
const {
return xformedMean_; }
200 CovMat const &getCov()
const {
return xformedCov_; }
213 #endif // INCLUDED_SigmaPointGenerator_h_GUID_1277DE61_21A1_42BD_0401_78E74169E598 double alpha
double L; Primary scaling factor, typically in the range [1e-4, 1]
Definition: SigmaPointGenerator.h:55
AugmentedSigmaPointGenerator(MeanVec const &mean, CovMatrix const &cov, SigmaPointParameters params)
Definition: SigmaPointGenerator.h:103
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: SigmaPointGenerator.h:90
double weightCov0
Element 0 of weight vector for computing covariance.
Definition: SigmaPointGenerator.h:84
Expression of a fixed-size or dynamic-size sub-vector.
Definition: ForwardDeclarations.h:83
Definition: SigmaPointGenerator.h:155
double weightMean0
Element 0 of weight vector for computing means.
Definition: SigmaPointGenerator.h:82
double lambda
"Compound scaling factor"
Definition: SigmaPointGenerator.h:77
double gamma
Scales the matrix square root in computing sigma points.
Definition: SigmaPointGenerator.h:79
double kappa
Tertiary scaling factor, typically 0.
Definition: SigmaPointGenerator.h:61
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
double beta
Secondary scaling to emphasize the 0th sigma point in covariance weighting - 2 is optimal for gaussia...
Definition: SigmaPointGenerator.h:58
ConstOrigMeanVec getOrigMean() const
Get the "un-augmented" mean.
Definition: SigmaPointGenerator.h:139
std::size_t DimensionType
Type for dimensions.
Definition: FlexibleKalmanBase.h:51
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Definition: SigmaPointGenerator.h:63
double weight
Other elements of weight vector.
Definition: SigmaPointGenerator.h:86
ReconstructedDistributionFromSigmaPoints(SigmaPointsGen const &sigmaPoints, TransformedSigmaPointsMat const &xformedPointsMat)
Definition: SigmaPointGenerator.h:171
For further details on the scaling factors, refer to: Julier, S.
Definition: SigmaPointGenerator.h:49