OSVR-Core
AngularVelocityMeasurement.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_AngularVelocityMeasurement_h_GUID_73F00F72_643C_45BC_C0BC_291214F14CF3
26 #define INCLUDED_AngularVelocityMeasurement_h_GUID_73F00F72_643C_45BC_C0BC_291214F14CF3
27 
28 // Internal Includes
29 #include "FlexibleKalmanBase.h"
30 #include "PoseState.h"
31 #include "OrientationState.h"
32 #include "ExternalQuaternion.h"
34 
35 // Library/third-party includes
36 // - none
37 
38 // Standard includes
39 // - none
40 
41 namespace osvr {
42 namespace kalman {
44  public:
45  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46  static const types::DimensionType DIMENSION = 3;
50  MeasurementVector const &variance)
51  : m_measurement(vel), m_covariance(variance.asDiagonal()) {}
52 
53  template <typename State>
54  MeasurementDiagonalMatrix const &getCovariance(State const &) {
55  return m_covariance;
56  }
57 
63  template <typename State>
65  const MeasurementVector residual =
66  m_measurement - s.angularVelocity();
67  return residual;
68  }
69 
71  void setMeasurement(MeasurementVector const &vel) {
72  m_measurement = vel;
73  }
74 
75  private:
76  MeasurementVector m_measurement;
77  MeasurementDiagonalMatrix m_covariance;
78  };
79 
82  template <typename StateType> class AngularVelocityMeasurement;
83 
85  template <>
86  class AngularVelocityMeasurement<pose_externalized_rotation::State>
87  : public AngularVelocityBase {
88  public:
90  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
91  static const types::DimensionType STATE_DIMENSION =
93  using Base = AngularVelocityBase;
94 
96  MeasurementVector const &variance)
97  : Base(vel, variance) {}
98 
100  getJacobian(State const &) const {
102  Jacobian ret = Jacobian::Zero();
103  ret.topRightCorner<3, 3>() = types::SquareMatrix<3>::Identity();
104  return ret;
105  }
106  };
107 
111  template <>
112  class AngularVelocityMeasurement<orient_externalized_rotation::State>
113  : public AngularVelocityBase {
114  public:
116  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
117  static const types::DimensionType STATE_DIMENSION =
119  using Base = AngularVelocityBase;
120 
122  MeasurementVector const &variance)
123  : Base(vel, variance) {}
124 
126  getJacobian(State const &) const {
128  Jacobian ret = Jacobian::Zero();
129  ret.topRightCorner<3, 3>() = types::SquareMatrix<3>::Identity();
130  return ret;
131  }
132  };
133 } // namespace kalman
134 } // namespace osvr
135 #endif // INCLUDED_AngularVelocityMeasurement_h_GUID_73F00F72_643C_45BC_C0BC_291214F14CF3
typename detail::Dimension_impl< T >::type Dimension
Given a state or measurement, get the dimension as a std::integral_constant.
Definition: FlexibleKalmanBase.h:87
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:135
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
MeasurementVector getResidual(State const &s) const
Gets the measurement residual, also known as innovation: predicts the measurement from the predicted ...
Definition: AngularVelocityMeasurement.h:64
Definition: AngularVelocityMeasurement.h:43
Header.
void setMeasurement(MeasurementVector const &vel)
Convenience method to be able to store and re-use measurements.
Definition: AngularVelocityMeasurement.h:71
std::size_t DimensionType
Type for dimensions.
Definition: FlexibleKalmanBase.h:51
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Definition: OrientationState.h:108
This is the subclass of AngularVelocityBase: only explicit specializations, and on state types...
Definition: AngularVelocityMeasurement.h:82