OSVR-Core
ConstantProcess.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_ConstantProcess_h_GUID_1F5DA279_772D_42B2_9D5A_FC7890DD4C16
26 #define INCLUDED_ConstantProcess_h_GUID_1F5DA279_772D_42B2_9D5A_FC7890DD4C16
27 
28 // Internal Includes
29 #include "FlexibleKalmanBase.h"
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 // - none
36 
37 namespace osvr {
38 namespace kalman {
45  template <typename StateType> class ConstantProcess {
46  public:
47  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48  using State = StateType;
51  ConstantProcess() : m_constantNoise(StateSquareMatrix::Zero()) {}
52  void predictState(State &state, double dt) {
53 
54  // Predict a-priori P
55  // The formula for this prediction is AP(A^T) + Q, where Q is
56  // getSampledProcessNoiseCovariance, and A is
57  // getStateTransitionMatrix, both optional process model methods.
58  // Since the state transition matrix for this, a constant process,
59  // is just the identity, this simplifies to a sum, so we just
60  // directly do the computation here rather than calling the
61  // predictErrorCovariance() free function.
62  StateSquareMatrix Pminus =
63  state.errorCovariance() + dt * m_constantNoise;
64  state.setErrorCovariance(Pminus);
65  }
66  void setNoiseAutocorrelation(double noise) {
67  m_constantNoise = StateVector::Constant(noise).asDiagonal();
68  }
69 
70  void setNoiseAutocorrelation(StateVector const &noise) {
71  m_constantNoise = noise.asDiagonal;
72  }
73 
74  private:
75  StateSquareMatrix m_constantNoise;
76  };
77 
78 } // namespace kalman
79 } // namespace osvr
80 #endif // INCLUDED_ConstantProcess_h_GUID_1F5DA279_772D_42B2_9D5A_FC7890DD4C16
typename FilterType::State StateType
Given a filter type, get the state type.
Definition: FlexibleKalmanBase.h:91
A simple process model for a "constant" process: all prediction does at most is bump up the uncertain...
Definition: ConstantProcess.h:45
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127