11 using namespace Kalman;
16 return((((
float)rand())/(RAND_MAX-1) - 0.5f)* 3.464101615138f);
26 for(i = 0; i < n; i++)
28 temp /= sqrt((
float)n);
39 const unsigned NTRY = 500;
49 static const double _P0[] = {100.0*100.0, 0.0, 0.0, 0.0,
50 0.0, 10.0*10.0, 0.0, 0.0,
51 0.0, 0.0, 25.0*25.0, 0.0,
52 0.0, 0.0, 0.0, 10.0*10.0};
60 dataInput.open(
"../Matlab/data.m",ifstream::in);
61 dataOutput.open(
"../Matlab/trajectory_udu_load.m", ofstream::out | ofstream::trunc);
65 cout<<
"Unable to open input file!"<<endl;
69 if (dataOutput.fail())
71 cout<<
"Unable to open output file!"<<endl;
75 cout<<
"Loading inputs and measures from file <data.m>."<<endl;
84 cout<<
"IO error!"<<endl;
100 cout<<
"IO error!"<<endl;
108 cout<<
"angle: "<<Measure(1,1)<<
"rayon: "<<Measure(2,1)<<endl;
109 x(1) = cos(Measure(1,1))*Measure(2,1);
111 x(3) = sin(Measure(1,1))*Measure(2,1);
116 cout <<
"xp(" <<
":," << i<<
") = " << filter.
getX()<<endl;
118 dataOutput<<
"trajectory_udu(" <<
":," << i <<
") = " << filter.
getX()<<endl;
120 for (i = 2; i <= NTRY; ++i)
123 for(j = 1; j <= m; j++)
130 cout <<
"xp(" <<
":," << i<<
") = " << filter.
getX()<<endl;
131 dataOutput<<
"trajectory_udu(" <<
":," << i<<
") = " << filter.
getX()<<endl;
KVectorContext createKVectorContext(std::string elemDelim=" ", std::string startDelim="", std::string endDelim="", unsigned prec=4)
Creates a vector printing context.
void step(Vector &u_, const Vector &z_)
Makes one prediction-correction step.
KMatrixContext createKMatrixContext(std::string elemDelim=" ", std::string rowDelim="\n", std::string startDelim="", std::string endDelim="", unsigned prec=4)
Creates a matrix printing context.
void init(Vector &x_, Matrix &P_)
Sets initial conditions for the Kalman Filter.
KVectorContext selectKVectorContext(KVectorContext c)
Selects a vector printing context as the current context.
const Vector & getX() const
Returns the corrected state (a posteriori state estimate).
KMatrixContext selectKMatrixContext(KMatrixContext c)
Selects a matrix printing context as the current context.