-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
81 lines (60 loc) · 1.81 KB
/
main.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
74
75
76
77
78
79
80
#include "lib/Matrix.cpp"
#include "lib/KalmanOdometry.cpp"
#include <iostream>
#include <iomanip>
#include <map>
#include <random>
int main ()
{
double measure_error_std = 2.4;
std::random_device rd{};
std::mt19937 gen{rd()};
std::normal_distribution<> d{0.0,measure_error_std};
std::map<int, int> hist_measure{};
std::map<int, int> hist_prediction{};
// double delta_t = 2.5e-3;
int delta_t = 25;
int t = 0;
double x = 0.0;
double y = 0.0;
KalmanOdometry* ko = new KalmanOdometry(278.0, -20.57, -20.9);
ko->y_r = 100.0;
unsigned int i = 0;
double _measures[3] = {0.0, 0.0, 0.0};
Matrix* Measures = new Matrix(3,1,_measures);
while(t < 150000)
{
double delta_l = 79.6;
double delta_r = 79.6005;
if(t > 500)
{
delta_l = 0;
delta_r = 0;
}
ko->prediction(delta_l, delta_r, ko->x_r, ko->y_r, ko->th_r);
double _measure = 100.0 + std::round(d(gen));
++hist_measure[_measure];
// printf("[Main] Normal random: %f\n", _measure);
_measures[1] = _measure;
// già trasposta
Measures->set(3,1,_measures);
ko->measure(Measures);
ko->update();
++hist_prediction[ko->y_r];
printf("[Main] x %f, y %f\n", ko->x_r, ko->y_r);
t = t + delta_t;
i++;
}
printf("KALMAN FILTER\n\n");
printf("[Main] MEASURES HISTOGRAM\n");
for(auto p : hist_measure) {
std::cout << std::setw(2)
<< p.first << ' ' << std::string(p.second/50, '*') << '\n';
}
printf("\n");
printf("[Main] PREDICTION HISTOGRAM\n");
for(auto p : hist_prediction) {
std::cout << std::setw(2)
<< p.first << ' ' << std::string(p.second/50, '*') << '\n';
}
}