indii/ml/filter/UnscentedKalmanFilterMeasurementAdaptor.hpp

00001 #ifndef INDII_ML_FILTER_UNSCENTEDKALMANFILTERMEASUREMENTADAPTOR_HPP
00002 #define INDII_ML_FILTER_UNSCENTEDKALMANFILTERMEASUREMENTADAPTOR_HPP
00003 
00004 #include "UnscentedTransformationModel.hpp"
00005 
00006 namespace indii {
00007   namespace ml {
00008     namespace filter {
00009 
00010   template <class T> class UnscentedTransformation;
00011   template <class T> class UnscentedKalmanFilter;
00012   template <class T> class UnscentedKalmanSmoother;
00013   template <class T> class UnscentedKalmanFilterModel;
00014 
00015 /**
00016  * Adaptor mapping UnscentedTransformationModel interface to method calls in
00017  * UnscentedKalmanFilterModel.
00018  * 
00019  * @author Lawrence Murray <lawrence@indii.org>
00020  * @version $Rev: 544 $
00021  * @date $Date: 2008-09-01 15:04:39 +0100 (Mon, 01 Sep 2008) $
00022  *
00023  * @param T The type of time.
00024  *
00025  * For internal use only.
00026  */
00027 template <class T>
00028 class UnscentedKalmanFilterMeasurementAdaptor :
00029     public UnscentedTransformationModel<T> {
00030 
00031   friend class UnscentedTransformation<T>;
00032   friend class UnscentedKalmanFilter<T>;
00033   friend class UnscentedKalmanSmoother<T>;
00034 
00035 private:
00036   /**
00037    * Constructor.
00038    * 
00039    * @param model NonLinearModel to which to map calls.
00040    */
00041   UnscentedKalmanFilterMeasurementAdaptor(
00042       UnscentedKalmanFilterModel<T>* model);
00043 
00044   /**
00045    * Maps call to UnscentedKalmanFilterModel::measure.
00046    */
00047   virtual indii::ml::aux::vector propagate(const indii::ml::aux::vector& X,
00048       const T delta = 0);
00049 
00050   /**
00051    * Model to which to map calls.
00052    */
00053   UnscentedKalmanFilterModel<T>* model;
00054 
00055 };
00056 
00057     }
00058   }
00059 }
00060 
00061 #include "UnscentedKalmanFilterModel.hpp"
00062 
00063 template <class T>
00064 indii::ml::filter::UnscentedKalmanFilterMeasurementAdaptor<T>::UnscentedKalmanFilterMeasurementAdaptor(
00065     UnscentedKalmanFilterModel<T>* model) : model(model) {
00066   //
00067 }
00068 
00069 template <class T>
00070 indii::ml::aux::vector
00071     indii::ml::filter::UnscentedKalmanFilterMeasurementAdaptor<T>::propagate(
00072     const indii::ml::aux::vector& X, const T delta) {
00073   namespace aux = indii::ml::aux;
00074   namespace ublas = boost::numeric::ublas;
00075     
00076   const unsigned int N = model->getStateSize();
00077   const unsigned int W = model->getSystemNoise().getDimensions();
00078   const unsigned int V = model->getMeasurementNoise().getDimensions();
00079 
00080   aux::vector x(project(X, ublas::range(0,N)));
00081   aux::vector v(project(X, ublas::range(N+W, N+W+V)));
00082 
00083   return model->measure(x, v);
00084 }
00085 
00086 #endif

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3