d/wmr: Make WMR to OpenXR coordinate transform explicit

Instead of negating Y and Z readings from the IMU when
parsing, parse the native values, then apply the rotation
using the centerline transform before fusion.
This commit is contained in:
Jan Schmidt 2021-12-04 23:21:25 +11:00
parent c7549c8680
commit c06c3fa782
2 changed files with 14 additions and 5 deletions
src/xrt/drivers/wmr

View file

@ -984,7 +984,9 @@ wmr_hmd_create(enum wmr_headset_type hmd_type,
u_var_add_gui_header(wh, &wh->gui.misc, "Misc");
u_var_add_log_level(wh, &wh->log_level, "log_level");
// Compute centerline in the HMD's calibration coordinate space as the average of the two display poses
// Compute centerline in the HMD's calibration coordinate space as the average of the two display poses,
// then rotate around the X axis to convert coordinate system from WMR (X right, Y down, Z away)
// to OpenXR (X right, Y up, Z towards)
math_quat_slerp(&wh->config.eye_params[0].pose.orientation, &wh->config.eye_params[1].pose.orientation, 0.5f,
&wh->centerline.orientation);
wh->centerline.position.x =
@ -994,6 +996,13 @@ wmr_hmd_create(enum wmr_headset_type hmd_type,
wh->centerline.position.z =
(wh->config.eye_params[0].pose.position.z + wh->config.eye_params[1].pose.position.z) * 0.5f;
struct xrt_pose wmr_to_openxr_xform = {
.position = {0.0, 0.0, 0.0},
.orientation = {.x = 1.0, .y = 0.0, .z = 0.0, .w = 0.0},
};
math_pose_transform(&wmr_to_openxr_xform, &wh->centerline, &wh->centerline);
// Compute display and sensor offsets relative to the centerline
for (int dIdx = 0; dIdx < 2; ++dIdx) {
math_pose_invert(&wh->config.eye_params[dIdx].pose, &wh->display_to_centerline[dIdx]);

View file

@ -23,8 +23,8 @@ void
vec3_from_hololens_accel(int32_t sample[3][4], int i, struct xrt_vec3 *out_vec)
{
out_vec->x = (float)sample[0][i] * 0.001f * 1.0f;
out_vec->y = (float)sample[1][i] * 0.001f * -1.0f;
out_vec->z = (float)sample[2][i] * 0.001f * -1.0f;
out_vec->y = (float)sample[1][i] * 0.001f * 1.0f;
out_vec->z = (float)sample[2][i] * 0.001f * 1.0f;
}
void
@ -47,7 +47,7 @@ vec3_from_hololens_gyro(int16_t sample[3][32], int i, struct xrt_vec3 *out_vec)
sample[1][8 * i + 5] + //
sample[1][8 * i + 6] + //
sample[1][8 * i + 7]) *
0.001f * -0.125f;
0.001f * 0.125f;
out_vec->z = (float)(sample[2][8 * i + 0] + //
sample[2][8 * i + 1] + //
sample[2][8 * i + 2] + //
@ -56,5 +56,5 @@ vec3_from_hololens_gyro(int16_t sample[3][32], int i, struct xrt_vec3 *out_vec)
sample[2][8 * i + 5] + //
sample[2][8 * i + 6] + //
sample[2][8 * i + 7]) *
0.001f * -0.125f;
0.001f * 0.125f;
}