OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 {
43  class AngularVelocityBase {
44  public:
45  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46  static const types::DimensionType DIMENSION = 3;
47  using MeasurementVector = types::Vector<DIMENSION>;
48  using MeasurementDiagonalMatrix = types::DiagonalMatrix<DIMENSION>;
49  AngularVelocityBase(MeasurementVector const &vel,
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>
64  MeasurementVector getResidual(State const &s) const {
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:
89  using State = pose_externalized_rotation::State;
90  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
91  static const types::DimensionType STATE_DIMENSION =
93  using Base = AngularVelocityBase;
94 
95  AngularVelocityMeasurement(MeasurementVector const &vel,
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:
115  using State = orient_externalized_rotation::State;
116  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
117  static const types::DimensionType STATE_DIMENSION =
119  using Base = AngularVelocityBase;
120 
121  AngularVelocityMeasurement(MeasurementVector const &vel,
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
Eigen::Matrix< Scalar, n, n > SquareMatrix
A square matrix, n x n.
The main namespace for all C++ elements of the framework, internal and external.
Definition: ClientKit.h:31
Header wrapping include of and for warning quieting.
Header.
std::size_t DimensionType
Type for dimensions.
Eigen::Matrix< Scalar, m, n > Matrix
A matrix with rows = m, cols = n.