OSVR-Core
PoseEstimator_SCAATKalman.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_PoseEstimator_SCAATKalman_h_GUID_F1FC2154_E59B_4598_70C2_253F8EA31485
26 #define INCLUDED_PoseEstimator_SCAATKalman_h_GUID_F1FC2154_E59B_4598_70C2_253F8EA31485
27 
28 // Internal Includes
29 #include "ConfigParams.h"
30 #include "ModelTypes.h"
31 #include "PoseEstimatorTypes.h"
32 #include "TrackedBodyTarget.h"
33 
34 // Library/third-party includes
35 // - none
36 
37 // Standard includes
38 #include <random>
39 
40 namespace osvr {
41 namespace vbtracker {
42 
44  public:
45  enum class TriBool { False, True, Unknown };
46  enum class TrackingHealth {
47  Functioning,
48  NeedsHardResetNow,
49  SoftResetWhenBeaconsSeen
50  };
52  bool operator()(EstimatorInOutParams const &p, LedPtrList const &leds,
53  osvr::util::time::TimeValue const &frameTime,
54  double videoDt);
55 
59  LedPtrList filterLeds(LedPtrList const &leds, const bool skipBright,
60  const bool skipAll, std::size_t &numBad,
61  EstimatorInOutParams const &p);
62 
63  void resetCounters() {
64  m_framesInProbation = 0;
65  m_framesWithoutIdentifiedBlobs = 0;
66  m_framesWithoutUtilizedMeasurements = 0;
67  m_lastUsableBeaconsSeen = SIGNAL_HAVE_NOT_SEEN_BEACONS_YET;
68  m_ledsUsed = 0;
69  m_ledsConsideredMisidentifiedLastFrame = 0;
70  m_ledsUsedLastFrame = 0;
71  m_misIDConsideredOurFault = false;
72  }
73 
78  TrackingHealth getTrackingHealth();
79 
80  private:
81  TriBool inBoundingBoxRatioRange(Led const &led);
82 
83  void markAsPossiblyMisidentified(Led &led);
84  void markAsUsed(Led &led);
85  void handlePossiblyMisidentifiedLeds();
86  double getVarianceFromBeaconDepth(double depth);
87 
88  float m_maxBoxRatio;
89  float m_minBoxRatio;
90  const bool m_shouldSkipBright;
91  const double m_maxResidual;
92  const double m_maxSquaredResidual;
93  const double m_maxZComponent;
94  const double m_highResidualVariancePenalty;
95  const double m_beaconProcessNoise;
96  const double m_noveltyPenaltyBase;
97  const double m_noBeaconLinearVelocityDecayCoefficient;
98  const double m_measurementVarianceScaleFactor;
99  const double m_brightLedVariancePenalty;
100  const double m_distanceMeasVarianceBase;
101  const double m_distanceMeasVarianceIntercept;
102  const bool m_extraVerbose;
103  std::mt19937 m_randEngine;
104  static const int SIGNAL_HAVE_NOT_SEEN_BEACONS_YET = -1;
105  int m_lastUsableBeaconsSeen = SIGNAL_HAVE_NOT_SEEN_BEACONS_YET;
106  std::size_t m_framesInProbation = 0;
107  std::size_t m_framesWithoutIdentifiedBlobs = 0;
108  std::size_t m_framesWithoutUtilizedMeasurements = 0;
109  std::vector<Led *> m_possiblyMisidentified;
110  std::size_t m_ledsUsed = 0;
111  std::size_t m_ledsConsideredMisidentifiedLastFrame = 0;
112  std::size_t m_ledsUsedLastFrame = 0;
113  bool m_misIDConsideredOurFault = false;
114  };
115 } // namespace vbtracker
116 } // namespace osvr
117 
118 #endif // INCLUDED_PoseEstimator_SCAATKalman_h_GUID_F1FC2154_E59B_4598_70C2_253F8EA31485
Helper class to keep track of the state of a blob over time.
Definition: LED.h:47
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
General configuration parameters.
Definition: ConfigParams.h:82
Definition: PoseEstimatorTypes.h:43
Header.
bool operator()(EstimatorInOutParams const &p, LedPtrList const &leds, osvr::util::time::TimeValue const &frameTime, double videoDt)
Definition: PoseEstimator_SCAATKalman.cpp:123
Definition: PoseEstimator_SCAATKalman.h:43
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
LedPtrList filterLeds(LedPtrList const &leds, const bool skipBright, const bool skipAll, std::size_t &numBad, EstimatorInOutParams const &p)
Given a list of LED pointers, filters them out according to configured parameters, updates the debug data, and returns a list of just those LEDs to process.
Definition: PoseEstimator_SCAATKalman.cpp:456
TrackingHealth getTrackingHealth()
Determines whether the Kalman filter is in good working condition, should fall back to RANSAC immedia...
Definition: PoseEstimator_SCAATKalman.cpp:635