25 #ifndef INCLUDED_ConfigurationParser_h_GUID_933C79EE_3392_4C8D_74D5_D9A72580DA6A 26 #define INCLUDED_ConfigurationParser_h_GUID_933C79EE_3392_4C8D_74D5_D9A72580DA6A 35 #include <boost/optional.hpp> 36 #include <json/value.h> 39 #include <initializer_list> 44 inline const char *getConfigStringForTargetSet(BuiltInTargetSets target) {
46 case osvr::vbtracker::BuiltInTargetSets::HDK1xChassis:
49 case osvr::vbtracker::BuiltInTargetSets::HDK2Chassis:
54 static const std::initializer_list<BuiltInTargetSets> AllBuiltInTargetSets =
55 {BuiltInTargetSets::HDK1xChassis, BuiltInTargetSets::HDK2Chassis};
56 template <
typename EnumType,
typename StringifyFunctor>
57 inline std::pair<boost::optional<EnumType>, boost::optional<std::string>>
59 Json::Value
const &root,
const char memberName[],
60 StringifyFunctor &&stringifyEnum,
61 std::initializer_list<EnumType>
const &possibleValues) {
63 std::pair<boost::optional<EnumType>, boost::optional<std::string>>;
65 if (!root.isMember(memberName)) {
68 auto &member = root[memberName];
69 if (!member.isString()) {
72 std::string str = member.asString();
74 for (
auto enumVal : possibleValues) {
75 if (str == stringifyEnum(enumVal)) {
85 static const auto MESSAGE_PREFIX =
86 "[Unified Tracker] Configuration Parsing WARNING: ";
87 #define PARAMNAME(X) "'" << X << "'" 90 config.
debug = root.get(
"showDebug",
false).asBool();
94 getConfigStringForTargetSet,
95 AllBuiltInTargetSets);
96 if (targetSet.first) {
98 }
else if (targetSet.second) {
102 std::cout << MESSAGE_PREFIX << PARAMNAME(
"targetSet")
103 <<
" contained a string, \"" << *(targetSet.second)
104 <<
"\", that was not recognized as a known target set. " 105 "Using the default instead." 110 "backPanelMeasurementError");
115 "headCircumference");
117 "headToFrontBeaconOriginDistance");
119 "backPanelMeasurementError");
128 getOptionalParameter(config.
logRawBlobs, root,
"logRawBlobs");
130 std::cout << MESSAGE_PREFIX << PARAMNAME(
"logRawBlobs")
131 <<
" is enabled - existing raw blob data file will be " 132 "overwritten, and there is a slight chance of " 133 "performance impacts." 136 getOptionalParameter(config.
logUsableLeds, root,
"logUsableLeds");
138 std::cout << MESSAGE_PREFIX << PARAMNAME(
"logUsableLeds")
139 <<
" is enabled - existing 'usable LED' data file will " 140 "be overwritten, and there is a slight chance of " 141 "performance impacts." 146 "continuousReporting");
147 getOptionalParameter(config.
extraVerbose, root,
"extraVerbose");
148 getOptionalParameter(config.
highGain, root,
"highGain");
152 "additionalPrediction");
153 getOptionalParameter(config.
maxResidual, root,
"maxResidual");
155 "initialBeaconError");
157 "blobMoveThreshold");
159 "blobsKeepIdentity");
160 getOptionalParameter(config.
numThreads, root,
"numThreads");
162 "cameraMicrosecondsOffset");
164 "streamBeaconDebugInfo");
169 "manualBeaconOffset");
173 getOptionalParameter(config.
cameraPosition, root,
"cameraPosition");
175 outputUnless(std::cout, root[
"eyeHeight"].
isNull())
176 << MESSAGE_PREFIX << PARAMNAME(
"eyeHeight")
177 <<
" is deprecated/ignored: use 'cameraPosition' for similar " 178 "effects with this plugin.";
181 getOptionalParameter(config.
permitKalman, root,
"permitKalman");
183 "beaconProcessNoise");
185 "processNoiseAutocorrelation");
187 "linearVelocityDecayCoefficient");
189 "angularVelocityDecayCoefficient");
191 root,
"noBeaconLinearVelocityDecayCoefficient");
193 "measurementVarianceScaleFactor");
195 "highResidualVariancePenalty");
198 "boundingBoxFilterRatio");
200 outputUnless(std::cout, root[
"boundingBoxFilterRatio"].
isNull())
201 << MESSAGE_PREFIX << PARAMNAME(
"boundingBoxFilterRatio")
202 <<
" parameter not actively used";
204 getOptionalParameter(config.
maxZComponent, root,
"maxZComponent");
206 "shouldSkipBrightLeds");
208 "brightLedVariancePenalty");
211 getOptionalParameter(config.
softResets, root,
"softResets");
213 "softResetPositionVarianceScale");
215 "softResetOrientationVariance");
218 if (root.isMember(
"blobParams")) {
219 parseBlobParams(root[
"blobParams"], config.
blobParams);
222 parseEdgeHoleExtractorParams(root[
"blobParams"],
227 if (root.isMember(
"imu")) {
228 Json::Value
const &imu = root[
"imu"];
229 getOptionalParameter(config.
imu.path, imu,
"path");
235 "orientationVariance");
236 getOptionalParameter(config.
imu.orientationMicrosecondsOffset, imu,
237 "orientationMicrosecondsOffset");
239 "useAngularVelocity");
241 "angularVelocityVariance");
242 getOptionalParameter(config.
imu.angularVelocityMicrosecondsOffset,
243 imu,
"angularVelocityMicrosecondsOffset");
251 #endif // INCLUDED_ConfigurationParser_h_GUID_933C79EE_3392_4C8D_74D5_D9A72580DA6A
bool streamBeaconDebugInfo
When true, will stream debug info (variance, pixel measurement, pixel residual) on up to the first 34...
Definition: ConfigParams.h:213
double linearVelocityDecayCoefficient
The value used in exponential decay of linear velocity: it'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
bool includeRearPanel
If true, this will replace the two sensors with just a single one, including the beacons at the back ...
Definition: ConfigParams.h:183
int numThreads
How many threads to let OpenCV use.
Definition: ConfigParams.h:141
float boundingBoxFilterRatio
This should be the ratio of lengths of sides that you'll permit to be filtered in.
Definition: ConfigParams.h:219
std::string calibrationFile
If non-empty, the file to load (or save to) for calibration data.
Definition: ConfigParams.h:251
double highResidualVariancePenalty
This is the multiplicative penalty applied to the variance of measurements with a "bad" residual...
Definition: ConfigParams.h:208
bool logUsableLeds
For recording tuning data - whether we should record the data from just the usable LEDs each frame af...
Definition: ConfigParams.h:97
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
double backPanelMeasurementError
This used to be different than the other beacons, but now it's mostly the same.
Definition: ConfigParams.h:198
std::pair< boost::optional< EnumType >, boost::optional< std::string > > getEnumFromStringParameter(Json::Value const &root, const char memberName[], StringifyFunctor &&stringifyEnum, std::initializer_list< EnumType > const &possibleValues)
Definition: ConfigurationParser.h:58
double noBeaconLinearVelocityDecayCoefficient
The value used in an additional exponential decay of linear velocity when we've lost sight of all bea...
Definition: ConfigParams.h:162
ConfigParams parseConfigParams(Json::Value const &root)
Definition: ConfigurationParser.h:88
BlobParams blobParams
Parameters specific to the blob-detection step of the algorithm.
Definition: ConfigParams.h:102
double manualBeaconOffset[3]
Manual beacon offset (in m) - only really sensible if you only have one target, only used if offsetTo...
Definition: ConfigParams.h:177
double initialBeaconError
Initial beacon error for autocalibration (units: m^2).
Definition: ConfigParams.h:130
bool offsetToCentroid
Whether the tracking algorithm internally adjusts beacon positions based on the centroid of the input...
Definition: ConfigParams.h:173
bool extraVerbose
Extra verbose developer debugging messages.
Definition: ConfigParams.h:247
bool isNull(PathElement const &elt)
Returns true if the path element provided is a NullElement.
Definition: PathElementTools.cpp:87
bool logRawBlobs
For recording tuning data - whether we should record the raw blob data.
Definition: ConfigParams.h:93
double blobMoveThreshold
Maximum distance a blob can move, in multiples of its previous "keypoint diameter", and still be considered the same blob.
Definition: ConfigParams.h:134
IMUInputParams imu
IMU input-related parameters.
Definition: ConfigParams.h:254
BuiltInTargetSets targetSet
When using hard-coded target sets, which one to use.
Definition: ConfigParams.h:108
General configuration parameters.
Definition: ConfigParams.h:82
double beaconProcessNoise
This is the process-model noise in the beacon-auto-calibration, in mm^2/s.
Definition: ConfigParams.h:204
bool permitKalman
Should we permit the whole system to enter Kalman mode? Not doing so is usually a bad idea...
Definition: ConfigParams.h:266
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
void getOptionalParameter(T &dest, Json::Value const &obj, const char *key)
Gets an optional parameter from a JSON object: if it's not present, the existing value is left there...
Definition: GetOptionalParameter.h:60
double cameraPosition[3]
x, y, z, with y up, all in meters.
Definition: ConfigParams.h:257
bool shouldSkipBrightLeds
Should we attempt to skip bright-mode LEDs? The alternative is to just give them slightly higher vari...
Definition: ConfigParams.h:229
bool softResets
Should we permit a reset to be "soft" (blended by a Kalman) rather than a hard state setting...
Definition: ConfigParams.h:275
bool highGain
Should we open the camera in high-gain mode?
Definition: ConfigParams.h:116
bool debug
Whether to show the debug windows and debug messages.
Definition: ConfigParams.h:137
double measurementVarianceScaleFactor
The measurement variance (units: m^2) is included in the plugin along with the coordinates of the bea...
Definition: ConfigParams.h:169
double headCircumference
Head circumference at the head strap, in cm - 55.75 is our estimate for an average based on some hat ...
Definition: ConfigParams.h:188
double softResetPositionVarianceScale
Soft reset data incorporation parameter: Positional variance scale - multiplied by the square of the ...
Definition: ConfigParams.h:279
double additionalPrediction
Seconds beyond the current time to predict, using the Kalman state.
Definition: ConfigParams.h:119
bool continuousReporting
Should we have the tracking thread update the reporting vector for every (IMU) message, instead of waiting/buffering for a few milliseconds between updates?
Definition: ConfigParams.h:113
bool blobsKeepIdentity
If this option is set to true, then while some of the pattern identifier is run each frame...
Definition: ConfigParams.h:244
std::int32_t cameraMicrosecondsOffset
Time offset for the camera timestamp, in microseconds.
Definition: ConfigParams.h:270
double maxZComponent
This should be a negative number - it's the largest the z component of the camera-space LED emission ...
Definition: ConfigParams.h:225
bool cameraIsForward
Whether we should adjust transforms to assume the camera looks along the YZ plane in the +Z direction...
Definition: ConfigParams.h:261
double headToFrontBeaconOriginDistance
This is the distance fron the front of the head to the origin of the front sensor coordinate system i...
Definition: ConfigParams.h:194
double softResetOrientationVariance
Soft reset data incorporation parameter: Orientation variance.
Definition: ConfigParams.h:282
double angularVelocityDecayCoefficient
The value used in exponential decay of angular velocity: it's the proportion of that velocity remaini...
Definition: ConfigParams.h:156
EdgeHoleParams extractParams
Parameters specific to the edge hole based LED extraction algorithm.
Definition: ConfigParams.h:105