extendedkalmanfilter.cpp
Go to the documentation of this file.
1 // $Id$
2 // Copyright (C) 2003 Klaas Gadeyne <first dot last at gmail dot com>
3 // Wim Meeussen <wim dot meeussen at mech dot kuleuven dot be>
4 // Tinne De Laet <tinne dot delaet at mech dot kuleuven dot be>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 //
20 #include "extendedkalmanfilter.h"
21 
22 namespace BFL
23 {
24  using namespace MatrixWrapper;
25 
26 
27 
28 #define AnalyticSys AnalyticSystemModelGaussianUncertainty
29 #define AnalyticMeas AnalyticMeasurementModelGaussianUncertainty
30 
31 
33 : KalmanFilter(prior)
34 , _x(prior->DimensionGet())
35 , _J(prior->DimensionGet())
36 , _F(prior->DimensionGet(),prior->DimensionGet())
37 , _Q(prior->DimensionGet())
38 {}
39 
41 {}
42 
43 void
44 ExtendedKalmanFilter::AllocateMeasModelExt(const vector<unsigned int>& meas_dimensions)
45 {
46  unsigned int meas_dimension;
47  for(int i = 0 ; i< meas_dimensions.size(); i++)
48  {
49  // find if variables with size meas_sizes[i] are already allocated
50  meas_dimension = meas_dimensions[i];
53  {
54  //variables with size z.rows() not allocated yet
56  (std::pair<unsigned int, MeasUpdateVariablesExt>( meas_dimension,MeasUpdateVariablesExt(meas_dimension,_x.rows()) ))).first;
57  }
58  }
59 }
60 
61 void
62 ExtendedKalmanFilter::AllocateMeasModelExt(const unsigned int& meas_dimension)
63 {
64  // find if variables with size meas_sizes[i] are already allocated
67  {
68  //variables with size z.rows() not allocated yet
70  (std::pair<unsigned int, MeasUpdateVariablesExt>( meas_dimension,MeasUpdateVariablesExt(meas_dimension,_x.rows()) ))).first;
71  }
72 }
73 
74 void
76  const ColumnVector& u)
77 {
79  _J = ((AnalyticSys*)sysmodel)->PredictionGet(u,_x);
80  _F = ((AnalyticSys*)sysmodel)->df_dxGet(u,_x);
81  _Q = ((AnalyticSys*)sysmodel)->CovarianceGet(u,_x);
82 
84 }
85 
86 void
88  const ColumnVector& z,
89  const ColumnVector& s)
90 {
91  // allocate measurement for z.rows() if needed
92  AllocateMeasModelExt(z.rows());
93 
95  (_mapMeasUpdateVariablesExt_it->second)._Z = ((AnalyticMeas*)measmodel)->PredictionGet(s,_x);
96  (_mapMeasUpdateVariablesExt_it->second)._H = ((AnalyticMeas*)measmodel)->df_dxGet(s,_x);
97  (_mapMeasUpdateVariablesExt_it->second)._R = ((AnalyticMeas*)measmodel)->CovarianceGet(s,_x);
98 
100 }
101 
102 } // end namespace BFL
void AllocateMeasModelExt(const vector< unsigned int > &meas_dimensions)
Function to allocate memory needed during the measurement update,.
virtual void SysUpdate(SystemModel< MatrixWrapper::ColumnVector > *const sysmodel, const MatrixWrapper::ColumnVector &u)
System Update.
Class representing Gaussian (or normal density)
Definition: gaussian.h:27
std::map< unsigned int, MeasUpdateVariablesExt >::iterator _mapMeasUpdateVariablesExt_it
#define AnalyticMeas
Pdf< MatrixWrapper::ColumnVector > * _post
Pointer to the Posterior Pdf.
Definition: filter.h:95
virtual void MeasUpdate(MeasurementModel< MatrixWrapper::ColumnVector, MatrixWrapper::ColumnVector > *const measmodel, const MatrixWrapper::ColumnVector &z, const MatrixWrapper::ColumnVector &s)
Measurement Update (overloaded)
#define AnalyticSys
virtual ~ExtendedKalmanFilter()
Destructor.
Class representing the family of all Kalman Filters (EKF, IEKF, ...)
Definition: kalmanfilter.h:49
void CalculateSysUpdate(const MatrixWrapper::ColumnVector &J, const MatrixWrapper::Matrix &F, const MatrixWrapper::SymmetricMatrix &Q)
std::map< unsigned int, MeasUpdateVariablesExt > _mapMeasUpdateVariablesExt
void CalculateMeasUpdate(const MatrixWrapper::ColumnVector &z, const MatrixWrapper::ColumnVector &Z, const MatrixWrapper::Matrix &H, const MatrixWrapper::SymmetricMatrix &R)
virtual T ExpectedValueGet() const
Get the expected value E[x] of the pdf.


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 Jun 10 2019 12:47:59