OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PoseEstimator_RANSACKalman.cpp
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 // Internal Includes
27 
28 // Library/third-party includes
32 
33 // Standard includes
34 // - none
35 
36 namespace osvr {
37 namespace vbtracker {
38  RANSACKalmanPoseEstimator::RANSACKalmanPoseEstimator(
39  double positionVarianceScale, double orientationVariance)
40  : m_positionVarianceScale(positionVarianceScale),
41  m_orientationVariance(orientationVariance) {}
42 
44  operator()(EstimatorInOutParams const &p, LedPtrList const &leds,
45  osvr::util::time::TimeValue const &frameTime) {
46 
47  Eigen::Vector3d xlate;
48  Eigen::Quaterniond quat;
50  {
51  auto ret = m_ransac(p.camParams, leds, p.beacons, p.beaconDebug,
52  xlate, quat);
53  if (!ret) {
54  return false;
55  }
56  }
57 
59 
60  if (p.startingTime != frameTime) {
62  auto dt = util::time::duration(frameTime, p.startingTime);
63  kalman::predict(p.state, p.processModel, dt);
64  }
65 
67  {
69  quat, Eigen::Vector3d::Constant(m_orientationVariance));
70  kalman::correct(p.state, p.processModel, meas);
71  }
73  {
76  xlate, Eigen::Vector3d::Constant(m_positionVarianceScale *
77  xlate.z() * xlate.z()));
78  kalman::correct(p.state, p.processModel, meas);
79  }
80  return true;
81  }
82 } // namespace vbtracker
83 } // namespace osvr
bool operator()(EstimatorInOutParams const &p, LedPtrList const &leds, osvr::util::time::TimeValue const &frameTime)
double duration(TimeValue const &a, TimeValue const &b)
Get a double containing seconds between the time points.
Definition: TimeValue.h:62
bool correct(StateType &state, ProcessModelType &processModel, MeasurementType &meas, bool cancelIfNotFinite=true)
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
Header for measurements of absolute orientation.
osvr::util::time::TimeValue const & startingTime
Time that the state is coming in at.