OSVR-Core
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
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>
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:
91  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
92  static const types::DimensionType STATE_DIMENSION =
94  using Base = AbsolutePositionBase;
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
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.
The measurement here has been split into a base and derived type, so that the derived type only conta...
Definition: AbsolutePositionMeasurement.h:45
void setMeasurement(MeasurementVector const &pos)
Convenience method to be able to store and re-use measurements.
Definition: AbsolutePositionMeasurement.h:73
Header.
MeasurementVector getResidual(State const &s) const
Gets the measurement residual, also known as innovation: predicts the measurement from the predicted ...
Definition: AbsolutePositionMeasurement.h:67
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
This is the subclass of AbsolutePositionBase: only explicit specializations, and on state types...
Definition: AbsolutePositionMeasurement.h:83