MCPcopy Create free account
hub / github.com/davisking/dlib / test_filter

Function test_filter

dlib/test/filtering.cpp:27–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26 template <typename filter_type>
27 double test_filter (
28 filter_type kf,
29 int size
30 )
31 {
32 // This test has a point moving in a circle around the origin. The point
33 // also gets a random bump in a random direction at each time step.
34
35 running_stats<double> rs;
36
37 dlib::rand rnd;
38 int count = 0;
39 const dlib::vector<double,3> z(0,0,1);
40 dlib::vector<double,2> p(10,10), temp;
41 for (int i = 0; i < size; ++i)
42 {
43 // move the point around in a circle
44 p += z.cross(p).normalize()/0.5;
45 // randomly drop measurements
46 if (rnd.get_random_double() < 0.7 || count < 4)
47 {
48 // make a random bump
49 dlib::vector<double,2> pp;
50 pp.x() = rnd.get_random_gaussian()/3;
51 pp.y() = rnd.get_random_gaussian()/3;
52
53 ++count;
54 kf.update(p+pp);
55 }
56 else
57 {
58 kf.update();
59 dlog << LTRACE << "MISSED MEASUREMENT";
60 }
61 // figure out the next position
62 temp = (p+z.cross(p).normalize()/0.5);
63 const double error = length(temp - rowm(kf.get_predicted_next_state(),range(0,1)));
64 rs.add(error);
65
66 dlog << LTRACE << temp << "("<< error << "): " << trans(kf.get_predicted_next_state());
67
68 // test the serialization a few times.
69 if (count < 10)
70 {
71 ostringstream sout;
72 serialize(kf, sout);
73 istringstream sin(sout.str());
74 filter_type temp;
75 deserialize(temp, sin);
76 kf = temp;
77 }
78 }
79
80
81 return rs.mean();
82
83 }
84

Callers 2

test_kalman_filterFunction · 0.85
test_rls_filterFunction · 0.85

Calls 14

get_random_doubleMethod · 0.80
get_random_gaussianMethod · 0.80
serializeFunction · 0.70
deserializeFunction · 0.70
lengthFunction · 0.50
rowmFunction · 0.50
rangeFunction · 0.50
transFunction · 0.50
normalizeMethod · 0.45
crossMethod · 0.45
updateMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected