13#error "This header is C++-only."
17#include <Eigen/Geometry>
19#include "flexkalman/AugmentedProcessModel.h"
20#include "flexkalman/AugmentedState.h"
21#include "flexkalman/BaseTypes.h"
22#include "flexkalman/PoseState.h"
25namespace xrt::auxiliary::tracking {
27namespace types = flexkalman::types;
28using flexkalman::types::Vector;
32template <
typename State>
36 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
37 static constexpr size_t Dimension = 3;
38 using MeasurementVector = types::Vector<Dimension>;
39 using MeasurementSquareMatrix = types::SquareMatrix<Dimension>;
41 types::Vector<3>
const &reference,
42 types::Vector<3>
const &variance)
43 : direction_(direction.normalized()), reference_(reference.normalized()), covariance_(variance.asDiagonal())
46 MeasurementSquareMatrix
const &
47 getCovariance(State
const & )
53 predictMeasurement(State
const &s)
const
55 return s.getCombinedQuaternion() * reference_;
59 getResidual(MeasurementVector
const &predictedMeasurement, State
const &s)
const
61 return predictedMeasurement - reference_;
65 getResidual(State
const &s)
const
67 return getResidual(predictMeasurement(s), s);
71 types::Vector<3> direction_;
72 types::Vector<3> reference_;
73 MeasurementSquareMatrix covariance_;
78class LinAccelWithGravityMeasurement
79 :
public flexkalman::MeasurementBase<LinAccelWithGravityMeasurement>
82 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
83 static constexpr size_t Dimension = 3;
84 using MeasurementVector = types::Vector<Dimension>;
85 using MeasurementSquareMatrix = types::SquareMatrix<Dimension>;
86 LinAccelWithGravityMeasurement(types::Vector<3>
const &direction,
87 types::Vector<3>
const &reference,
88 types::Vector<3>
const &variance)
89 : direction_(direction), reference_(reference),
90 covariance_(variance.asDiagonal())
94 MeasurementSquareMatrix
const &
95 getCovariance(State
const & )
102 predictMeasurement(State
const &s)
const
109 getResidual(MeasurementVector
const &predictedMeasurement,
110 State
const &s)
const
112 s.getQuaternion().conjugate() *
113 predictedMeasurement
return predictedMeasurement -
114 reference_.normalized();
117 template <
typename State>
119 getResidual(State
const &s)
const
121 MeasurementVector residual =
122 direction_ - reference_ * s.getQuaternion();
123 return getResidual(predictMeasurement(s), s);
127 types::Vector<3> direction_;
128 types::Vector<3> reference_;
129 MeasurementSquareMatrix covariance_;
136 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
137 static constexpr size_t Dimension = 3;
138 using MeasurementVector = types::Vector<Dimension>;
139 using MeasurementSquareMatrix = types::SquareMatrix<Dimension>;
141 : angVel_(angVel), covariance_(variance.asDiagonal())
144 template <
typename State>
145 MeasurementSquareMatrix
const &
146 getCovariance(State
const & )
151 template <
typename State>
153 predictMeasurement(State
const &s)
const
155 return s.b().stateVector() + angVel_;
158 template <
typename State>
160 getResidual(MeasurementVector
const &predictedMeasurement, State
const &s)
const
162 return predictedMeasurement - s.a().angularVelocity();
165 template <
typename State>
167 getResidual(State
const &s)
const
169 return getResidual(predictMeasurement(s), s);
173 types::Vector<3> angVel_;
174 MeasurementSquareMatrix covariance_;
183 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
184 using State = flexkalman::pose_externalized_rotation::State;
185 static constexpr size_t Dimension = 3;
186 using MeasurementVector = types::Vector<Dimension>;
187 using MeasurementSquareMatrix = types::SquareMatrix<Dimension>;
196 MeasurementVector
const &knownLocationInBodySpace,
197 MeasurementVector
const &variance)
198 : measurement_(measurement), knownLocationInBodySpace_(knownLocationInBodySpace),
199 covariance_(variance.asDiagonal())
202 MeasurementSquareMatrix
const &
203 getCovariance(State
const & )
209 predictMeasurement(State
const &s)
const
211 return s.getIsometry() * knownLocationInBodySpace_;
215 getResidual(MeasurementVector
const &predictedMeasurement, State
const & )
const
217 return measurement_ - predictedMeasurement;
221 getResidual(State
const &s)
const
223 return getResidual(predictMeasurement(s), s);
227 MeasurementVector measurement_;
228 MeasurementVector knownLocationInBodySpace_;
229 MeasurementSquareMatrix covariance_;
For PS Move-like things, where there's a directly-computed absolute position that is not at the track...
Definition: t_fusion.hpp:181
AbsolutePositionLeverArmMeasurement(MeasurementVector const &measurement, MeasurementVector const &knownLocationInBodySpace, MeasurementVector const &variance)
Definition: t_fusion.hpp:195
Definition: t_fusion.hpp:134
For things like accelerometers, which on some level measure the local vector of a world direction.
Definition: t_fusion.hpp:34