From 17e06b4822e60ccca865e77b45bf2b52a26852f2 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 23 Mar 2018 14:42:53 +0000 Subject: Made picking posers more consistent / configposer can use short name --- src/survive.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index e6bf69f..a8e7b94 100644 --- a/src/survive.c +++ b/src/survive.c @@ -199,7 +199,8 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { return ctx; } -static void *setup_func_by_name(SurviveContext *ctx, const char *name, const char *configname, const char *configdef) { +void *GetDriverByConfig(SurviveContext *ctx, const char *name, const char *configname, const char *configdef, + int verbose) { const char *Preferred = survive_configs(ctx, configname, SC_SETCONFIG, configdef); const char *DriverName = 0; const char *picked = 0; @@ -207,12 +208,14 @@ static void *setup_func_by_name(SurviveContext *ctx, const char *name, const cha void *func = 0; int prefixLen = strlen(name); - SV_INFO("Available %s:", name); + if (verbose > 1) + SV_INFO("Available %s:", name); while ((DriverName = GetDriverNameMatching(name, i++))) { void *p = GetDriver(DriverName); bool match = strcmp(DriverName, Preferred) == 0 || strcmp(DriverName + prefixLen, Preferred) == 0; - SV_INFO("\t%c%s", match ? '*' : ' ', DriverName + prefixLen); + if (verbose > 1) + SV_INFO("\t%c%s", match ? '*' : ' ', DriverName + prefixLen); if (!func || match) { func = p; picked = (DriverName + prefixLen); @@ -221,7 +224,10 @@ static void *setup_func_by_name(SurviveContext *ctx, const char *name, const cha if (!func) { SV_ERROR("Error. Cannot find any valid %s.", name); } - SV_INFO("Totals %d %ss. Using %s.", i - 1, name, picked); + if (verbose > 1) + SV_INFO("Totals %d %ss.", i - 1, name); + if (verbose > 0) + SV_INFO("Using %s for %s", name, configname); return func; } @@ -230,6 +236,8 @@ int survive_startup(SurviveContext *ctx) { int r = 0; int i = 0; + survive_install_recording(ctx); + // initialize the button queue memset(&(ctx->buttonQueue), 0, sizeof(ctx->buttonQueue)); ctx->buttonQueue.buttonservicesem = OGCreateSema(); @@ -237,15 +245,13 @@ int survive_startup(SurviveContext *ctx) { // start the thread to process button data ctx->buttonservicethread = OGCreateThread(button_servicer, ctx); - PoserCB PreferredPoserCB = setup_func_by_name(ctx, "Poser", "defaultposer", "PoserTurveyTori"); - ctx->lightcapfunction = setup_func_by_name(ctx, "Disambiguator", "disambiguator", "Turvey"); + PoserCB PreferredPoserCB = GetDriverByConfig(ctx, "Poser", "defaultposer", "TurveyTori", 2); + ctx->lightcapfunction = GetDriverByConfig(ctx, "Disambiguator", "disambiguator", "Turvey", 2); const char *DriverName; i = 0; - survive_install_recording(ctx); - while ((DriverName = GetDriverNameMatching("DriverReg", i++))) { DeviceDriver dd = GetDriver(DriverName); SV_INFO("Loading driver %s (%p) (%d)", DriverName, dd, i); -- cgit v1.2.3 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 --- src/survive.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/survive.c') 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; } -- cgit v1.2.3 From 378b6e58d4cb0e9873062cfabefa271e43794bd6 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 23 Mar 2018 16:19:22 +0000 Subject: Broadcast lighthouse position at startup --- src/survive.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 3f3b844..1786d45 100644 --- a/src/survive.c +++ b/src/survive.c @@ -294,6 +294,13 @@ int survive_startup(SurviveContext *ctx) { } } + // If lighthouse positions are known, broadcast them + for (int i = 0; i < ctx->activeLighthouses; i++) { + if(ctx->bsd[i].PositionSet) { + ctx->lighthouseposeproc(ctx, i, &ctx->bsd[i].Pose, 0); + } + } + return 0; } -- cgit v1.2.3 From d5c42c4951261c401c5f9148ce2d6bb1402ce75b Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sat, 24 Mar 2018 10:13:23 -0600 Subject: Some minor fixups around command line processing --- src/survive.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 1786d45..807e82f 100644 --- a/src/survive.c +++ b/src/survive.c @@ -177,7 +177,10 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { fprintf(stderr, " -p [poser] - use a specific defaultposer.\n"); fprintf(stderr, " -l [lighthouse count] - use a specific number of lighthoses.\n"); fprintf(stderr, " -c [config file] - set config file\n"); - fprintf(stderr, " -p [lighthouse count] - use a specific number of lighthoses.\n"); + fprintf(stderr, " --record [log file] - Write all events to the given record file.\n"); + fprintf(stderr, " --playback [log file] - Read events from the given file instead of USB devices.\n"); + fprintf(stderr, " --playback-factor [f] - Time factor of playback -- 1 is run at the same timing as " + "original, 0 is run as fast as possible.\n"); return 0; } -- cgit v1.2.3 From c17ac29dcdb617f5d9d960e432a628747e0e63df Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sat, 24 Mar 2018 10:26:53 -0600 Subject: Added support for flags on command-line --- src/survive.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 807e82f..73d6474 100644 --- a/src/survive.c +++ b/src/survive.c @@ -159,11 +159,18 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { } if (vartoupdate) { - if (av + 1 == argvend) { - fprintf(stderr, "Error: expected parameter after %s\n", *av); - showhelp = 1; + const char *name = *av + 2; // Skip the '--'; + bool flagArgument = (av + 1 == argvend) || av[1][0] == '-'; + + if (flagArgument) { + bool value = strncmp("no-", name, 3) != 0; + if (value == 0) { + name += 3; // Skip "no-" + } + survive_configi(ctx, name, SC_OVERRIDE | SC_SET, value); } else { - survive_configs(ctx, *av + 2, SC_OVERRIDE | SC_SET, *(av + 1)); + const char *value = *(av + 1); + survive_configs(ctx, name, SC_OVERRIDE | SC_SET, value); av++; } } @@ -273,7 +280,7 @@ 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); + int calibrateForbidden = survive_configi(ctx, "calibrate", SC_GET, 1) == 0; if (calibrateMandatory && calibrateForbidden) { SV_INFO("Contradictory settings --calibrate and --no-calibrate specified. Switching to normal behavior."); calibrateMandatory = calibrateForbidden = 0; @@ -288,6 +295,8 @@ int survive_startup(SurviveContext *ctx) { 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"); + } else { + SV_INFO("Calibration requested. Previous calibration will be overwritten."); } bool doCalibrate = isCalibrated == false || calibrateMandatory; -- cgit v1.2.3 From 3963b2bfe6954bf647d112b2a435910baa5529b2 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Mon, 26 Mar 2018 19:22:54 -0600 Subject: Fixed text in menu text --- src/survive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 73d6474..899d206 100644 --- a/src/survive.c +++ b/src/survive.c @@ -219,7 +219,7 @@ void *GetDriverByConfig(SurviveContext *ctx, const char *name, const char *confi int prefixLen = strlen(name); if (verbose > 1) - SV_INFO("Available %s:", name); + SV_INFO("Available %ss:", name); while ((DriverName = GetDriverNameMatching(name, i++))) { void *p = GetDriver(DriverName); @@ -237,7 +237,7 @@ void *GetDriverByConfig(SurviveContext *ctx, const char *name, const char *confi if (verbose > 1) SV_INFO("Totals %d %ss.", i - 1, name); if (verbose > 0) - SV_INFO("Using %s for %s", name, configname); + SV_INFO("Using '%s' for %s", picked, configname); return func; } -- cgit v1.2.3 From 91f0cab811e983da63ea49f6e24afae283138a1c Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Wed, 28 Mar 2018 20:36:05 -0600 Subject: Functional C# in windows --- src/survive.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 899d206..f46f128 100644 --- a/src/survive.c +++ b/src/survive.c @@ -111,6 +111,11 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) MANUAL_DRIVER_REGISTRATION(PoserDummy) MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) + MANUAL_DRIVER_REGISTRATION(DriverRegPlayback) + + MANUAL_DRIVER_REGISTRATION(DisambiguatorCharles) + MANUAL_DRIVER_REGISTRATION(DisambiguatorStateBased) + MANUAL_DRIVER_REGISTRATION(DisambiguatorTurvey) #endif SurviveContext *ctx = calloc(1, sizeof(SurviveContext)); -- cgit v1.2.3 From 08cc0afc797d2225cf23fbc785e6a28cc8667285 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Wed, 28 Mar 2018 21:52:00 -0600 Subject: Nuget packaged up dependencies --- src/survive.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index f46f128..23b1e4c 100644 --- a/src/survive.c +++ b/src/survive.c @@ -110,6 +110,9 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow) MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) MANUAL_DRIVER_REGISTRATION(PoserDummy) + MANUAL_DRIVER_REGISTRATION(PoserEPNP) + MANUAL_DRIVER_REGISTRATION(PoserSBA) + MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) MANUAL_DRIVER_REGISTRATION(DriverRegPlayback) @@ -260,7 +263,7 @@ int survive_startup(SurviveContext *ctx) { // start the thread to process button data ctx->buttonservicethread = OGCreateThread(button_servicer, ctx); - PoserCB PreferredPoserCB = GetDriverByConfig(ctx, "Poser", "defaultposer", "TurveyTori", 2); + PoserCB PreferredPoserCB = GetDriverByConfig(ctx, "Poser", "defaultposer", "SBA", 2); ctx->lightcapfunction = GetDriverByConfig(ctx, "Disambiguator", "disambiguator", "Turvey", 2); const char *DriverName; -- cgit v1.2.3 From 52bcccaea5de63a4de4b3df17236507455776409 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 30 Mar 2018 09:50:24 -0600 Subject: Added accessors for language bindings --- src/survive.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 23b1e4c..b359669 100644 --- a/src/survive.c +++ b/src/survive.c @@ -551,4 +551,9 @@ int survive_simple_inflate(struct SurviveContext *ctx, const char *input, int in return len; } +const char *survive_object_codename(SurviveObject *so) { return so->codename; } +int8_t survive_object_sensor_ct(SurviveObject *so) { return so->sensor_ct; } +const FLT *survive_object_sensor_locations(SurviveObject *so) { return so->sensor_locations; } +const FLT *survive_object_sensor_normals(SurviveObject *so) { return so->sensor_normals; } + #endif -- cgit v1.2.3 From 053750ef27c996822512f75f55c0110f573eccd6 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 30 Mar 2018 12:33:11 -0600 Subject: Made manual driver registration only ever happen once --- src/survive.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index b359669..a15e0ed 100644 --- a/src/survive.c +++ b/src/survive.c @@ -36,8 +36,8 @@ static void survivefault(struct SurviveContext *ctx, const char *fault) { } static void survivenote(struct SurviveContext *ctx, const char *fault) { - survive_recording_info_process(ctx, fault); - fprintf(stderr, "Info: %s\n", fault); + survive_recording_info_process(ctx, fault); + fprintf(stderr, "Info: %s\n", fault); } static void *button_servicer(void *context) { @@ -86,8 +86,9 @@ void survive_verify_FLT_size(uint32_t user_size) { if (sizeof(FLT) != user_size) { fprintf(stderr, "FLT type incompatible; the shared library libsurvive has FLT size %lu vs user program %u\n", (unsigned long)sizeof(FLT), user_size); - fprintf(stderr, "Add '#define FLT %s' before including survive.h or recompile the shared library with the " - "appropriate flag. \n", + fprintf(stderr, + "Add '#define FLT %s' before including survive.h or recompile the shared library with the " + "appropriate flag. \n", sizeof(FLT) == sizeof(double) ? "double" : "float"); exit(-1); } @@ -101,24 +102,28 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { } #endif #ifdef MANUAL_REGISTRATION -// note: this manual registration is currently only in use on builds using Visual Studio. + // note: this manual registration is currently only in use on builds using Visual Studio. + static int did_manual_driver_registration = 0; + if (did_manual_driver_registration == 0) { #define MANUAL_DRIVER_REGISTRATION(func) \ int func(SurviveObject *so, PoserData *pd); \ RegisterDriver(#func, &func); - MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow) - MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) - MANUAL_DRIVER_REGISTRATION(PoserDummy) - MANUAL_DRIVER_REGISTRATION(PoserEPNP) - MANUAL_DRIVER_REGISTRATION(PoserSBA) + MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow) + MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) + MANUAL_DRIVER_REGISTRATION(PoserDummy) + MANUAL_DRIVER_REGISTRATION(PoserEPNP) + MANUAL_DRIVER_REGISTRATION(PoserSBA) - MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) - MANUAL_DRIVER_REGISTRATION(DriverRegPlayback) + MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) + MANUAL_DRIVER_REGISTRATION(DriverRegPlayback) - MANUAL_DRIVER_REGISTRATION(DisambiguatorCharles) - MANUAL_DRIVER_REGISTRATION(DisambiguatorStateBased) - MANUAL_DRIVER_REGISTRATION(DisambiguatorTurvey) + MANUAL_DRIVER_REGISTRATION(DisambiguatorCharles) + MANUAL_DRIVER_REGISTRATION(DisambiguatorStateBased) + MANUAL_DRIVER_REGISTRATION(DisambiguatorTurvey) + did_manual_driver_registration = 1; + } #endif SurviveContext *ctx = calloc(1, sizeof(SurviveContext)); @@ -316,9 +321,9 @@ int survive_startup(SurviveContext *ctx) { // If lighthouse positions are known, broadcast them for (int i = 0; i < ctx->activeLighthouses; i++) { - if(ctx->bsd[i].PositionSet) { - ctx->lighthouseposeproc(ctx, i, &ctx->bsd[i].Pose, 0); - } + if (ctx->bsd[i].PositionSet) { + ctx->lighthouseposeproc(ctx, i, &ctx->bsd[i].Pose, 0); + } } return 0; -- cgit v1.2.3 From 22d40fb360fdb65da7916fb87f9b199f4f401f05 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sun, 1 Apr 2018 07:52:00 -0600 Subject: overhal to calibration --- src/survive.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index a15e0ed..63ad2ba 100644 --- a/src/survive.c +++ b/src/survive.c @@ -219,6 +219,8 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { ctx->configfunction = survive_default_htc_config_process; ctx->rawposeproc = survive_default_raw_pose_process; + ctx->calibration_flag = (enum SurviveCalFlag)survive_configi(ctx, "bsd-cal", SC_GET, SVCal_All); + return ctx; } -- cgit v1.2.3 From 47c7fb15182700fb403894f65beaf143a7fad6ab Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sun, 1 Apr 2018 12:23:48 -0600 Subject: Tweaked how reproject / calibate interact --- src/survive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/survive.c') diff --git a/src/survive.c b/src/survive.c index 63ad2ba..2a7aad1 100644 --- a/src/survive.c +++ b/src/survive.c @@ -219,7 +219,8 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { ctx->configfunction = survive_default_htc_config_process; ctx->rawposeproc = survive_default_raw_pose_process; - ctx->calibration_flag = (enum SurviveCalFlag)survive_configi(ctx, "bsd-cal", SC_GET, SVCal_All); + ctx->calibration_config = survive_calibration_config_ctor(); + ctx->calibration_config.use_flag = (enum SurviveCalFlag)survive_configi(ctx, "bsd-cal", SC_GET, SVCal_All); return ctx; } -- cgit v1.2.3