00001 #include "MobileRobotUnscentedKalmanFilterModel.hpp"
00002
00003 #define SYSTEM_SIZE 5
00004 #define SYSTEM_NOISE_SIZE 2
00005 #define MEAS_SIZE 1
00006 #define MEAS_NOISE_SIZE 1
00007
00008 namespace aux = indii::ml::aux;
00009
00010 MobileRobotUnscentedKalmanFilterModel::MobileRobotUnscentedKalmanFilterModel()
00011 : w(SYSTEM_NOISE_SIZE), v(MEAS_NOISE_SIZE) {
00012 aux::vector mu;
00013 aux::symmetric_matrix sigma;
00014
00015
00016 mu.resize(SYSTEM_NOISE_SIZE, false);
00017 sigma.resize(SYSTEM_NOISE_SIZE, false);
00018
00019 mu.clear();
00020
00021 sigma.clear();
00022 sigma(0,0) = pow(0.01, 2.0);
00023 sigma(1,1) = pow(0.01, 2.0);
00024
00025 w.setExpectation(mu);
00026 w.setCovariance(sigma);
00027
00028
00029 mu.resize(MEAS_NOISE_SIZE, false);
00030 sigma.resize(MEAS_NOISE_SIZE, false);
00031
00032 mu.clear();
00033
00034 sigma.clear();
00035 sigma(0,0) = pow(0.05,2.0);
00036
00037 v.setExpectation(mu);
00038 v.setCovariance(sigma);
00039 }
00040
00041 aux::vector MobileRobotUnscentedKalmanFilterModel::transition(
00042 const aux::vector& x, const aux::vector& w, unsigned int delta) {
00043 aux::vector xtnp1(SYSTEM_SIZE);
00044 xtnp1(0) = x(0) + cos(x(2)) * x(3) + w(0);
00045 xtnp1(1) = x(1) + sin(x(2)) * x(3) + w(1);
00046 xtnp1(2) = x(2) + x(4);
00047 xtnp1(3) = x(3);
00048 xtnp1(4) = x(4);
00049
00050 return xtnp1;
00051 }
00052
00053 aux::vector MobileRobotUnscentedKalmanFilterModel::measure(
00054 const aux::vector& x, const aux::vector& v) {
00055 aux::vector y(MEAS_SIZE);
00056 y(0) = 2.0 * x(1) + v(0);
00057
00058 return y;
00059 }
00060
00061 aux::vector MobileRobotUnscentedKalmanFilterModel::backwardTransition(
00062 const aux::vector& x, const aux::vector& w, unsigned int delta) {
00063 aux::vector xtnm1(SYSTEM_SIZE);
00064 xtnm1(0) = x(0) - cos(x(2)) * x(3) - w(0);
00065 xtnm1(1) = x(1) - sin(x(2)) * x(3) - w(1);
00066 xtnm1(2) = x(2) - x(4);
00067 xtnm1(3) = x(3);
00068 xtnm1(4) = x(4);
00069
00070 return xtnm1;
00071 }
00072
00073 unsigned int MobileRobotUnscentedKalmanFilterModel::getStateSize() {
00074 return SYSTEM_SIZE;
00075 }
00076
00077 aux::GaussianPdf& MobileRobotUnscentedKalmanFilterModel::getSystemNoise() {
00078 return w;
00079 }
00080
00081 aux::GaussianPdf& MobileRobotUnscentedKalmanFilterModel::getMeasurementNoise() {
00082 return v;
00083 }
00084