25 #ifndef INCLUDED_PoseState_h_GUID_57A246BA_940D_4386_ECA4_4C4172D97F5A 26 #define INCLUDED_PoseState_h_GUID_57A246BA_940D_4386_ECA4_4C4172D97F5A 34 #include <Eigen/Geometry> 41 namespace pose_externalized_rotation {
42 using Dimension = types::DimensionConstant<12>;
43 using StateVector = types::DimVector<Dimension>;
44 using StateVectorBlock3 = StateVector::FixedSegmentReturnType<3>::Type;
45 using ConstStateVectorBlock3 =
46 StateVector::ConstFixedSegmentReturnType<3>::Type;
48 using StateVectorBlock6 = StateVector::FixedSegmentReturnType<6>::Type;
49 using StateSquareMatrix = types::DimSquareMatrix<Dimension>;
53 inline StateVectorBlock3 position(StateVector &vec) {
56 inline ConstStateVectorBlock3 position(StateVector
const &vec) {
60 inline StateVectorBlock3 incrementalOrientation(StateVector &vec) {
61 return vec.segment<3>(3);
63 inline ConstStateVectorBlock3
64 incrementalOrientation(StateVector
const &vec) {
65 return vec.segment<3>(3);
68 inline StateVectorBlock3 velocity(StateVector &vec) {
69 return vec.segment<3>(6);
71 inline ConstStateVectorBlock3 velocity(StateVector
const &vec) {
72 return vec.segment<3>(6);
75 inline StateVectorBlock3 angularVelocity(StateVector &vec) {
76 return vec.segment<3>(9);
78 inline ConstStateVectorBlock3 angularVelocity(StateVector
const &vec) {
79 return vec.segment<3>(9);
84 return vec.segment<6>(6);
101 return std::pow(damping, dt);
109 stateTransitionMatrixWithVelocityDamping(
double dt,
double damping) {
111 auto A = stateTransitionMatrix(dt);
125 auto A = stateTransitionMatrix(dt);
139 position(ret) += velocity(state) * dt;
140 incrementalOrientation(ret) += angularVelocity(state) * dt;
154 double oriDamping,
double dt) {
160 incrementalOrientationToQuat(
StateVector const &state) {
161 return external_quat::vecToQuat(incrementalOrientation(state));
166 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
184 return m_errorCovariance;
193 void postCorrect() { externalizeRotation(); }
195 void externalizeRotation() {
197 incrementalOrientation() = Eigen::Vector3d::Zero();
200 StateVectorBlock3 position() {
201 return pose_externalized_rotation::position(m_state);
204 ConstStateVectorBlock3 position()
const {
205 return pose_externalized_rotation::position(m_state);
208 StateVectorBlock3 incrementalOrientation() {
209 return pose_externalized_rotation::incrementalOrientation(
213 ConstStateVectorBlock3 incrementalOrientation()
const {
214 return pose_externalized_rotation::incrementalOrientation(
218 StateVectorBlock3 velocity() {
219 return pose_externalized_rotation::velocity(m_state);
222 ConstStateVectorBlock3 velocity()
const {
223 return pose_externalized_rotation::velocity(m_state);
226 StateVectorBlock3 angularVelocity() {
227 return pose_externalized_rotation::angularVelocity(m_state);
230 ConstStateVectorBlock3 angularVelocity()
const {
231 return pose_externalized_rotation::angularVelocity(m_state);
235 return m_orientation;
240 return incrementalOrientationToQuat(m_state).
normalized() *
248 ret.fromPositionOrientationScale(position(), getQuaternion(),
249 Eigen::Vector3d::Constant(1));
266 template <
typename OutputStream>
267 inline OutputStream &operator<<(OutputStream &os,
State const &state) {
268 os <<
"State:" << state.
stateVector().transpose() <<
"\n";
278 #endif // INCLUDED_PoseState_h_GUID_57A246BA_940D_4386_ECA4_4C4172D97F5A
typename detail::Dimension_impl< T >::type Dimension
Given a state or measurement, get the dimension as a std::integral_constant.
Definition: FlexibleKalmanBase.h:87
const Coefficients & coeffs() const
Definition: Quaternion.h:93
Convenience base class for things (like states and measurements) that have a dimension.
Definition: FlexibleKalmanBase.h:63
void setQuaternion(Eigen::Quaterniond const &quaternion)
Intended for startup use.
Definition: PoseState.h:189
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Eigen::Isometry3d getIsometry() const
Get the position and quaternion combined into a single isometry (transformation)
Definition: PoseState.h:246
void separatelyDampenVelocities(StateVector &state, double posDamping, double oriDamping, double dt)
Separately dampen the linear and angular velocities.
Definition: PoseState.h:152
StateVector const & stateVector() const
xhat
Definition: PoseState.h:177
EIGEN_MAKE_ALIGNED_OPERATOR_NEW State()
Default constructor.
Definition: PoseState.h:169
StateVectorBlock6 velocities(StateVector &vec)
both translational and angular velocities
Definition: PoseState.h:83
StateSquareMatrix const & errorCovariance() const
P.
Definition: PoseState.h:183
double computeAttenuation(double damping, double dt)
Function used to compute the coefficient m in v_new = m * v_old.
Definition: PoseState.h:100
StateSquareMatrix stateTransitionMatrixWithSeparateVelocityDamping(double dt, double posDamping, double oriDamping)
Returns the state transition matrix for a constant velocity with separate damping paramters for linea...
Definition: PoseState.h:121
Definition: Quaternion.h:47
Definition: PoseState.h:164
Quaternion< double > Quaterniond
double precision quaternion type
Definition: Quaternion.h:211
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Quaternion normalized() const
Definition: Quaternion.h:154
Eigen::Quaterniond getCombinedQuaternion() const
Definition: PoseState.h:238
void setStateVector(StateVector const &state)
set xhat
Definition: PoseState.h:175