OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
45  using State = pose_externalized_rotation::State;
46  using StateVector = pose_externalized_rotation::StateVector;
47  using StateSquareMatrix = pose_externalized_rotation::StateSquareMatrix;
49  using NoiseAutocorrelation = BaseProcess::NoiseAutocorrelation;
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 
74  StateSquareMatrix getStateTransitionMatrix(State const &,
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 
91  StateSquareMatrix getSampledProcessNoiseCovariance(double dt) const {
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
StateSquareMatrix getSampledProcessNoiseCovariance(double dt) const
types::DimSquareMatrix< StateType > predictErrorCovariance(StateType const &state, ProcessModelType &processModel, double dt)
A constant-velocity model for a 6DOF pose (with velocities)
The main namespace for all C++ elements of the framework, internal and external.
Definition: ClientKit.h:31
StateSquareMatrix getStateTransitionMatrix(State const &, double dt) const
Also known as the "process model jacobian" in TAG, this is A.
void setDamping(double damping)
Set the damping - must be positive.
StateVector computeEstimate(State &state, double dt) const
Header.
StateVector computeEstimate(State &state, double dt) const
StateSquareMatrix getSampledProcessNoiseCovariance(double dt) const