nonlinearanalyticconditionalgaussian3D.cpp
Go to the documentation of this file.
00001 // $Id: NonLinearAnalyticConditionalGaussian3D.cpp 5823 2005-10-27 13:43:02Z 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 #include "bayesian_filtering/nonlinearanalyticconditionalgaussian3D.h"
00020 #include <wrappers/rng/rng.h> // Wrapper around several rng
00021 // libraries
00022 #define NUMCONDARGUMENTS_MOBILE 2
00023 
00024 namespace BFL
00025 {
00026 using namespace MatrixWrapper;
00027 
00028 
00029 NonLinearAnalyticConditionalGaussian3D::NonLinearAnalyticConditionalGaussian3D(const Gaussian& additiveNoise)
00030     : AnalyticConditionalGaussianAdditiveNoise(additiveNoise,NUMCONDARGUMENTS_MOBILE)
00031 {}
00032 
00033 NonLinearAnalyticConditionalGaussian3D::~NonLinearAnalyticConditionalGaussian3D(){}
00034 
00035 ColumnVector NonLinearAnalyticConditionalGaussian3D::ExpectedValueGet() const
00036 {
00037     ColumnVector state = ConditionalArgumentGet(0);
00038     ColumnVector input  = ConditionalArgumentGet(1); // Transformation
00039 
00040     // Construct homogeneous transformation matrix
00041     Matrix T_homogeneous(4,4);
00042     T_homogeneous=0;
00043 
00044     // Rotation
00045     T_homogeneous(1,1)=1.0;
00046     T_homogeneous(2,2)=1.0;
00047     T_homogeneous(3,3)=1.0;
00048 
00049     // Translation
00050     T_homogeneous(1,4)=input(1); // delta_x
00051     T_homogeneous(2,4)=input(2); // delta_y
00052     T_homogeneous(3,4)=input(3); // delta_z
00053     T_homogeneous(4,4)=1.0;
00054 
00055     // Construct homogeneous state vector
00056     ColumnVector state_homogeneous(4);
00057     state_homogeneous=0;
00058     state_homogeneous(1)=state(1);     state_homogeneous(2)=state(2);    state_homogeneous(3)=state(3);    state_homogeneous(4)=1.0;
00059 
00060     // Apply transformation
00061     state_homogeneous=T_homogeneous * state_homogeneous;
00062 
00063     // Convert back to state coordinates
00064     state(1)=state_homogeneous(1);   state(2)=state_homogeneous(2);  state(3)=state_homogeneous(3);
00065     return state + AdditiveNoiseMuGet();
00066 }
00067 
00068 Matrix NonLinearAnalyticConditionalGaussian3D::dfGet(unsigned int i) const
00069 {
00070     if (i==0)//derivative to the first conditional argument (x)
00071     {
00072         ColumnVector state = ConditionalArgumentGet(0);
00073         ColumnVector vel = ConditionalArgumentGet(1);
00074         Matrix df(3,3);
00075         df(1,1)=1;
00076         df(1,2)=0;
00077         df(1,3)=-vel(1)*sin(state(3));
00078         df(2,1)=0;
00079         df(2,2)=1;
00080         df(2,3)=vel(1)*cos(state(3));
00081         df(3,1)=0;
00082         df(3,2)=0;
00083         df(3,3)=1;
00084 
00085 
00086         return df;
00087     }
00088     else
00089     {
00090         if (i >= NumConditionalArgumentsGet())
00091         {
00092             cerr << "This pdf Only has " << NumConditionalArgumentsGet() << " conditional arguments\n";
00093             exit(-BFL_ERRMISUSE);
00094         }
00095         else
00096         {
00097             cerr << "The df is not implemented for the" <<i << "th conditional argument\n";
00098             exit(-BFL_ERRMISUSE);
00099         }
00100     }
00101 }
00102 
00103 }//namespace BFL
00104 
00105 


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