OSVR-Core
RoomCalibration.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_RoomCalibration_h_GUID_D53BD552_47D4_4390_C6AC_C6819180D4AF
26 #define INCLUDED_RoomCalibration_h_GUID_D53BD552_47D4_4390_C6AC_C6819180D4AF
27 
28 // Internal Includes
29 #include "BodyIdTypes.h"
30 
31 // Library/third-party includes
32 #include <osvr/Util/Angles.h>
34 #include <osvr/Util/EigenFilters.h>
35 #include <osvr/Util/TimeValue.h>
36 
37 #include <boost/optional.hpp>
38 
39 // Standard includes
40 #include <cstddef>
41 #include <iosfwd>
42 
43 namespace osvr {
44 namespace vbtracker {
45  class TrackingSystem;
49  public:
50  RoomCalibration(Eigen::Vector3d const &camPosition,
51  bool cameraIsForward = true);
52 
55  bool wantVideoData(TrackingSystem const &sys,
56  BodyTargetId const &target) const;
57 
58  void processVideoData(TrackingSystem const &sys,
59  BodyTargetId const &target,
60  util::time::TimeValue const &timestamp,
61  Eigen::Vector3d const &xlate,
62  Eigen::Quaterniond const &quat);
63 
64  void processIMUData(TrackingSystem const &sys, BodyId const &body,
65  util::time::TimeValue const &timestamp,
66  Eigen::Quaterniond const &quat);
67 
71 
72  bool calibrationComplete() const { return m_calibComplete; }
73 
80  boost::optional<util::Angle>
81  getCalibrationYaw(BodyId const &body) const;
86 
87  private:
88  bool finished() const;
89 
91  std::ostream &msgStream() const;
93  std::ostream &msg() const;
97  std::ostream &instructions() const;
98  void endInstructions() const;
99 
100  bool haveVideoData() const { return !m_videoTarget.first.empty(); }
101  bool haveIMUData() const { return !m_imuBody.empty(); }
102  std::size_t m_steadyVideoReports = 0;
103 
104  double m_linVel = 0;
105  double m_angVel = 0;
106  void handleExcessVelocity(double zTranslation);
107  enum class InstructionState {
108  Uninstructed,
109  ToldToMoveCloser,
110  ToldDistanceIsGood
111  };
112  InstructionState m_instructionState = InstructionState::Uninstructed;
113 
116  BodyTargetId m_videoTarget;
117  util::time::TimeValue m_lastVideoData;
119 
121  util::filters::PoseOneEuroFilterd m_poseFilter =
125  Eigen::Vector3d m_rTc_ln_accum = Eigen::Vector3d::Zero();
126 
127  BodyId m_imuBody;
129 
132  Eigen::Vector3d m_suppliedCamPosition;
133  bool m_cameraIsForward;
135 
136  bool m_calibComplete = false;
139  util::Angle m_imuYaw = 0 * util::radians;
140  Eigen::Isometry3d m_cameraPose = Eigen::Isometry3d::Identity();
141  Eigen::Isometry3d m_rTi = Eigen::Isometry3d::Identity();
143  };
144 
147  bool isRoomCalibrationComplete(TrackingSystem const &sys);
148 } // namespace vbtracker
149 } // namespace osvr
150 #endif // INCLUDED_RoomCalibration_h_GUID_D53BD552_47D4_4390_C6AC_C6819180D4AF
AngleRadiansd Angle
Default angle type.
Definition: Angles.h:63
static Quaternion Identity()
Definition: Quaternion.h:133
Parameters needed for the one-euro filter.
Definition: EigenFilters.h:121
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
std::pair< BodyId, TargetId > BodyTargetId
Type-safe zero-based target ID qualified with its body ID.
Definition: BodyIdTypes.h:67
bool wantVideoData(TrackingSystem const &sys, BodyTargetId const &target) const
Since during startup, we only want video data on a single target, we can save processing power by ask...
Definition: RoomCalibration.cpp:80
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
Header defining some filters for Eigen datatypes.
Definition: TrackingSystem.h:54
bool isRoomCalibrationComplete(TrackingSystem const &sys)
A standalone function that looks at the camera and IMUs in a tracking system to determine whether all...
Definition: RoomCalibration.cpp:394
Takes care of the initial room calibration startup step, when we learn the pose of the camera in spac...
Definition: RoomCalibration.h:48
Header providing a C++ wrapper around TimeValueC.h.
void processVideoData(TrackingSystem const &sys, BodyTargetId const &target, util::time::TimeValue const &timestamp, Eigen::Vector3d const &xlate, Eigen::Quaterniond const &quat)
Definition: RoomCalibration.cpp:101
Eigen::Isometry3d getCameraPose() const
Gets the pose of the camera in the room (the transform from camera space to room space) ...
Definition: RoomCalibration.cpp:371
Definition: Quaternion.h:47
Combines a one-euro filter for position and a one-euro filter for orientation for the common use case...
Definition: EigenFilters.h:226
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
Header.
Definition: Transform.h:43
bool postCalibrationUpdate(TrackingSystem &sys)
When completed feeding data, this method will check to see if calibration has finished and perform up...
Definition: RoomCalibration.cpp:299