kfilter_impl.hpp
Go to the documentation of this file.
1 // This file is part of kfilter.
2 // kfilter is a C++ variable-dimension extended kalman filter library.
3 //
4 // Copyright (C) 2004 Vincent Zalzal, Sylvain Marleau
5 // Copyright (C) 2001, 2004 Richard Gourdeau
6 // Copyright (C) 2004 GRPR and DGE's Automation sector
7 // École Polytechnique de Montréal
8 //
9 // Code adapted from algorithms presented in :
10 // Bierman, G. J. "Factorization Methods for Discrete Sequential
11 // Estimation", Academic Press, 1977.
12 //
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2.1 of the License, or (at your option) any later version.
17 //
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 
27 #ifndef KFILTER_IMPL_HPP
28 #define KFILTER_IMPL_HPP
29 
32 
33 namespace Kalman {
34 
35  template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
37 
38  template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
40 
41  template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
43 
44  template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
46 
47  // x = Ax + Bu + Ww n.1 = n.n * n.1 + n.nu * nu.1
48  makeB();
49 
50  K_UINT_32 i, j;
51  x__.resize(n);
52 
53  for (i = BEG; i < n + BEG; ++i) {
54 
55  x__(i) = T(0.0);
56 
57  for (j = BEG; j < n + BEG; ++j)
58  x__(i) += A(i,j) * x(j);
59 
60  for (j = BEG; j < nu + BEG; ++j)
61  x__(i) += B(i,j) * u(j);
62 
63  }
64 
65  x.swap(x__);
66 
67  }
68 
69  template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
71 
72  // z = Hx + Vv
73  K_UINT_32 i, j;
74 
75  z.resize(m);
76  for (i = BEG; i < m + BEG; ++i) {
77 
78  z(i) = T(0.0);
79 
80  for (j = BEG; j < n + BEG; ++j)
81  z(i) += H(i,j) * x(j);
82 
83  }
84 
85  }
86 
87  template<typename T, K_UINT_32 BEG, bool OQ, bool OVR, bool DBG>
89 
90  if (flags & ( KALMAN_N_MODIFIED | KALMAN_NU_MODIFIED ) ) {
91  B.resize(n, nu);
92  makeBaseB();
93  }
94 
96  }
97 
98 }
99 
100 #endif
#define KALMAN_NU_MODIFIED
#define KALMAN_N_MODIFIED
virtual void makeProcess()
Process function overridden to be linear.
virtual void makeBaseB()
Virtual pre-creator of B.
virtual void makeMeasure()
Measurement function overridden to be linear.
virtual void sizeUpdate()
Resizes all vector and matrices. Never call or overload this !
virtual void makeB()
Virtual creator of B.
virtual void sizeUpdate()
Matrix and vector resizing function, overridden to take B into account.
unsigned long int K_UINT_32
Unsigned 32-bits integral type.
Definition: ktypes.hpp:68
virtual ~KFilter()=0
Virtual destructor.


kfilter
Author(s): Jorge Almeida, Vincent Zalzal, Sylvain Marleau, Richard Gourdeau
autogenerated on Mon Mar 2 2015 01:31:45