OSVR-Core
ConfigurationParser.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_ConfigurationParser_h_GUID_933C79EE_3392_4C8D_74D5_D9A72580DA6A
26 #define INCLUDED_ConfigurationParser_h_GUID_933C79EE_3392_4C8D_74D5_D9A72580DA6A
27 
28 // Internal Includes
29 #include "GetOptionalParameter.h"
30 #include "Types.h"
31 #include <ParseBlobParams.h>
32 
33 // Library/third-party includes
34 #include <json/value.h>
35 
36 // Standard includes
37 // - none
38 
39 namespace osvr {
40 namespace vbtracker {
41 
42  inline ConfigParams parseConfigParams(Json::Value const &root) {
43  ConfigParams config;
44  config.debug = root.get("showDebug", false).asBool();
46  getOptionalParameter(config.includeRearPanel, root, "includeRearPanel");
47  getOptionalParameter(config.headCircumference, root,
48  "headCircumference");
49  getOptionalParameter(config.headToFrontBeaconOriginDistance, root,
50  "headToFrontBeaconOriginDistance");
51  getOptionalParameter(config.backPanelMeasurementError, root,
52  "backPanelMeasurementError");
53 
54  // If we include the rear panel, we default to not offsetting to
55  // centroid since it causes strange tracking.
56  if (config.includeRearPanel) {
57  config.offsetToCentroid = false;
58  }
59 
61  getOptionalParameter(config.extraVerbose, root, "extraVerbose");
62  getOptionalParameter(config.calibrationFile, root, "calibrationFile");
63  getOptionalParameter(config.additionalPrediction, root,
64  "additionalPrediction");
65  getOptionalParameter(config.maxResidual, root, "maxResidual");
66  getOptionalParameter(config.initialBeaconError, root,
67  "initialBeaconError");
68  getOptionalParameter(config.blobMoveThreshold, root,
69  "blobMoveThreshold");
70  getOptionalParameter(config.blobsKeepIdentity, root,
71  "blobsKeepIdentity");
72  getOptionalParameter(config.numThreads, root, "numThreads");
73  getOptionalParameter(config.streamBeaconDebugInfo, root,
74  "streamBeaconDebugInfo");
75  getOptionalParameter(config.offsetToCentroid, root, "offsetToCentroid");
76  if (!config.offsetToCentroid) {
77  getOptionalParameter(config.manualBeaconOffset, root,
78  "manualBeaconOffset");
79  }
80 
82  getOptionalParameter(config.beaconProcessNoise, root,
83  "beaconProcessNoise");
84  getOptionalParameter(config.processNoiseAutocorrelation, root,
85  "processNoiseAutocorrelation");
86  getOptionalParameter(config.linearVelocityDecayCoefficient, root,
87  "linearVelocityDecayCoefficient");
88  getOptionalParameter(config.angularVelocityDecayCoefficient, root,
89  "angularVelocityDecayCoefficient");
90  getOptionalParameter(config.measurementVarianceScaleFactor, root,
91  "measurementVarianceScaleFactor");
92  getOptionalParameter(config.highResidualVariancePenalty, root,
93  "highResidualVariancePenalty");
94  getOptionalParameter(config.boundingBoxFilterRatio, root,
95  "boundingBoxFilterRatio");
96  getOptionalParameter(config.maxZComponent, root, "maxZComponent");
97  getOptionalParameter(config.shouldSkipBrightLeds, root,
98  "shouldSkipBrightLeds");
99 
101  if (root.isMember("blobParams")) {
102  parseBlobParams(root["blobParams"], config.blobParams);
103  }
104 
105  return config;
106  }
107 
108 } // End namespace vbtracker
109 } // End namespace osvr
110 #endif // INCLUDED_ConfigurationParser_h_GUID_933C79EE_3392_4C8D_74D5_D9A72580DA6A
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
ConfigParams parseConfigParams(Json::Value const &root)
Definition: ConfigurationParser.h:88
Header.
void getOptionalParameter(T &dest, Json::Value const &obj, const char *key)
Gets an optional parameter from a JSON object: if it&#39;s not present, the existing value is left there...
Definition: GetOptionalParameter.h:60
bool debug
Whether to show the debug windows and debug messages.
Definition: ConfigParams.h:137