OSVR-Core
TrackedBodyIMU.h
Go to the documentation of this file.
1 
11 // Copyright 2016 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_TrackedBodyIMU_h_GUID_65A86547_8C4C_43B5_906C_361178DCCE06
26 #define INCLUDED_TrackedBodyIMU_h_GUID_65A86547_8C4C_43B5_906C_361178DCCE06
27 
28 // Internal Includes
29 #include "CannedIMUMeasurement.h"
30 #include "ModelTypes.h"
31 
32 // Library/third-party includes
33 #include <osvr/Util/Angles.h>
35 #include <osvr/Util/TimeValue.h>
36 
37 // Standard includes
38 // - none
39 
40 namespace osvr {
41 namespace vbtracker {
42  struct ConfigParams;
43  class TrackedBody;
45  public:
46  TrackedBodyIMU(TrackedBody &body, double orientationVariance,
47  double angularVelocityVariance);
48 
49  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50 
51  TrackedBody &getBody() { return m_body; }
52  TrackedBody const &getBody() const { return m_body; }
53 
56  Eigen::Quaterniond const &quat);
57 
60  Eigen::Quaterniond const &deltaquat,
61  double dt);
62 
63  bool hasPoseEstimate() const { return m_hasOrientation; }
64  util::time::TimeValue const &getLastUpdate() const { return m_last; }
66  Eigen::Quaterniond const &getPoseEstimate() const { return m_quat; }
67 
68  bool calibrationYawKnown() const { return m_yawKnown; }
69  void setCalibrationYaw(util::Angle yaw) {
70  using namespace Eigen;
71  using namespace util;
72  m_yaw = yaw;
73  m_yawCorrection =
74  Quaterniond(AngleAxisd(getRadians(m_yaw), Vector3d::UnitY()));
75  m_yawKnown = true;
76  }
77 
80  return m_yawCorrection;
81  }
82 
83  private:
86  transformRawIMUOrientation(Eigen::Quaterniond const &input) const;
88  Eigen::Quaterniond transformRawIMUAngularVelocity(
89  Eigen::Quaterniond const &deltaquat) const;
90 
95  preprocessAngularVelocity(util::time::TimeValue const &tv,
96  Eigen::Quaterniond const &deltaquat,
97  double dt);
98 
103  preprocessOrientation(util::time::TimeValue const &tv,
104  Eigen::Quaterniond const &quat);
105 
110  bool updatePoseFromMeasurement(util::time::TimeValue const &tv,
111  CannedIMUMeasurement const &meas);
112 
113  ConfigParams const &getParams() const;
114  TrackedBody &m_body;
115  bool m_yawKnown = false;
116  util::Angle m_yaw;
118  Eigen::Quaterniond m_yawCorrection;
119 
120  bool m_useOrientation;
121  double m_orientationVariance;
122  bool m_useAngularVelocity;
123  double m_angularVelocityVariance;
124 
125  bool m_hasRawQuat = false;
127  Eigen::Quaterniond m_rawQuat;
128 
129  bool m_hasOrientation = false;
131  Eigen::Quaterniond m_quat;
132  util::time::TimeValue m_last;
133  };
134 } // namespace vbtracker
135 } // namespace osvr
136 
137 #endif // INCLUDED_TrackedBodyIMU_h_GUID_65A86547_8C4C_43B5_906C_361178DCCE06
AngleRadiansd Angle
Default angle type.
Definition: Angles.h:63
Definition: RunLoopManager.h:42
void updatePoseFromOrientation(util::time::TimeValue const &tv, Eigen::Quaterniond const &quat)
Processes an orientation.
Definition: TrackedBodyIMU.cpp:49
Eigen::Quaterniond const & getIMUToRoom() const
Gets the transform based on the calibration yaw.
Definition: TrackedBodyIMU.h:79
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
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
A safe way to store and transport an orientation measurement or an angular velocity measurement witho...
Definition: CannedIMUMeasurement.h:44
AngleAxis< double > AngleAxisd
double precision angle-axis type
Definition: AngleAxis.h:152
General configuration parameters.
Definition: ConfigParams.h:82
void updatePoseFromAngularVelocity(util::time::TimeValue const &tv, Eigen::Quaterniond const &deltaquat, double dt)
Processes an angular velocity.
Definition: TrackedBodyIMU.cpp:82
Definition: TrackedBodyIMU.h:44
Header providing a C++ wrapper around TimeValueC.h.
This is the class representing a tracked rigid body in the system.
Definition: TrackedBody.h:56
Definition: Quaternion.h:47
Header.
Quaternion< double > Quaterniond
double precision quaternion type
Definition: Quaternion.h:211
Y getRadians(AngleGeneric< System, Y > const angle)
Get the raw scalar value of your angle in radians.
Definition: Angles.h:67
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
Header.
Eigen::Quaterniond const & getPoseEstimate() const
This estimate incorporates the calibration yaw correction.
Definition: TrackedBodyIMU.h:66