aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Berger <jdavidberger@gmail.com>2018-06-29 21:17:37 +0000
committerJustin Berger <jdavidberger@gmail.com>2018-06-29 21:17:37 +0000
commit69f5ef52d73f653ac557e3d7ce883d509efd8fdd (patch)
treec61f3e541f4c10b950512c1f5bcd5711d7da1f00 /src
parent4d7c4e6033f3a7399e4f6352f9c471ee1d762ae9 (diff)
downloadlibsurvive-69f5ef52d73f653ac557e3d7ce883d509efd8fdd.tar.gz
libsurvive-69f5ef52d73f653ac557e3d7ce883d509efd8fdd.tar.bz2
Read in tracker imu ref from json
Diffstat (limited to 'src')
-rw-r--r--src/survive_default_devices.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/survive_default_devices.c b/src/survive_default_devices.c
index 76e8f36..c9d1f7f 100644
--- a/src/survive_default_devices.c
+++ b/src/survive_default_devices.c
@@ -96,6 +96,14 @@ static int ParsePoints(SurviveContext *ctx, SurviveObject *so, char *ct0conf,
return 0;
}
+static void vive_json_pose_to_survive_pose(const FLT *values, SurvivePose *pose) {
+ for (int i = 0; i < 3; i++) {
+ pose->Pos[i] = values[4 + i];
+ pose->Rot[1 + i] = values[i];
+ }
+ pose->Rot[0] = values[3];
+}
+
int survive_load_htc_config_format(SurviveObject *so, char *ct0conf, int len) {
if (len == 0)
return -1;
@@ -119,6 +127,7 @@ int survive_load_htc_config_format(SurviveObject *so, char *ct0conf, int len) {
for (i = 1; i < r; i++) {
jsmntok_t *tk = &t[i];
+ /*
char ctxo[100];
int ilen = tk->end - tk->start;
if (ilen > 99)
@@ -126,49 +135,53 @@ int survive_load_htc_config_format(SurviveObject *so, char *ct0conf, int len) {
memcpy(ctxo, ct0conf + tk->start, ilen);
ctxo[ilen] = 0;
- // printf( "%d / %d / %d / %d %s %d\n", tk->type, tk->start,
+ //printf( "%d / %d / %d / %d %s %d\n", tk->type, tk->start,
//tk->end, tk->size, ctxo, jsoneq(ct0conf, &t[i], "modelPoints") );
// printf( "%.*s\n", ilen, ct0conf + tk->start );
-
+ */
if (jsoneq(ct0conf, tk, "modelPoints") == 0) {
if (ParsePoints(ctx, so, ct0conf, &so->sensor_locations, t, i)) {
break;
}
- }
- if (jsoneq(ct0conf, tk, "modelNormals") == 0) {
+ } else if (jsoneq(ct0conf, tk, "modelNormals") == 0) {
if (ParsePoints(ctx, so, ct0conf, &so->sensor_normals, t, i)) {
break;
}
}
- if (jsoneq(ct0conf, tk, "acc_bias") == 0) {
+ else if (jsoneq(ct0conf, tk, "acc_bias") == 0) {
int32_t count = (tk + 1)->size;
FLT *values = NULL;
if (parse_float_array(ct0conf, tk + 2, &values, count) > 0) {
so->acc_bias = values;
}
- }
- if (jsoneq(ct0conf, tk, "acc_scale") == 0) {
+ } else if (jsoneq(ct0conf, tk, "acc_scale") == 0) {
int32_t count = (tk + 1)->size;
FLT *values = NULL;
if (parse_float_array(ct0conf, tk + 2, &values, count) > 0) {
so->acc_scale = values;
}
- }
-
- if (jsoneq(ct0conf, tk, "gyro_bias") == 0) {
+ } else if (jsoneq(ct0conf, tk, "gyro_bias") == 0) {
int32_t count = (tk + 1)->size;
FLT *values = NULL;
if (parse_float_array(ct0conf, tk + 2, &values, count) > 0) {
so->gyro_bias = values;
}
- }
- if (jsoneq(ct0conf, tk, "gyro_scale") == 0) {
+ } else if (jsoneq(ct0conf, tk, "gyro_scale") == 0) {
int32_t count = (tk + 1)->size;
FLT *values = NULL;
if (parse_float_array(ct0conf, tk + 2, &values, count) > 0) {
so->gyro_scale = values;
}
+ } else if (jsoneq(ct0conf, tk, "trackref_from_imu") == 0) {
+ int32_t count = (tk + 1)->size;
+ if (count == 7) {
+ FLT *values = NULL;
+ if (parse_float_array(ct0conf, tk + 2, &values, count) > 0) {
+ vive_json_pose_to_survive_pose(values, &so->relative_imu_pose);
+ free(values);
+ }
+ }
}
}