Projet

Général

Profil

« Précédent | Suivant » 

Révision 566

Ajouté par Romain CHAMBELLON il y a presque 3 ans

Implantation fonctions X, Pk, K

Voir les différences:

branch/CHAMBELLON/sp4a3/sp4a3_kalman.c
{0, 0, 0, 1}};
double FT[4][4];
Transpose_Mat(4,4,F,FT);
/// On definit des matrices intermediaires pour les calculs pour eviter l'utilisation
/// d'une meme variable matricielle en entree et en sortie de fonction d'opérations
double Xk[4][1];
double P1[4][4];
double P2[4][4];
double Pk[4][4];
double NK1[4][2];
double DK1[2][4];
double DK2[2][2];
double DK3[2][2];
double DK4[2][2];
while(fscanf(fichier, "%lf %lf %lf", &t, &xobs, &yobs)>0){
......
xobs=xobs-x0;yobs=yobs-y0;
Plot_Mat(F,"F = ");
Plot_Mat(H,"H = ");
Plot_Mat(R,"R = ");
Plot_Mat(R,"R = ");
}
else
{
t -= t0;xobs -= x0;yobs -= y0;
debug=0; ///Mettre à 1 pour afficher les matrices.
debug=1; ///Mettre à 1 pour afficher les matrices.
///Ajouter votre code ci-dessous
/// Kalman
// X = F*X
Mul_Mat_Mat(4, 4, F, 4, 1, X, Xk);
Plot_Mat(Xk," X(k+1|k) = ");
Plot_Mat(X," X(k+1|k) = ");
//P = F*P*F'+Q;
Mul_Mat_Mat(4,4,F,4,4,P,P1);
Mul_Mat_Mat(4,4,P1,4,4,FT,P2);
Add_Mat_Mat(4,4,P2,4,4,Q,Pk);
Plot_Mat(Pk,"P(k+1|k) = F.P(k|k).FT + Q = ");
//P = F*P*F'+Q;
Plot_Mat(P,"P(k+1|k) = F.P(k|k).FT + Q = ");
// K = P*H' / ( H*P*H' + R);
Mul_Mat_Mat(4,4,Pk,4,2,HT,NK1); // Calcul du numerateur de K
Mul_Mat_Mat(2,4,H,4,4,Pk,DK1); // Calcul du dénominateur de K
Mul_Mat_Mat(2,4,DK1,4,2,HT,DK2);
Add_Mat_Mat(2,2,DK2,2,2,R,DK3);
Inverse_Mat_22(2,2,DK3,DK4); // Calcul de l'inverse pour faire la division
Mul_Mat_Mat(4,2,NK1,2,2,DK4,K);
Plot_Mat(K,"K = ");
// K = P*H' / ( H*P*H' + R);
Plot_Mat(K,"K = ");
//X = X + K*([xobs(i);yobs(i)]-H*X);
//X = X + K*([xobs(i);yobs(i)]-H*X);
//Plot_Mat(Delta,"DELTA = Obs - H.X(k+1|k)");
Plot_Mat(X," X(k+1|k+1) = X(k+1|k) + K.Delta = ");

Formats disponibles : Unified diff