Révision 557
Ajouté par Romain CHAMBELLON il y a presque 3 ans
sp4a3_kalman.c | ||
---|---|---|
#include "sp4a3_kalman_extra.h"
|
||
|
||
|
||
void Add_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double B[nb][mb], double R[na][ma]){
|
||
void Add_Mat_Mat(int na, int ma, double A[na][ma], int nb, int mb, double B[nb][mb], double R[na][ma]){
|
||
|
||
int i, j;
|
||
for (i=0;i<na;i++)
|
||
{
|
||
for (j=0;j<ma;j++)
|
||
{
|
||
R[i][j] = A[i][j] + B[i][j];
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
void Inverse_Mat_22(int n,int m,double A[n][m],double B[n][m]){
|
||
void Inverse_Mat_22(int n, int m, double A[n][m], double B[n][m]){
|
||
|
||
double det = A[0][0]*A[1][1]-A[0][1]*A[1][0];
|
||
|
||
B[0][0]=A[1][1]/det;
|
||
B[1][1]=A[0][0]/det;
|
||
B[0][1]=-A[0][1]/det;
|
||
B[1][0]=-A[1][0]/det;
|
||
|
||
|
||
}
|
||
|
||
void Transpose_Mat(int n,int m,double A[n][m],double R[m][n]){
|
||
int i,j;
|
||
for (i=0;i<n;i++)
|
||
for (j=0;j<m;j++)
|
||
R[j][i]=A[i][j];
|
||
void Transpose_Mat(int n, int m, double A[n][m], double R[m][n]){
|
||
|
||
int i,j;
|
||
for (i=0;i<n;i++)
|
||
for (j=0;j<m;j++)
|
||
R[j][i]=A[i][j];
|
||
|
||
}
|
||
|
||
void Sub_Mat_Mat(int na,int ma,double A[na][ma],int nb,int mb,double B[nb][mb], double R[na][ma]){
|
||
void Sub_Mat_Mat(int na, int ma , double A[na][ma], int nb, int mb, double B[nb][mb], double R[na][ma]){
|
||
|
||
int i, j;
|
||
for (i=0;i<na;i++)
|
||
{
|
||
for (j=0;j<ma;j++)
|
||
{
|
||
R[i][j] = A[i][j] - B[i][j];
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
void Mul_Mat_Mat(int na,int ma,double A[na][ma], int nb,int mb,double B[nb][mb], double R[na][mb]){
|
||
void Mul_Mat_Mat(int na, int ma, double A[na][ma], int nb, int mb, double B[nb][mb], double R[na][mb]){
|
||
|
||
int i, j, k;
|
||
for (i=0;i<na;i++)
|
||
{
|
||
for (j=0;j<mb;j++)
|
||
{
|
||
R[i][j] = 0;
|
||
for(k=0;k<ma;k++)
|
||
{
|
||
R[i][j] = R[i][j] + A[i][k]*B[k][j];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
... | ... | |
{0, 0, 1, 0},
|
||
{0, 0, 0, 1}};
|
||
double FT[4][4];
|
||
Transpose_Mat(4,4,F,FT);
|
||
Transpose_Mat(4,4,F,FT);
|
||
|
||
|
||
while(fscanf(fichier, "%lf %lf %lf", &t, &xobs, &yobs)>0){
|
||
printf("-------------%04d--------------\n",cpt);
|
||
|
||
... | ... | |
t -= t0;xobs -= x0;yobs -= y0;
|
||
|
||
debug=0; ///Mettre à 1 pour afficher les matrices.
|
||
///Ajouter votre code ci-dessous///
|
||
// Kalman
|
||
///Ajouter votre code ci-dessous
|
||
/// Kalman
|
||
|
||
// X = F*X
|
||
// X = F*X
|
||
|
||
Plot_Mat(X," X(k+1|k) = ");
|
||
|
||
//P = F*P*F'+Q;
|
||
... | ... | |
// P = P - K*H*P;
|
||
Plot_Mat(P," P(k+1|k+1) = P(k+1|k) - K.H.P(k+1|k) = ");
|
||
|
||
/// La matrice X doit contenir la position filtrée ///
|
||
// La matrice X doit contenir la position filtrée //
|
||
}
|
||
t = cpt * dt;
|
||
dx = (xobs - oldx)/dt;
|
Formats disponibles : Unified diff
Implantation fonctionnelle des fonctions d'opérations matricielles