OSVR-Core
PoseDampedConstantVelocity.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_PoseDampedConstantVelocity_h_GUID_FCDCA6AF_D0A2_4D92_49BE_9DBAC5C2F622
26 #define INCLUDED_PoseDampedConstantVelocity_h_GUID_FCDCA6AF_D0A2_4D92_49BE_9DBAC5C2F622
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 {
43  public:
44  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50  PoseDampedConstantVelocityProcessModel(double damping = 0.1,
51  double positionNoise = 0.01,
52  double orientationNoise = 0.1)
53  : m_constantVelModel(positionNoise, orientationNoise) {
54  setDamping(damping);
55  }
56 
57  void setNoiseAutocorrelation(double positionNoise = 0.01,
58  double orientationNoise = 0.1) {
59  m_constantVelModel.setNoiseAutocorrelation(positionNoise,
60  orientationNoise);
61  }
62 
63  void setNoiseAutocorrelation(NoiseAutocorrelation const &noise) {
64  m_constantVelModel.setNoiseAutocorrelation(noise);
65  }
67  void setDamping(double damping) {
68  if (damping > 0) {
69  m_damp = damping;
70  }
71  }
72 
75  double dt) const {
76  return pose_externalized_rotation::
77  stateTransitionMatrixWithVelocityDamping(dt, m_damp);
78  }
79 
80  void predictState(State &s, double dt) {
81  auto xHatMinus = computeEstimate(s, dt);
82  auto Pminus = predictErrorCovariance(s, *this, dt);
83  s.setStateVector(xHatMinus);
84  s.setErrorCovariance(Pminus);
85  }
86 
92  return m_constantVelModel.getSampledProcessNoiseCovariance(dt);
93  }
94 
97  StateVector computeEstimate(State &state, double dt) const {
98  StateVector ret = m_constantVelModel.computeEstimate(state, dt);
99  // Dampen velocities
100  pose_externalized_rotation::dampenVelocities(ret, m_damp, dt);
101  return ret;
102  }
103 
104  private:
105  BaseProcess m_constantVelModel;
106  double m_damp = 0.1;
107  };
108 
109 } // namespace kalman
110 } // namespace osvr
111 #endif // INCLUDED_PoseDampedConstantVelocity_h_GUID_FCDCA6AF_D0A2_4D92_49BE_9DBAC5C2F622
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
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 damping)
Set the damping - must be positive.
Definition: PoseDampedConstantVelocity.h:67
A basically-constant-velocity model, with the addition of some damping of the velocities inspired by ...
Definition: PoseDampedConstantVelocity.h:42
StateSquareMatrix getStateTransitionMatrix(State const &, double dt) const
Also known as the "process model jacobian" in TAG, this is A.
Definition: PoseDampedConstantVelocity.h:74
Header.
StateSquareMatrix getSampledProcessNoiseCovariance(double dt) const
This is Q(deltaT) - the Sampled Process Noise Covariance.
Definition: PoseConstantVelocity.h:79
StateSquareMatrix getSampledProcessNoiseCovariance(double dt) const
This is Q(deltaT) - the Sampled Process Noise Covariance.
Definition: PoseDampedConstantVelocity.h:91
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
StateVector computeEstimate(State &state, double dt) const
Returns a 12-element vector containing a predicted state based on a constant velocity process model...
Definition: PoseDampedConstantVelocity.h:97