nonlinearanalyticconditionalgaussianmobile.cpp
Go to the documentation of this file.
00001 // $Id: nonlinearanalyticconditionalgaussianmobile.h 5374 2005-05-06 14:57:05Z TDeLaet $
00002 // Copyright (C) 2006  Tinne De Laet <first dot last at mech dot kuleuven dot be>
00003 //
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as published by
00006 // the Free Software Foundation; either version 2.1 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 //
00018 
00019 
00020 #ifndef __NON_LINEAR_SYSTEM_CONDITIONAL_GAUSSIAN_MOBILE__
00021 #define __NON_LINEAR_SYSTEM_CONDITIONAL_GAUSSIAN_MOBILE__
00022 
00023 #include <pdf/analyticconditionalgaussian_additivenoise.h>
00024 
00025 namespace BFL
00026 {
00028 
00034 class NonLinearAnalyticConditionalGaussianMobile : public AnalyticConditionalGaussianAdditiveNoise
00035 {
00036 public:
00038 
00047     NonLinearAnalyticConditionalGaussianMobile( const Gaussian& additiveNoise);
00048 
00050     virtual ~NonLinearAnalyticConditionalGaussianMobile();
00051 
00052     // redefine virtual functions
00053     virtual MatrixWrapper::ColumnVector    ExpectedValueGet() const;
00054     virtual MatrixWrapper::Matrix          dfGet(unsigned int i)       const;
00055 };
00056 
00057 } // End namespace BFL
00058 
00059 #endif //// $Id: nonlinearanalyticconditionalgaussianmobile.cpp 5823 2005-10-27 13:43:02Z TDeLaet $
00060 // Copyright (C) 2006  Tinne De Laet <first dot last at mech dot kuleuven dot be>
00061 //
00062 // This program is free software; you can redistribute it and/or modify
00063 // it under the terms of the GNU Lesser General Public License as published by
00064 // the Free Software Foundation; either version 2.1 of the License, or
00065 // (at your option) any later version.
00066 //
00067 // This program is distributed in the hope that it will be useful,
00068 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00069 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00070 // GNU Lesser General Public License for more details.
00071 //
00072 // You should have received a copy of the GNU Lesser General Public License
00073 // along with this program; if not, write to the Free Software
00074 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00075 //
00076 
00077 #include "bayesian_filtering/nonlinearanalyticconditionalgaussianmobile.h"
00078 #include <wrappers/rng/rng.h> // Wrapper around several rng
00079 // libraries
00080 #define NUMCONDARGUMENTS_MOBILE 2
00081 
00082 namespace BFL
00083 {
00084 using namespace MatrixWrapper;
00085 
00086 
00087 NonLinearAnalyticConditionalGaussianMobile::NonLinearAnalyticConditionalGaussianMobile(const Gaussian& additiveNoise)
00088     : AnalyticConditionalGaussianAdditiveNoise(additiveNoise,NUMCONDARGUMENTS_MOBILE)
00089 {}
00090 
00091 
00092 NonLinearAnalyticConditionalGaussianMobile::~NonLinearAnalyticConditionalGaussianMobile(){}
00093 void angleOverflowCorrect(double& a)
00094 {
00095     while ((a) >  M_PI) a -= 2*M_PI;
00096     while ((a) < -M_PI) a += 2*M_PI;
00097 }
00098 ColumnVector NonLinearAnalyticConditionalGaussianMobile::ExpectedValueGet() const
00099 {
00100     // Input rot_1, trans, rot_2
00101     ColumnVector state = ConditionalArgumentGet(0);
00102     ColumnVector delta_odom  = ConditionalArgumentGet(1)+AdditiveNoiseMuGet();
00103     state(1) += cos(state(3)+delta_odom(1))*delta_odom(2);
00104     state(2) += sin(state(3)+delta_odom(1))*delta_odom(2);
00105     state(3) += delta_odom(1)+delta_odom(3);
00106     angleOverflowCorrect(state(3));
00107     return state;
00108 }
00109 
00110 Matrix NonLinearAnalyticConditionalGaussianMobile::dfGet(unsigned int i) const
00111 {
00112     if (i==0)//derivative to the second conditional argument (u)
00113     {
00114         ColumnVector state = ConditionalArgumentGet(0);
00115         ColumnVector delta_odom = ConditionalArgumentGet(1);
00116         //std::cout << "state:"<< state << std::endl;
00117 
00118         Matrix df(3,3);
00119 //        df(1,1)=-sin(state(3)+delta_odom(1))*delta_odom(2);
00120 //        df(1,2)=cos(state(3)+delta_odom(1));
00121 //        df(2,2)=0;
00122 
00123 //        df(2,1)=cos(state(3)+delta_odom(1))*delta_odom(2);
00124 //        df(2,2)=sin(state(3)+delta_odom(1));
00125 //        df(2,3)=0;
00126 
00127 //        df(3,1)=1;
00128 //        df(3,2)=0;
00129 //        df(3,3)=1;
00130 
00131 
00132         df(1,1)=1;
00133         df(1,2)=0;
00134         df(1,3)=-sin(state(3)+delta_odom(1))*delta_odom(2);
00135         df(2,1)=0;
00136         df(2,2)=1;
00137         df(2,3)=cos(state(3)+delta_odom(1))*delta_odom(2);
00138         df(3,1)=0;
00139         df(3,2)=0;
00140         df(3,3)=1;
00141 
00142         return df;
00143     }
00144     else
00145     {
00146         if (i >= NumConditionalArgumentsGet())
00147         {
00148             cerr << "This pdf Only has " << NumConditionalArgumentsGet() << " conditional arguments\n";
00149             exit(-BFL_ERRMISUSE);
00150         }
00151         else{
00152             cerr << "The df is not implemented for the" <<i << "th conditional argument\n";
00153             exit(-BFL_ERRMISUSE);
00154         }
00155     }
00156 }
00157 
00158 }//namespace BFL
00159 


ekf_localization
Author(s):
autogenerated on Sat Jun 8 2019 20:11:55