20 #include "../model/linearanalyticmeasurementmodel_gaussianuncertainty_implicit.h" 25 #define AnalyticSys AnalyticSystemModelGaussianUncertainty 26 #define LinearAnalyticMeas_Implicit LinearAnalyticMeasurementModelGaussianUncertainty_Implicit 27 #define Numerical_Limitation 100*100 31 nr_iterations(nr_it), JP(prior->CovarianceGet().rows(),prior->CovarianceGet().rows())
43 MatrixWrapper::ColumnVector J = ((
AnalyticSys*)sysmodel)->PredictionGet(u,x);
44 MatrixWrapper::Matrix F = ((
AnalyticSys*)sysmodel)->df_dxGet(u,x);
45 MatrixWrapper::SymmetricMatrix Q = ((
AnalyticSys*)sysmodel)->CovarianceGet(u,x);
61 MatrixWrapper::ColumnVector u(0);
69 MatrixWrapper::Matrix invS(z.rows(),z.rows());
70 MatrixWrapper::Matrix Sr(z.rows(),z.rows());
77 MatrixWrapper::Matrix H_i; MatrixWrapper::SymmetricMatrix R_i;
78 MatrixWrapper::Matrix R_vf; MatrixWrapper::Matrix SR_vf;
79 MatrixWrapper::ColumnVector Z_i;
80 MatrixWrapper::Matrix U; MatrixWrapper::ColumnVector V; MatrixWrapper::Matrix W;
81 MatrixWrapper::Matrix JP1;
int change;
84 Matrix diag(
JP.rows(),
JP.columns());
85 Matrix invdiag(
JP.rows(),
JP.columns());
86 diag=0;invdiag=0;change=0;
90 for(
unsigned int j=1;j<
JP.rows()+1;j++){diag(j,j)=100; invdiag(j,j)=0.01;}
106 R_vf = SR_vf.transpose();
110 R_i.cholesky_semidefinite(R_vf);
111 R_vf = R_vf.transpose();
118 MatrixWrapper::Matrix V_matrix(U.columns(),W.columns());
119 for(
unsigned int k=1;k<
JP.rows()+1;k++)
121 V_matrix(k,k) = V(k);
127 JP = U*V_matrix*(W.transpose());
136 if (i==nr_iterations)
147 const ColumnVector& z)
180 Sigma_new_matrix.convertToSymmetricMatrix(Sigma_new);
190 MatrixWrapper::Matrix S_i1,S_i2,S_temp1;
191 MatrixWrapper::SymmetricMatrix S_temp2,S_temp;
192 S_i1 = ( H_i * (Matrix)
JP * (Matrix) (
JP.transpose())* (H_i.transpose()) );
194 S_temp1 = (S_i1 + S_i2).transpose();
195 S_temp1.convertToSymmetricMatrix(S_temp);
197 S_temp.cholesky_semidefinite(Sr);
201 K_i =
JP*(
JP.transpose())*(H_i.transpose())*(invS.transpose())*invS;
215 MatrixWrapper::ColumnVector x_i;
216 x_i = x_k + K_i * (z - Z_i);
223 MatrixWrapper::Matrix temp;
224 temp = (Matrix)R_vf+(Matrix)Sr;
225 JP = (Matrix)
JP -(Matrix)
JP*(Matrix)(
JP.transpose()) * (H_i.transpose()) * (Matrix)(invS.transpose())*(Matrix)(temp.inverse())*H_i*(Matrix)
JP;
226 MatrixWrapper::SymmetricMatrix Sigma;
227 MatrixWrapper::Matrix Sigma1;
228 Sigma1=(
JP*(
JP.transpose())).transpose();
229 Sigma1.convertToSymmetricMatrix(Sigma);
void PostMuSet(const MatrixWrapper::ColumnVector &c)
Set expected value of posterior estimate.
virtual void CalculateMeasUpdate(MatrixWrapper::ColumnVector z, MatrixWrapper::ColumnVector Z, MatrixWrapper::Matrix H, MatrixWrapper::SymmetricMatrix R)
MatrixWrapper::Matrix SRCovarianceGet() const
Returns a square root of the covariance of the measurement input u.
Class representing Gaussian (or normal density)
void PostSigmaSet(const MatrixWrapper::SymmetricMatrix &s)
Set covariance of posterior estimate.
Pdf< MatrixWrapper::ColumnVector > * _post
Pointer to the Posterior Pdf.
void SRCovarianceSet(MatrixWrapper::Matrix JP_new)
Set the square root covariance to a specific value.
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
MatrixWrapper::Matrix JP
the upper triangular matrix cholesky decompostion of the state covariance ( )
SRIteratedExtendedKalmanFilter(Gaussian *prior, unsigned int nr_it=1)
void PriorSet(MatrixWrapper::ColumnVector &X, MatrixWrapper::SymmetricMatrix &P)
Set mean and covariance of the state estimation to a specific value.
virtual void MeasUpdate(MeasurementModel< MatrixWrapper::ColumnVector, MatrixWrapper::ColumnVector > *const measmodel, const MatrixWrapper::ColumnVector &z, const MatrixWrapper::ColumnVector &s)
Perform a measurement update use a measurement model, measurements z and virutal measurements s...
#define LinearAnalyticMeas_Implicit
Class representing the family of all Kalman Filters (EKF, IEKF, ...)
virtual void SysUpdate(SystemModel< MatrixWrapper::ColumnVector > *const sysmodel, const MatrixWrapper::ColumnVector &u)
Perform a system update with the current measurement model ans system model using an input u...
virtual void CalculateMean(MatrixWrapper::ColumnVector &x_k, const MatrixWrapper::ColumnVector &z, MatrixWrapper::ColumnVector &Z_i, MatrixWrapper::Matrix &K_i)
Calculate the new state estimate.
unsigned int DimensionGet() const
Get the dimension of the argument.
void CalculateSysUpdate(const MatrixWrapper::ColumnVector &J, const MatrixWrapper::Matrix &F, const MatrixWrapper::SymmetricMatrix &Q)
virtual T ExpectedValueGet() const
Get the expected value E[x] of the pdf.
unsigned int nr_iterations
Variable indicating the number of iterations of the filter.
#define Numerical_Limitation
virtual ~SRIteratedExtendedKalmanFilter()
Destructor.
virtual void CalculateMatrix(MatrixWrapper::Matrix &H_i, MatrixWrapper::SymmetricMatrix &R_i, MatrixWrapper::Matrix &invS, MatrixWrapper::Matrix &Sr, MatrixWrapper::Matrix &K_i)
Calculate K_i , invS and Sr.
virtual void CalculateCovariance(MatrixWrapper::Matrix &R_vf, MatrixWrapper::Matrix &H_i, MatrixWrapper::Matrix &invS, MatrixWrapper::Matrix &SR)
Calculate the covariance of the new state estimate (P_k)
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.