kfilter_impl.hpp

Go to the documentation of this file.
00001 // This file is part of kfilter.
00002 // kfilter is a C++ variable-dimension extended kalman filter library.
00003 //
00004 // Copyright (C) 2004        Vincent Zalzal, Sylvain Marleau
00005 // Copyright (C) 2001, 2004  Richard Gourdeau
00006 // Copyright (C) 2004        GRPR and DGE's Automation sector
00007 //                           École Polytechnique de Montréal
00008 //
00009 // Code adapted from algorithms presented in :
00010 //      Bierman, G. J. "Factorization Methods for Discrete Sequential
00011 //      Estimation", Academic Press, 1977.
00012 //
00013 // This library is free software; you can redistribute it and/or
00014 // modify it under the terms of the GNU Lesser General Public
00015 // License as published by the Free Software Foundation; either
00016 // version 2.1 of the License, or (at your option) any later version.
00017 //
00018 // This library is distributed in the hope that it will be useful,
00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 // Lesser General Public License for more details.
00022 //
00023 // You should have received a copy of the GNU Lesser General Public
00024 // License along with this library; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027 #ifndef KFILTER_IMPL_HPP
00028 #define KFILTER_IMPL_HPP
00029 
00032 
00033 namespace Kalman {
00034 
00035   template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
00036   KFilter<T, BEG, OQ, OVR, DBG>::~KFilter() {}
00037 
00038   template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
00039   void KFilter<T, BEG, OQ, OVR, DBG>::makeBaseB() {}
00040 
00041   template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
00042   void KFilter<T, BEG, OQ, OVR, DBG>::makeB() {}
00043 
00044   template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
00045   void KFilter<T, BEG, OQ, OVR, DBG>::makeProcess() {
00046 
00047     // x = Ax + Bu + Ww    n.1 = n.n * n.1 + n.nu * nu.1
00048     makeB();
00049 
00050     K_UINT_32 i, j;
00051     x__.resize(n);
00052 
00053     for (i = BEG; i < n + BEG; ++i) {
00054 
00055       x__(i) = T(0.0);
00056 
00057       for (j = BEG; j < n + BEG; ++j)
00058         x__(i) += A(i,j) * x(j);
00059 
00060       for (j = BEG; j < nu + BEG; ++j)
00061         x__(i) += B(i,j) * u(j);
00062 
00063     }
00064 
00065     x.swap(x__);
00066 
00067   }
00068 
00069   template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
00070   void KFilter<T, BEG, OQ, OVR, DBG>::makeMeasure() {
00071     
00072     // z = Hx + Vv
00073     K_UINT_32 i, j;
00074 
00075     z.resize(m);
00076     for (i = BEG; i < m + BEG; ++i) {
00077 
00078       z(i) = T(0.0);
00079 
00080       for (j = BEG; j < n + BEG; ++j)
00081         z(i) += H(i,j) * x(j);
00082 
00083     }
00084 
00085   }
00086 
00087   template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
00088   void KFilter<T, BEG, OQ, OVR, DBG>::sizeUpdate() {
00089 
00090     if (flags & ( KALMAN_N_MODIFIED | KALMAN_NU_MODIFIED ) ) {
00091       B.resize(n, nu);
00092       makeBaseB();
00093     }   
00094     
00095     EKFilter<T, BEG, OQ, OVR, DBG>::sizeUpdate();
00096   }
00097 
00098 }
00099 
00100 #endif

Generated on Sat Jan 28 21:02:01 2006 for KFilter by  doxygen 1.4.5