OSVR-Core
PoseSeparatelyDampedConstantVelocity.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_PoseSeparatelyDampedConstantVelocity_h_GUID_4BB00A8D_B12F_47BF_EA91_599233CED644
26 #define INCLUDED_PoseSeparatelyDampedConstantVelocity_h_GUID_4BB00A8D_B12F_47BF_EA91_599233CED644
27 
28 // Internal Includes
29 #include "PoseState.h"
30 #include "PoseConstantVelocity.h"
31 
32 // Library/third-party includes
33 // - none
34 
35 // Standard includes
36 #include <cassert>
37 
38 namespace osvr {
39 namespace kalman {
44  public:
45  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
52  double positionDamping = 0.3, double orientationDamping = 0.01,
53  double positionNoise = 0.01, double orientationNoise = 0.1)
54  : m_constantVelModel(positionNoise, orientationNoise) {
55  setDamping(positionDamping, orientationDamping);
56  }
57 
58  void setNoiseAutocorrelation(double positionNoise = 0.01,
59  double orientationNoise = 0.1) {
60  m_constantVelModel.setNoiseAutocorrelation(positionNoise,
61  orientationNoise);
62  }
63 
64  void setNoiseAutocorrelation(NoiseAutocorrelation const &noise) {
65  m_constantVelModel.setNoiseAutocorrelation(noise);
66  }
68  void setDamping(double posDamping, double oriDamping) {
69  if (posDamping > 0 && posDamping < 1) {
70  m_posDamp = posDamping;
71  }
72  if (oriDamping > 0 && oriDamping < 1) {
73  m_oriDamp = oriDamping;
74  }
75  }
76 
79  double dt) const {
80  return pose_externalized_rotation::
81  stateTransitionMatrixWithSeparateVelocityDamping(dt, m_posDamp,
82  m_oriDamp);
83  }
84 
85  void predictState(State &s, double dt) {
86  auto xHatMinus = computeEstimate(s, dt);
87  auto Pminus = predictErrorCovariance(s, *this, dt);
88  s.setStateVector(xHatMinus);
89  s.setErrorCovariance(Pminus);
90  }
91 
97  return m_constantVelModel.getSampledProcessNoiseCovariance(dt);
98  }
99 
102  StateVector computeEstimate(State &state, double dt) const {
103  StateVector ret = m_constantVelModel.computeEstimate(state, dt);
104  // Dampen velocities
105  pose_externalized_rotation::separatelyDampenVelocities(
106  ret, m_posDamp, m_oriDamp, dt);
107  return ret;
108  }
109 
110  private:
111  BaseProcess m_constantVelModel;
112  double m_posDamp = 0.2;
113  double m_oriDamp = 0.01;
114  };
115 
116 } // namespace kalman
117 } // namespace osvr
118 
119 #endif // INCLUDED_PoseSeparatelyDampedConstantVelocity_h_GUID_4BB00A8D_B12F_47BF_EA91_599233CED644
types::DimSquareMatrix< StateType > predictErrorCovariance(StateType const &state, ProcessModelType &processModel, double dt)
Computes P-.
Definition: FlexibleKalmanBase.h:135
StateVector computeEstimate(State &state, double dt) const
Returns a 12-element vector containing a predicted state based on a constant velocity process model...
Definition: PoseConstantVelocity.h:99
StateVector computeEstimate(State &state, double dt) const
Returns a 12-element vector containing a predicted state based on a constant velocity process model...
Definition: PoseSeparatelyDampedConstantVelocity.h:102
A constant-velocity model for a 6DOF pose (with velocities)
Definition: PoseConstantVelocity.h:40
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void setDamping(double posDamping, double oriDamping)
Set the damping - must be in (0, 1)
Definition: PoseSeparatelyDampedConstantVelocity.h:68
StateSquareMatrix getSampledProcessNoiseCovariance(double dt) const
This is Q(deltaT) - the Sampled Process Noise Covariance.
Definition: PoseSeparatelyDampedConstantVelocity.h:96
StateSquareMatrix getStateTransitionMatrix(State const &, double dt) const
Also known as the "process model jacobian" in TAG, this is A.
Definition: PoseSeparatelyDampedConstantVelocity.h:78
Header.
StateSquareMatrix getSampledProcessNoiseCovariance(double dt) const
This is Q(deltaT) - the Sampled Process Noise Covariance.
Definition: PoseConstantVelocity.h:79
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
void setStateVector(StateVector const &state)
set xhat
Definition: PoseState.h:175
A basically-constant-velocity model, with the addition of some damping of the velocities inspired by ...
Definition: PoseSeparatelyDampedConstantVelocity.h:43