OSVR-Core
ParameterSets.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_ParameterSets_h_GUID_3059CE4C_7E9B_4784_4678_5B01F94BC979
26 #define INCLUDED_ParameterSets_h_GUID_3059CE4C_7E9B_4784_4678_5B01F94BC979
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 // - none
36 
37 namespace osvr {
38 namespace vbtracker {
39 
40  namespace optimization_param_sets {
42  template <typename T> struct ParamSetName;
43 
46  static const size_t Dimension = 5;
47 
50 
52  static ParamVec getInitialVec(OptimCommonData const &commonData) {
53 
54  ParamVec x;
55  const auto &p = commonData.initialParams;
56  const auto posProcessNoise = p.processNoiseAutocorrelation[0];
57  const auto oriProcessNoise = p.processNoiseAutocorrelation[3];
58 
59  x << posProcessNoise, oriProcessNoise,
60  p.linearVelocityDecayCoefficient,
61  p.angularVelocityDecayCoefficient,
62  p.noBeaconLinearVelocityDecayCoefficient;
63  return x;
64  }
65 
67  static std::pair<double, double> getRho() { return {1e-10, 1e0}; }
68 
70  static void updateParamsFromVec(ConfigParams &params,
71  ParamVec const &x) {
72  // Update config from provided param vec
74  params.processNoiseAutocorrelation[0] =
75  params.processNoiseAutocorrelation[1] =
76  params.processNoiseAutocorrelation[2] = x[0];
78  params.processNoiseAutocorrelation[3] =
79  params.processNoiseAutocorrelation[4] =
80  params.processNoiseAutocorrelation[5] = x[1];
81 
82  params.linearVelocityDecayCoefficient = x[2];
83  params.angularVelocityDecayCoefficient = x[3];
85  }
86 
88  static const char *getVecElementNames() {
89  return "position process noise autocorrelation, "
90  "orientation process noise autocorrelation, "
91  "linear velocity decay coefficient, "
92  "angular velocity decay coefficient, "
93  "no-beacon linear velocity decay coefficient";
94  }
95  };
96 
98  template <> struct ParamSetName<ProcessNoiseAndDecay> {
99  static const char *get() { return "ProcessNoiseAndDecay"; }
100  };
101 
104  static const size_t Dimension = 5;
105 
108 
110  static ParamVec getInitialVec(OptimCommonData const &commonData) {
111 
112  ParamVec x;
113  const auto &p = commonData.initialParams;
114  const auto posProcessNoise = p.processNoiseAutocorrelation[0];
115  const auto oriProcessNoise = p.processNoiseAutocorrelation[3];
116 
117  x << posProcessNoise, oriProcessNoise,
118  p.measurementVarianceScaleFactor,
119  p.linearVelocityDecayCoefficient,
120  p.angularVelocityDecayCoefficient;
121  return x;
122  }
123 
125  static std::pair<double, double> getRho() { return {1e-10, 1e0}; }
126 
128  static void updateParamsFromVec(ConfigParams &params,
129  ParamVec const &x) {
130  // Update config from provided param vec
132  params.processNoiseAutocorrelation[0] =
133  params.processNoiseAutocorrelation[1] =
134  params.processNoiseAutocorrelation[2] = x[0];
136  params.processNoiseAutocorrelation[3] =
137  params.processNoiseAutocorrelation[4] =
138  params.processNoiseAutocorrelation[5] = x[1];
139 
140  params.measurementVarianceScaleFactor = x[2];
141 
142  params.linearVelocityDecayCoefficient = x[3];
143  params.angularVelocityDecayCoefficient = x[4];
144  }
145 
147  static const char *getVecElementNames() {
148  return "position process noise autocorrelation, "
149  "orientation process noise autocorrelation, "
150  "video tracker measurement variance scale factor, "
151  "linear velocity decay coefficient, "
152  "angular velocity decay coefficient";
153  }
154  };
155 
158  static const char *get() { return "ProcessNoiseVarianceAndDecay"; }
159  };
160 
161  struct BrightAndNew {
163  static const size_t Dimension = 2;
164 
167 
169  static ParamVec getInitialVec(OptimCommonData const &commonData) {
170  ParamVec x;
171  const auto &p = commonData.initialParams;
172  x << p.brightLedVariancePenalty, p.tuning.noveltyPenaltyBase;
173  return x;
174  }
175 
177  static std::pair<double, double> getRho() { return {1e-5, 1e1}; }
178 
181  ParamVec const &x) {
182  // Update config from provided param vec
183  p.brightLedVariancePenalty = x[0];
184  p.shouldSkipBrightLeds = false;
185  p.tuning.noveltyPenaltyBase = x[1];
186  }
187 
189  static const char *getVecElementNames() {
190  return "bright LED variance penalty,\n"
191  "novelty penalty base";
192  }
193  };
194 
195  template <> struct ParamSetName<BrightAndNew> {
196  static const char *get() { return "BrightAndNew"; }
197  };
198 
199  struct HighResidual {
201  static const size_t Dimension = 2;
202 
205 
207  static ParamVec getInitialVec(OptimCommonData const &commonData) {
208  ParamVec x;
209  const auto &p = commonData.initialParams;
210  x << p.maxResidual, p.highResidualVariancePenalty;
211  return x;
212  }
213 
215  static std::pair<double, double> getRho() { return {1e-4, 1e1}; }
216 
219  ParamVec const &x) {
220  // Update config from provided param vec
221  p.maxResidual = x[0];
223  }
224 
226  static const char *getVecElementNames() {
227  return "max residual,\n"
228  "high residual variance penalty";
229  }
230  };
231 
232  template <> struct ParamSetName<HighResidual> {
233  static const char *get() { return "HighResidual"; }
234  };
235 
238  static const size_t Dimension = 3;
239 
242 
244  static ParamVec getInitialVec(OptimCommonData const &commonData) {
245  ParamVec x;
246  const auto &p = commonData.initialParams;
247  x << p.brightLedVariancePenalty, p.highResidualVariancePenalty,
248  p.measurementVarianceScaleFactor;
249  return x;
250  }
251 
253  static std::pair<double, double> getRho() { return {1e-5, 1e1}; }
254 
257  ParamVec const &x) {
258  // Update config from provided param vec
259  p.brightLedVariancePenalty = x[0];
260  p.shouldSkipBrightLeds = false;
263  }
264 
266  static const char *getVecElementNames() {
267  return "bright LED variance penalty,\n"
268  "high residual variance penalty,\n"
269  "measurement variance scale factor";
270  }
271  };
272 
273  template <> struct ParamSetName<VariancePenalties> {
274  static const char *get() { return "VariancePenalties"; }
275  };
276  } // namespace optimization_param_sets
277 } // namespace vbtracker
278 } // namespace osvr
279 #endif // INCLUDED_ParameterSets_h_GUID_3059CE4C_7E9B_4784_4678_5B01F94BC979
static std::pair< double, double > getRho()
required part of interface
Definition: ParameterSets.h:67
double linearVelocityDecayCoefficient
The value used in exponential decay of linear velocity: it&#39;s the proportion of that velocity remainin...
Definition: ConfigParams.h:151
double processNoiseAutocorrelation[6]
This is the autocorrelation kernel of the process noise.
Definition: ConfigParams.h:146
double highResidualVariancePenalty
This is the multiplicative penalty applied to the variance of measurements with a "bad" residual...
Definition: ConfigParams.h:208
static std::pair< double, double > getRho()
required part of interface
Definition: ParameterSets.h:125
static std::pair< double, double > getRho()
required part of interface
Definition: ParameterSets.h:215
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
double brightLedVariancePenalty
If shouldSkipBrightLeds is false, we use this value as a factor to increase the measurement variance ...
Definition: ConfigParams.h:235
static void updateParamsFromVec(ConfigParams &p, ParamVec const &x)
required part of interface
Definition: ParameterSets.h:180
static ParamVec getInitialVec(OptimCommonData const &commonData)
required part of interface
Definition: ParameterSets.h:169
double noBeaconLinearVelocityDecayCoefficient
The value used in an additional exponential decay of linear velocity when we&#39;ve lost sight of all bea...
Definition: ConfigParams.h:162
static std::pair< double, double > getRho()
required part of interface
Definition: ParameterSets.h:177
static const char * getVecElementNames()
required part of interface
Definition: ParameterSets.h:189
static ParamVec getInitialVec(OptimCommonData const &commonData)
required part of interface
Definition: ParameterSets.h:207
static const char * getVecElementNames()
required part of interface
Definition: ParameterSets.h:88
static const size_t Dimension
required part of interface
Definition: ParameterSets.h:46
static const char * getVecElementNames()
required part of interface
Definition: ParameterSets.h:147
static void updateParamsFromVec(ConfigParams &params, ParamVec const &x)
required part of interface
Definition: ParameterSets.h:128
General configuration parameters.
Definition: ConfigParams.h:82
static ParamVec getInitialVec(OptimCommonData const &commonData)
required part of interface
Definition: ParameterSets.h:52
static void updateParamsFromVec(ConfigParams &p, ParamVec const &x)
required part of interface
Definition: ParameterSets.h:256
static ParamVec getInitialVec(OptimCommonData const &commonData)
required part of interface
Definition: ParameterSets.h:244
double maxResidual
Max residual, in meters at the expected XY plane of the beacon in space, for a beacon before applying...
Definition: ConfigParams.h:123
static void updateParamsFromVec(ConfigParams &params, ParamVec const &x)
required part of interface
Definition: ParameterSets.h:70
static std::pair< double, double > getRho()
required part of interface
Definition: ParameterSets.h:253
bool shouldSkipBrightLeds
Should we attempt to skip bright-mode LEDs? The alternative is to just give them slightly higher vari...
Definition: ConfigParams.h:229
double measurementVarianceScaleFactor
The measurement variance (units: m^2) is included in the plugin along with the coordinates of the bea...
Definition: ConfigParams.h:169
Input from main to the optimization routine (wrapper)
Definition: OptimizationBase.h:47
static const char * getVecElementNames()
required part of interface
Definition: ParameterSets.h:226
static const char * getVecElementNames()
required part of interface
Definition: ParameterSets.h:266
static void updateParamsFromVec(ConfigParams &p, ParamVec const &x)
required part of interface
Definition: ParameterSets.h:218
Trait for param set name.
Definition: ParameterSets.h:42
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
static ParamVec getInitialVec(OptimCommonData const &commonData)
required part of interface
Definition: ParameterSets.h:110
double angularVelocityDecayCoefficient
The value used in exponential decay of angular velocity: it&#39;s the proportion of that velocity remaini...
Definition: ConfigParams.h:156