-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKalmanLP_o.cpp
73 lines (60 loc) · 1.25 KB
/
KalmanLP_o.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
int n=2;
double Io[2*2];
// Inicializacion de P1
double Pok[2*2];
// Matriz de covariancia de ruido de Proceso
double Qok[2*2]={
covX2, 0,
0, covY2,
};
// Matriz de covariance del ruido de medicion
double Ro[2*2]={
covX_gps, 0,
0, covY_gps
};
double Rok[2*2];
double Ko[2*2];
double Xo_[2];
double Zo[2];
double Y_o[2];
int Kalman_o(float x, float y){
int n=2;
if (Satellites>=6){
// printf("cont=20");
Zo[0]=x;
Zo[1]=y;
for (int i=0;i<n;i++){
Y_o[i] = Xo_[i];
};
// // Pok=Pok+Qok;
for (int i=0;i<n*n;i++){
Pok[i] += Qok[i];
};
// // Rok=Ro+Pok;
for (int i=0;i<n*n;i++){
Rok[i] = Ro[i] + Pok[i];
};
// // Ko=Pok*Rok.inverse();
inv(Rok, n);
Multi_MM(Pok, Rok, Ko, 'N', 'N', n, n, n);
double M1[n];
double M2[n];
// // Xo_=Xo_+Ko*(Zo-Y_o);
for (int i=0;i<n;i++){
M1[i]=Zo[i]-Y_o[i];
};
Multi_MM(Ko, M1, M2, 'N', 'N', n, 1, n);
for (int i=0;i<n;i++){
Xo_[i] += M2[i];
};
// printMatrix(Xo_, n, 1);
double M3[n*n];
ini_Matrix(Io, 0, 1, 2);
// // Pok=(Io-Ko)*Pok;
for (int i=0;i<n*n;i++){
M3[i]=Io[i]-Ko[i];
};
Multi_MM(M3, Pok, Pok, 'N', 'N', n, n, n);
// printMatrix(Pok, n, n);
}
}