From d475a433ec40f335fa0bffdf774bac4c69d7fc10 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 23 Mar 2018 14:43:32 +0000 Subject: Made calibration installation driveable from the command line; also turns on if there is no calibration --- data_recorder.c | 4 ---- src/survive.c | 25 +++++++++++++++++++++++++ src/survive_cal.c | 3 +++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/data_recorder.c b/data_recorder.c index eef233d..427a953 100644 --- a/data_recorder.c +++ b/data_recorder.c @@ -17,10 +17,6 @@ int main(int argc, char **argv) { } survive_startup(ctx); - if (survive_configi(ctx, "calibrate", SC_GET, 1)) { - SV_INFO("Installing calibration"); - survive_cal_install(ctx); - } while (survive_poll(ctx) == 0) { } diff --git a/src/survive.c b/src/survive.c index a8e7b94..3f3b844 100644 --- a/src/survive.c +++ b/src/survive.c @@ -269,6 +269,31 @@ int survive_startup(SurviveContext *ctx) { ctx->state = SURVIVE_RUNNING; + int calibrateMandatory = survive_configi(ctx, "calibrate", SC_GET, 0); + int calibrateForbidden = survive_configi(ctx, "no-calibrate", SC_GET, 0); + if (calibrateMandatory && calibrateForbidden) { + SV_INFO("Contradictory settings --calibrate and --no-calibrate specified. Switching to normal behavior."); + calibrateMandatory = calibrateForbidden = 0; + } + + if (!calibrateForbidden) { + bool isCalibrated = true; + for (int i = 0; i < ctx->activeLighthouses; i++) { + isCalibrated &= ctx->bsd[i].PositionSet; + } + + if (!isCalibrated) { + SV_INFO("Uncalibrated configuration detected. Attaching calibration. Please don't move tracked objects for " + "the duration of calibration. Pass '--no-calibrate' to skip calibration"); + } + + bool doCalibrate = isCalibrated == false || calibrateMandatory; + + if (doCalibrate) { + survive_cal_install(ctx); + } + } + return 0; } diff --git a/src/survive_cal.c b/src/survive_cal.c index c94bd0d..218f5c1 100755 --- a/src/survive_cal.c +++ b/src/survive_cal.c @@ -116,6 +116,9 @@ int survive_cal_get_status( struct SurviveContext * ctx, char * description, int void survive_cal_install( struct SurviveContext * ctx ) { + if (ctx->calptr) + return; + int i; struct SurviveCalData * cd = ctx->calptr = calloc( 1, sizeof( struct SurviveCalData ) ); -- cgit v1.2.3