00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <robot_pose_ekf/nonlinearanalyticconditionalgaussianodo.h>
00019 #include <wrappers/rng/rng.h>
00020
00021 #define NUMCONDARGUMENTS_MOBILE 2
00022
00023 namespace BFL
00024 {
00025 using namespace MatrixWrapper;
00026
00027
00028 NonLinearAnalyticConditionalGaussianOdo::NonLinearAnalyticConditionalGaussianOdo(const Gaussian& additiveNoise)
00029 : AnalyticConditionalGaussianAdditiveNoise(additiveNoise,NUMCONDARGUMENTS_MOBILE),
00030 df(6,6)
00031 {
00032
00033 for (unsigned int i=1; i<=6; i++){
00034 for (unsigned int j=1; j<=6; j++){
00035 if (i==j) df(i,j) = 1;
00036 else df(i,j) = 0;
00037 }
00038 }
00039 }
00040
00041
00042 NonLinearAnalyticConditionalGaussianOdo::~NonLinearAnalyticConditionalGaussianOdo(){}
00043
00044 ColumnVector NonLinearAnalyticConditionalGaussianOdo::ExpectedValueGet() const
00045 {
00046 ColumnVector state = ConditionalArgumentGet(0);
00047 ColumnVector vel = ConditionalArgumentGet(1);
00048 state(1) += cos(state(6)) * vel(1);
00049 state(2) += sin(state(6)) * vel(1);
00050 state(6) += vel(2);
00051 return state + AdditiveNoiseMuGet();
00052 }
00053
00054 Matrix NonLinearAnalyticConditionalGaussianOdo::dfGet(unsigned int i) const
00055 {
00056 if (i==0)
00057 {
00058 double vel_trans = ConditionalArgumentGet(1)(1);
00059 double yaw = ConditionalArgumentGet(0)(6);
00060
00061 df(1,3)=-vel_trans*sin(yaw);
00062 df(2,3)= vel_trans*cos(yaw);
00063
00064 return df;
00065 }
00066 else
00067 {
00068 if (i >= NumConditionalArgumentsGet())
00069 {
00070 cerr << "This pdf Only has " << NumConditionalArgumentsGet() << " conditional arguments\n";
00071 exit(-BFL_ERRMISUSE);
00072 }
00073 else{
00074 cerr << "The df is not implemented for the" <<i << "th conditional argument\n";
00075 exit(-BFL_ERRMISUSE);
00076 }
00077 }
00078 }
00079
00080 }
00081