Révision 537
Ajouté par Mourougen MARIMOUTOU-POUGARY il y a presque 3 ans
branch/MARIMOUTOU_Mourougen/spa3/sp4a3_kalman.c | ||
---|---|---|
// Pour compiler : gcc sp4a3_kalman.c -lm
|
||
|
||
/**=====================================================================================================**/
|
||
/**MARIMOUTOU Mourougen**/
|
||
/**Programme finale**/
|
||
/**=====================================================================================================**/
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
#include <math.h>
|
||
... | ... | |
double FT[4][4];
|
||
Transpose_Mat(4,4,F,FT);
|
||
|
||
/**Declaration des matrice tampon**/
|
||
/**============== Declaration des matrice tampon ==============**/
|
||
double X1[4][1]= {{0},{0},{0},{0}};
|
||
double X2[4][1]= {{0},{0},{0},{0}};
|
||
double P1[4][4] = {{sigma_etat*sigma_etat, 0, 0, 0},
|
||
... | ... | |
{0, 0, 0, 0},
|
||
{0, 0, 0, 0}};
|
||
|
||
double temp1[4][4],temp2[4][4],temp3[4][4],temp4[4][4],temp5[4][4],temp6[4][4],temp7[4][4],temp8[4][4],temp9[4][4],temp10[4][4],temp11[4][4];
|
||
double temp1[4][4],temp2[4][4],temp3[4][4],temp4[4][4],temp5[4][4],temp6[4][4];
|
||
double temp7[4][4],temp8[4][4],temp9[4][4],temp10[4][4],temp11[4][4];
|
||
/**============================================================**/
|
||
|
||
while(fscanf(fichier, "%lf %lf %lf", &t, &xobs, &yobs)>0){
|
||
printf("-------------%04d--------------\n",cpt);
|
||
... | ... | |
Mul_Mat_Mat(4,4,P1,4,2,HT,temp3);
|
||
Mul_Mat_Mat(4,2,temp3,2,2,temp7,K);
|
||
Plot_Mat(K,"K = ");
|
||
|
||
//X = X + K*([xobs(i);yobs(i)]-H*X);
|
||
double Xobs[2][1]={{xobs},{yobs}};
|
||
double Delta[4][4];
|
||
//Plot_Mat(Delta,"DELTA = Obs - H.X(k+1|k)");
|
||
|
||
double obs[2][1]={{xobs},{yobs}};//Vecteur observation
|
||
double Delta[4][4];
|
||
//DELTA = Obs - H.X(k+1|k)
|
||
Mul_Mat_Mat(2,4,H,4,1,X1,temp8);
|
||
Sub_Mat_Mat(2,1,Xobs,2,1,temp8,Delta);
|
||
|
||
Sub_Mat_Mat(2,1,obs,2,1,temp8,Delta);
|
||
Plot_Mat(Delta,"DELTA = Obs - H.X(k+1|k)");
|
||
//X = X + K*([xobs(i);yobs(i)]-H*X);
|
||
Mul_Mat_Mat(4,2,K,2,1,Delta,temp9);
|
||
Add_Mat_Mat(4,2,X1,2,2,temp9,X2);
|
||
Plot_Mat(X," X(k+1|k+1) = X(k+1|k) + K.Delta = ");
|
||
... | ... | |
Sub_Mat_Mat(4,4,P1,4,4,temp11,P2);
|
||
Plot_Mat(P," P(k+1|k+1) = P(k+1|k) - K.H.P(k+1|k) = ");
|
||
|
||
//Iteration X(k|k)->X(k+1|k) et X(k+1|k)->X(k+1|k+1)
|
||
int i,j;
|
||
for(i=0;i<4;i++)
|
||
{
|
||
for(j=0;j<1;j++)
|
||
{
|
||
X[i][j]=X2[i][j];
|
||
}
|
||
//Iteration X(k|k)->X(k+1|k) et X(k+1|k)->X(k+1|k+1)
|
||
int i,j;
|
||
for(i=0;i<4;i++)
|
||
{
|
||
for(j=0;j<1;j++)
|
||
{
|
||
X[i][j]=X2[i][j];
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
//Iteration P(k|k)->P(k+1|k) et P(k+1|k)->P(k+1|k+1)
|
||
for(i=0;i<4;i++)
|
||
{
|
||
for(j=0;j<4;j++)
|
||
{
|
||
P[i][j]=P2[i][j];
|
||
}
|
||
//Iteration P(k|k)->P(k+1|k) et P(k+1|k)->P(k+1|k+1)
|
||
for(i=0;i<4;i++)
|
||
{
|
||
for(j=0;j<4;j++)
|
||
{
|
||
P[i][j]=P2[i][j];
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
/// La matrice X doit contenir la position filtrée ///
|
||
}
|
||
t = cpt * dt;
|
Formats disponibles : Unified diff
Indentation et commentaire programme finale