aboutsummaryrefslogtreecommitdiff
path: root/src/survive_cal.c
diff options
context:
space:
mode:
authormwturvey <michael.w.turvey@intel.com>2017-03-23 12:13:44 -0700
committermwturvey <michael.w.turvey@intel.com>2017-03-23 12:13:44 -0700
commitf33018188bf5bdf6f6b8af0d646e3f8c519d9d71 (patch)
treeb94e358bcf65076fb533cd26efdc95fe21753102 /src/survive_cal.c
parent78b7b6fb520c287caecbe895501898ef5c1440a5 (diff)
downloadlibsurvive-f33018188bf5bdf6f6b8af0d646e3f8c519d9d71.tar.gz
libsurvive-f33018188bf5bdf6f6b8af0d646e3f8c519d9d71.tar.bz2
Added support for empty string in config.json & other cleanup.
Diffstat (limited to 'src/survive_cal.c')
-rwxr-xr-xsrc/survive_cal.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/src/survive_cal.c b/src/survive_cal.c
index 19eb3ca..f9ec595 100755
--- a/src/survive_cal.c
+++ b/src/survive_cal.c
@@ -124,50 +124,42 @@ void survive_cal_install( struct SurviveContext * ctx )
cd->numPoseObjects = 0;
- for (int i=0; i < ctx->objs_ct; i++)
+ const char * RequiredTrackersForCal = config_read_str( ctx->global_config_values, "RequiredTrackersForCal", "HMD,WM0,WM1" );
+ const uint32_t AllowAllTrackersForCal = config_read_uint32( ctx->global_config_values, "AllowAllTrackersForCal", 0 );
+ size_t requiredTrackersFound = 0;
+
+ for (int j=0; j < ctx->objs_ct; j++)
{
- // This would be a place where we could conditionally decide if we
- // want to include a certain device in the calibration routine.
- if (1)
+ // Add the tracker if we allow all trackers for calibration, or if it's in the list
+ // of required trackers.
+ int isRequiredTracker = strstr(RequiredTrackersForCal, ctx->objs[j]->codename) != NULL;
+
+ if (isRequiredTracker)
{
- cd->poseobjects[i] = ctx->objs[i];
+ requiredTrackersFound++;
+ }
+
+ if (AllowAllTrackersForCal || isRequiredTracker)
+ {
+ cd->poseobjects[j] = ctx->objs[j];
cd->numPoseObjects++;
- SV_INFO("Calibration is using %s", cd->poseobjects[i]->codename);
+ SV_INFO("Calibration is using %s", cd->poseobjects[j]->codename);
}
+
}
// If we want to mandate that certain devices have been found
-
-
- //cd->poseobjects[0] = survive_get_so_by_name( ctx, "HMD" );
- //cd->poseobjects[1] = survive_get_so_by_name( ctx, "WM0" );
- //cd->poseobjects[2] = survive_get_so_by_name( ctx, "WM1" );
-
- //if( cd->poseobjects[0] == 0 || cd->poseobjects[1] == 0 || cd->poseobjects[2] == 0 )
- //{
- // SV_ERROR( "Error: cannot find all devices needed for calibration." );
- // free( cd );
- // return;
- //}
-
-//XXX TODO MWTourney, work on your code here.
-/*
- if( !cd->hmd )
+ if (strlen(RequiredTrackersForCal) > 0)
{
- cd->hmd = survive_get_so_by_name( ctx, "TR0" );
-
- if( !cd->hmd )
+ if (requiredTrackersFound != ((strlen(RequiredTrackersForCal) + 1) / 4))
{
- SV_ERROR( "Error: cannot find any devices labeled HMD. Required for calibration" );
+ SV_ERROR( "Error: cannot find all devices needed for calibration." );
free( cd );
return;
}
- SV_INFO( "HMD not found, calibrating using Tracker" );
}
-*/
-
const char * DriverName;
const char * PreferredPoser = config_read_str( ctx->global_config_values, "ConfigPoser", "PoserCharlesSlow" );