aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Berger <j.david.berger@gmail.com>2018-03-22 10:11:22 -0600
committerJustin Berger <j.david.berger@gmail.com>2018-03-22 10:11:22 -0600
commitabb8176f4ef23047a66e416f3f3a6eee6fc7a0c4 (patch)
tree5e2a52a8372aa198ce4a4708ed1ea7e7d5d876ff
parent6f54646482e44051af1d3e2965012888b00e2038 (diff)
downloadlibsurvive-abb8176f4ef23047a66e416f3f3a6eee6fc7a0c4.tar.gz
libsurvive-abb8176f4ef23047a66e416f3f3a6eee6fc7a0c4.tar.bz2
Fixed startup bug; changed config names to be consistent
-rw-r--r--README.md8
-rw-r--r--src/survive.c4
-rw-r--r--src/survive_playback.c18
-rw-r--r--src/survive_playback.h17
-rwxr-xr-xsrc/survive_vive.c2
5 files changed, 36 insertions, 13 deletions
diff --git a/README.md b/README.md
index 518a985..4b18c43 100644
--- a/README.md
+++ b/README.md
@@ -268,25 +268,25 @@ Compiling this minimal example only requires the include path for survive.h as w
As mentioned, only the pose from lighthouse number `0` is used. Since the callback is called for all tracked devices, `so->codename` can be used to differentiate between devices like `HMD`, `WM0`, etc.
-# Playback
+# Record / Playback
libsurvive has an integrated tool that allows you to record and playback streams from all supported devices. To save off a stream, invoke it as follows:
```
make
-./data_recorder -o my_playback_file
+./data_recorder --record my_playback_file
```
This gives you a file -- my_playback_file -- with all the device configurations and events file you need to replay it.
You can also just let it stream to standard output, but this tends to be a lot of information.
-To actually replay it, put that directory path in the 'playbackfile' configuration value in config.json and run libsurvive as usual. Note that this will purposefully stop the USB devices from loading as to not confuse the library with inconsistent data.
+To actually replay it, put that directory path in the 'playback' configuration value in config.json and run libsurvive as usual. Note that this will purposefully stop the USB devices from loading as to not confuse the library with inconsistent data.
You can also replay it just with command line options:
```
-./calibrate --playbackfile my_playback_file
+./calibrate --playback my_playback_file
```
## Playback speed
diff --git a/src/survive.c b/src/survive.c
index 2f3034b..9209e7c 100644
--- a/src/survive.c
+++ b/src/survive.c
@@ -10,6 +10,7 @@
#include "os_generic.h"
#include "survive_config.h"
#include "survive_default_devices.h"
+#include "survive_playback.h"
#ifdef __APPLE__
#define z_const const
@@ -239,6 +240,9 @@ int survive_startup(SurviveContext *ctx) {
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);
diff --git a/src/survive_playback.c b/src/survive_playback.c
index 45eea85..9261bb5 100644
--- a/src/survive_playback.c
+++ b/src/survive_playback.c
@@ -300,9 +300,9 @@ static int playback_close(struct SurviveContext *ctx, void *_driver) {
return 0;
}
-void install_recording(SurviveContext *ctx) {
- const char *dataout_file = survive_configs(ctx, "dataoutfile", SC_SETCONFIG, "");
- int record_to_stdout = survive_configi(ctx, "datastdout", SC_SETCONFIG, 0);
+void survive_install_recording(SurviveContext *ctx) {
+ const char *dataout_file = survive_configs(ctx, "record", SC_SETCONFIG, "");
+ int record_to_stdout = survive_configi(ctx, "record-stdout", SC_SETCONFIG, 0);
if (strlen(dataout_file) > 0 || record_to_stdout) {
ctx->recptr = calloc(1, sizeof(struct SurviveRecordingData));
@@ -314,14 +314,16 @@ void install_recording(SurviveContext *ctx) {
ctx->recptr = 0;
return;
}
+ SV_INFO("Recording to '%s'", dataout_file);
ctx->recptr->alwaysWriteStdOut = record_to_stdout;
+ if (record_to_stdout) {
+ SV_INFO("Recording to stdout");
+ }
}
}
int DriverRegPlayback(SurviveContext *ctx) {
- install_recording(ctx);
-
- const char *playback_file = survive_configs(ctx, "playbackfile", SC_SETCONFIG, "");
+ const char *playback_file = survive_configs(ctx, "playback", SC_SETCONFIG, "");
if (strlen(playback_file) == 0) {
return 0;
@@ -330,7 +332,7 @@ int DriverRegPlayback(SurviveContext *ctx) {
SurvivePlaybackData *sp = calloc(1, sizeof(SurvivePlaybackData));
sp->ctx = ctx;
sp->playback_dir = playback_file;
- sp->time_factor = survive_configf(ctx, "playbackfactor", SC_SETCONFIG, 1.f);
+ sp->time_factor = survive_configf(ctx, "playback-factor", SC_SETCONFIG, 1.f);
printf("%s\n", playback_file);
@@ -341,7 +343,7 @@ int DriverRegPlayback(SurviveContext *ctx) {
return -1;
}
- SV_INFO("Using playback file '%s'", playback_file);
+ SV_INFO("Using playback file '%s' with timefactor of %f", playback_file, sp->time_factor);
SurviveObject *hmd = survive_create_hmd(ctx, "Playback", sp);
SurviveObject *wm0 = survive_create_wm0(ctx, "Playback", sp, 0);
SurviveObject *wm1 = survive_create_wm1(ctx, "Playback", sp, 0);
diff --git a/src/survive_playback.h b/src/survive_playback.h
new file mode 100644
index 0000000..52638a9
--- /dev/null
+++ b/src/survive_playback.h
@@ -0,0 +1,17 @@
+#include <survive.h>
+
+void survive_install_recording(SurviveContext *ctx);
+void survive_recording_config_process(SurviveObject *so, char *ct0conf, int len);
+
+void survive_recording_lighthouse_process(SurviveContext *ctx, uint8_t lighthouse, SurvivePose *lh_pose,
+ SurvivePose *obj);
+
+void survive_recording_raw_pose_process(SurviveObject *so, uint8_t lighthouse, SurvivePose *pose);
+void survive_recording_info_process(SurviveContext *ctx, const char *fault);
+void survive_recording_angle_process(struct SurviveObject *so, int sensor_id, int acode, uint32_t timecode, FLT length,
+ FLT angle, uint32_t lh);
+
+void survive_recording_light_process(struct SurviveObject *so, int sensor_id, int acode, int timeinsweep,
+ uint32_t timecode, uint32_t length, uint32_t lh);
+
+void survive_recording_imu_process(struct SurviveObject *so, int mask, FLT *accelgyro, uint32_t timecode, int id);
diff --git a/src/survive_vive.c b/src/survive_vive.c
index cf068a3..d431207 100755
--- a/src/survive_vive.c
+++ b/src/survive_vive.c
@@ -1720,7 +1720,7 @@ void init_SurviveObject(SurviveObject* so) {
int DriverRegHTCVive( SurviveContext * ctx )
{
- const char *playback_dir = survive_configs(ctx, "playbackfile", SC_SETCONFIG, "");
+ const char *playback_dir = survive_configs(ctx, "playback", SC_SETCONFIG, "");
if(strlen(playback_dir) != 0) {
SV_INFO("Playback is active; disabling USB driver");
return 0;