Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <filter/extendedkalmanfilter.h>
00024
00025 #include <model/linearanalyticsystemmodel_gaussianuncertainty.h>
00026 #include <model/linearanalyticmeasurementmodel_gaussianuncertainty.h>
00027
00028 #include <pdf/analyticconditionalgaussian.h>
00029 #include <pdf/linearanalyticconditionalgaussian.h>
00030
00031 #include "../mobile_robot.h"
00032
00033 #include <iostream>
00034 #include <fstream>
00035
00036
00037 #include "../mobile_robot_wall_cts.h"
00038
00039 using namespace MatrixWrapper;
00040 using namespace BFL;
00041 using namespace std;
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 int main(int argc, char** argv)
00073 {
00074 cerr << "==================================================" << endl
00075 << "Test of kalman filter" << endl
00076 << "Mobile robot localisation example" << endl
00077 << "==================================================" << endl;
00078
00079
00080
00081
00082
00083
00084
00085 Matrix A(2,2);
00086 A(1,1) = 1.0;
00087 A(1,2) = 0.0;
00088 A(2,1) = 0.0;
00089 A(2,2) = 1.0;
00090 Matrix B(2,2);
00091 B(1,1) = cos(0.8);
00092 B(1,2) = 0.0;
00093 B(2,1) = sin(0.8);
00094 B(2,2) = 0.0;
00095
00096 vector<Matrix> AB(2);
00097 AB[0] = A;
00098 AB[1] = B;
00099
00100
00101 ColumnVector sysNoise_Mu(2);
00102 sysNoise_Mu(1) = MU_SYSTEM_NOISE_X;
00103 sysNoise_Mu(2) = MU_SYSTEM_NOISE_Y;
00104
00105 SymmetricMatrix sysNoise_Cov(2);
00106 sysNoise_Cov = 0.0;
00107 sysNoise_Cov(1,1) = SIGMA_SYSTEM_NOISE_X;
00108 sysNoise_Cov(1,2) = 0.0;
00109 sysNoise_Cov(2,1) = 0.0;
00110 sysNoise_Cov(2,2) = SIGMA_SYSTEM_NOISE_Y;
00111
00112 Gaussian system_Uncertainty(sysNoise_Mu, sysNoise_Cov);
00113
00114
00115 LinearAnalyticConditionalGaussian sys_pdf(AB, system_Uncertainty);
00116 LinearAnalyticSystemModelGaussianUncertainty sys_model(&sys_pdf);
00117
00118
00119
00120
00121
00122
00123
00124 Matrix H(1,2);
00125 double wall_ct = 2/(sqrt(pow(RICO_WALL,2.0) + 1));
00126 H = 0.0;
00127 H(1,1) = wall_ct * RICO_WALL;
00128 H(1,2) = 0 - wall_ct;
00129
00130
00131 ColumnVector measNoise_Mu(1);
00132 measNoise_Mu(1) = MU_MEAS_NOISE;
00133
00134 SymmetricMatrix measNoise_Cov(1);
00135 measNoise_Cov(1,1) = SIGMA_MEAS_NOISE;
00136 Gaussian measurement_Uncertainty(measNoise_Mu, measNoise_Cov);
00137
00138
00139 LinearAnalyticConditionalGaussian meas_pdf(H, measurement_Uncertainty);
00140 LinearAnalyticMeasurementModelGaussianUncertainty meas_model(&meas_pdf);
00141
00142
00143
00144
00145
00146
00147 ColumnVector prior_Mu(2);
00148 prior_Mu(1) = PRIOR_MU_X;
00149 prior_Mu(2) = PRIOR_MU_Y;
00150 SymmetricMatrix prior_Cov(2);
00151 prior_Cov(1,1) = PRIOR_COV_X;
00152 prior_Cov(1,2) = 0.0;
00153 prior_Cov(2,1) = 0.0;
00154 prior_Cov(2,2) = PRIOR_COV_Y;
00155 Gaussian prior(prior_Mu,prior_Cov);
00156
00157
00158
00159
00160
00161
00162
00163 ExtendedKalmanFilter filter(&prior);
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 MobileRobot mobile_robot;
00174 ColumnVector input(2);
00175 input(1) = 0.1;
00176 input(2) = 0.0;
00177
00178
00179
00180
00181 cout << "MAIN: Starting estimation" << endl;
00182 unsigned int time_step;
00183 for (time_step = 0; time_step < NUM_TIME_STEPS-1; time_step++)
00184 {
00185
00186 mobile_robot.Move(input);
00187
00188
00189 ColumnVector measurement = mobile_robot.Measure();
00190
00191
00192 filter.Update(&sys_model,input,&meas_model,measurement);
00193 }
00194
00195
00196
00197 Pdf<ColumnVector> * posterior = filter.PostGet();
00198 cout << "After " << time_step+1 << " timesteps " << endl;
00199 cout << " Posterior Mean = " << endl << posterior->ExpectedValueGet() << endl
00200 << " Covariance = " << endl << posterior->CovarianceGet() << "" << endl;
00201
00202
00203 cout << "======================================================" << endl
00204 << "End of the Kalman filter for mobile robot localisation" << endl
00205 << "======================================================"
00206 << endl;
00207
00208
00209 return 0;
00210 }
bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Mon Feb 11 2019 03:45:12