OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
AbsolutePositionMeasurement.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_AbsolutePositionMeasurement_h_GUID_F2854FEA_1E84_479E_1B5D_A302104DBF47
26 #define INCLUDED_AbsolutePositionMeasurement_h_GUID_F2854FEA_1E84_479E_1B5D_A302104DBF47
27 
28 // Internal Includes
29 #include "FlexibleKalmanBase.h"
30 #include "PoseState.h"
32 
33 // Library/third-party includes
34 // - none
35 
36 // Standard includes
37 // - none
38 
39 namespace osvr {
40 namespace kalman {
41 
46  public:
47  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48  static const types::DimensionType DIMENSION = 3; // 3 position
49  using MeasurementVector = types::Vector<DIMENSION>;
50  using MeasurementDiagonalMatrix = types::DiagonalMatrix<DIMENSION>;
51  using MeasurementMatrix = types::SquareMatrix<DIMENSION>;
52  AbsolutePositionBase(MeasurementVector const &pos,
53  MeasurementVector const &variance)
54  : m_pos(pos), m_covariance(variance.asDiagonal()) {}
55 
56  template <typename State>
57  MeasurementMatrix getCovariance(State const &) const {
58  return m_covariance;
59  }
60 
66  template <typename State>
67  MeasurementVector getResidual(State const &s) const {
68  MeasurementVector residual = m_pos - s.position();
69  return residual;
70  }
71 
73  void setMeasurement(MeasurementVector const &pos) { m_pos = pos; }
74 
75  private:
76  MeasurementVector m_pos;
77  MeasurementDiagonalMatrix m_covariance;
78  };
79 
83  template <typename StateType> class AbsolutePositionMeasurement;
84 
86  template <>
87  class AbsolutePositionMeasurement<pose_externalized_rotation::State>
88  : public AbsolutePositionBase {
89  public:
90  using State = pose_externalized_rotation::State;
91  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
92  static const types::DimensionType STATE_DIMENSION =
94  using Base = AbsolutePositionBase;
96  AbsolutePositionMeasurement(MeasurementVector const &pos,
97  MeasurementVector const &variance)
98  : Base(pos, variance), m_jacobian(Jacobian::Zero()) {
99  m_jacobian.block<3, 3>(0, 0) = types::SquareMatrix<3>::Identity();
100  }
101 
103  getJacobian(State const &) const {
104  return m_jacobian;
105  }
106 
107  private:
109  };
110 } // namespace kalman
111 } // namespace osvr
112 #endif // INCLUDED_AbsolutePositionMeasurement_h_GUID_F2854FEA_1E84_479E_1B5D_A302104DBF47
Eigen::Matrix< Scalar, n, 1 > Vector
A vector of length n.
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.
void setMeasurement(MeasurementVector const &pos)
Convenience method to be able to store and re-use measurements.
Header.
Eigen::DiagonalMatrix< Scalar, n > DiagonalMatrix
A square diagonal matrix, n x n.
std::size_t DimensionType
Type for dimensions.
MeasurementVector getResidual(State const &s) const
Eigen::Matrix< Scalar, m, n > Matrix
A matrix with rows = m, cols = n.