OSVR-Core
VideoIMUFusion.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_VideoIMUFusion_h_GUID_85338EA5_58E6_4787_16D2_EC53201EFE9F
26 #define INCLUDED_VideoIMUFusion_h_GUID_85338EA5_58E6_4787_16D2_EC53201EFE9F
27 
28 // Internal Includes
29 #include "FusionParams.h"
32 #include <osvr/Util/TimeValue.h>
33 
34 // Library/third-party includes
35 // - none
36 
37 // Standard includes
38 #include <memory>
39 #include <cassert>
40 
44  public:
49 
50  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
51 
54  void handleIMUData(const OSVR_TimeValue &timestamp,
55  const OSVR_OrientationReport &report);
56 
57  void handleIMUVelocity(const OSVR_TimeValue &timestamp,
58  const Eigen::Vector3d &angVel);
62  const OSVR_PoseReport &report);
69  const OSVR_TimeValue &timestamp, const OSVR_PoseReport &report,
70  const OSVR_OrientationState &orientation);
71 
72  bool running() const { return m_state == State::Running; }
73 
75  OSVR_PoseState const &getLatestPose() const { return m_lastPose; }
76 
80  return m_lastTime;
81  }
82 
83  OSVR_VelocityState const &getLatestVelocity() const {
84  return m_lastVelocity;
85  }
86  osvr::util::time::TimeValue const &getLatestVelocityTime() const {
87  return m_lastVelTime;
88  }
89 
93  assert(running());
94  return m_reorientedVideo;
95  }
96 
102  assert(running());
103  return m_camera;
104  }
105 
109 
110  private:
111  void enterCameraPoseAcquisitionState();
112  void enterRunningState(Eigen::Isometry3d const &rTc,
113  const OSVR_TimeValue &timestamp,
114  const OSVR_PoseReport &report,
115  const OSVR_OrientationState &orientation);
116  void updateFusedOutput(const OSVR_TimeValue &timestamp);
117  enum class State {
119  AcquiringCameraPose,
120  Running
121  };
122 
123  State m_state = State::AcquiringCameraPose;
124 
125  class StartupData;
126  std::unique_ptr<StartupData> m_startupData;
127  class RunningData;
128  std::unique_ptr<RunningData> m_runningData;
129  Eigen::Isometry3d m_rTc;
130 
131  OSVR_PoseState m_camera;
132  OSVR_PoseState m_reorientedVideo;
133  OSVR_PoseState m_lastPose;
134  osvr::util::time::TimeValue m_lastTime;
135  OSVR_VelocityState m_lastVelocity;
136  osvr::util::time::TimeValue m_lastVelTime;
137  VideoIMUFusionParams m_params;
138  Eigen::Isometry3d m_roomCalib;
139 };
140 
141 #endif // INCLUDED_VideoIMUFusion_h_GUID_85338EA5_58E6_4787_16D2_EC53201EFE9F
void handleVideoTrackerDataWhileRunning(const OSVR_TimeValue &timestamp, const OSVR_PoseReport &report)
Call with each new video tracker report once we&#39;ve entered running state.
Definition: VideoIMUFusion.cpp:153
Definition: FusionParams.h:37
VideoIMUFusion(VideoIMUFusionParams const &params=VideoIMUFusionParams())
Constructor.
Definition: VideoIMUFusion.cpp:63
OSVR_PoseState const & getLatestReorientedVideoPose() const
Returns the latest video-tracker pose, re-oriented to be in room space.
Definition: VideoIMUFusion.h:92
OSVR_PoseState const & getLatestPose() const
Returns the latest (fusion result, if available) pose.
Definition: VideoIMUFusion.h:75
Eigen::Matrix< double, 12, 12 > const & getErrorCovariance() const
Returns the current state error covariance matrix Only valid once running state is entered! ...
Definition: VideoIMUFusion.cpp:70
EIGEN_MAKE_ALIGNED_OPERATOR_NEW void handleIMUData(const OSVR_TimeValue &timestamp, const OSVR_OrientationReport &report)
Call with each new IMU report, whether or not fusion is in running state.
Definition: VideoIMUFusion.cpp:103
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
A structure defining a quaternion, often a unit quaternion representing 3D rotation.
Definition: QuaternionC.h:49
The core of the fusion code - doesn&#39;t deal with getting data in or reporting it out, for easier use in testing.
Definition: VideoIMUFusion.h:43
~VideoIMUFusion()
Out-of-line destructor required for unique_ptr pimpl idiom.
osvr::util::time::TimeValue const & getLatestTime() const
Returns the timestamp associated with the latest (fusion result, if available) pose.
Definition: VideoIMUFusion.h:79
void handleVideoTrackerDataDuringStartup(const OSVR_TimeValue &timestamp, const OSVR_PoseReport &report, const OSVR_OrientationState &orientation)
Call with each new video tracker report, as well as the most recent IMU orientation state...
Definition: VideoIMUFusion.cpp:262
Report type for an orientation callback on a tracker interface.
Definition: ClientReportTypesC.h:145
void handleIMUVelocity(const OSVR_TimeValue &timestamp, const Eigen::Vector3d &angVel)
Definition: VideoIMUFusion.cpp:118
Header providing a C++ wrapper around TimeValueC.h.
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
Definition: Pose3C.h:54
Struct for combined velocity state.
Definition: ClientReportTypesC.h:87
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Definition: VideoIMUFusion.cpp:168
Definition: RunningData.h:75
Definition: Transform.h:43
Report type for a pose (position and orientation) callback on a tracker interface.
Definition: ClientReportTypesC.h:155
OSVR_PoseState const & getLatestCameraPose() const
Returns the latest pose of the camera in the room.
Definition: VideoIMUFusion.h:101