d/wmr: Split out inertial sensor configuration

Inertial sensor configuration blocks are common to
both HMD and controller calibration. Factor out a
shared structure to receive them.
This commit is contained in:
Jan Schmidt 2021-12-03 04:48:50 +11:00
parent 76c18bfdc7
commit 385a3bd33d
3 changed files with 16 additions and 11 deletions

View file

@ -36,9 +36,9 @@ wmr_hmd_config_init_defaults(struct wmr_hmd_config *c)
// initialize default sensor transforms
math_pose_identity(&c->eye_params[0].pose);
math_pose_identity(&c->eye_params[1].pose);
math_pose_identity(&c->accel_pose);
math_pose_identity(&c->gyro_pose);
math_pose_identity(&c->mag_pose);
math_pose_identity(&c->sensors.accel_pose);
math_pose_identity(&c->sensors.gyro_pose);
math_pose_identity(&c->sensors.mag_pose);
}
static void
@ -170,7 +170,7 @@ wmr_config_parse_display(struct wmr_hmd_config *c, cJSON *display, enum u_loggin
}
static bool
wmr_config_parse_inertial_sensor(struct wmr_hmd_config *c, cJSON *sensor, enum u_logging_level log_level)
wmr_inertial_sensors_config_parse(struct wmr_inertial_sensors_config *c, cJSON *sensor, enum u_logging_level log_level)
{
struct xrt_pose *out_pose;
@ -361,7 +361,7 @@ wmr_config_parse_calibration(struct wmr_hmd_config *c, cJSON *calib_info, enum u
cJSON_ArrayForEach(item, sensors)
{
if (!wmr_config_parse_inertial_sensor(c, item, log_level)) {
if (!wmr_inertial_sensors_config_parse(&c->sensors, item, log_level)) {
WMR_WARN(log_level, "Error parsing InertialSensor entry");
}
}

View file

@ -105,14 +105,19 @@ struct wmr_camera_config
struct wmr_distortion_6KT distortion6KT;
};
struct wmr_inertial_sensors_config
{
struct xrt_pose accel_pose;
struct xrt_pose gyro_pose;
struct xrt_pose mag_pose;
};
struct wmr_hmd_config
{
/* Left and Right eye mapping and distortion params */
struct wmr_distortion_eye_config eye_params[2];
struct xrt_pose accel_pose;
struct xrt_pose gyro_pose;
struct xrt_pose mag_pose;
struct wmr_inertial_sensors_config sensors;
int n_cameras;
struct wmr_camera_config cameras[WMR_MAX_CAMERAS];

View file

@ -996,11 +996,11 @@ wmr_hmd_create(enum wmr_headset_type hmd_type,
math_pose_transform(&wh->centerline, &wh->display_to_centerline[dIdx],
&wh->display_to_centerline[dIdx]);
}
math_pose_invert(&wh->config.accel_pose, &wh->accel_to_centerline);
math_pose_invert(&wh->config.sensors.accel_pose, &wh->accel_to_centerline);
math_pose_transform(&wh->centerline, &wh->accel_to_centerline, &wh->accel_to_centerline);
math_pose_invert(&wh->config.gyro_pose, &wh->gyro_to_centerline);
math_pose_invert(&wh->config.sensors.gyro_pose, &wh->gyro_to_centerline);
math_pose_transform(&wh->centerline, &wh->gyro_to_centerline, &wh->gyro_to_centerline);
math_pose_invert(&wh->config.mag_pose, &wh->mag_to_centerline);
math_pose_invert(&wh->config.sensors.mag_pose, &wh->mag_to_centerline);
math_pose_transform(&wh->centerline, &wh->mag_to_centerline, &wh->mag_to_centerline);
struct u_device_simple_info info;