Monado OpenXR Runtime
wmr_config.h
Go to the documentation of this file.
1/* Copyright 2021 Jan Schmidt
2 * SPDX-License-Identifier: BSL-1.0
3 */
4/*!
5 * @file
6 * @brief WMR and MS HoloLens configuration structures
7 * @author Jan Schmidt <jan@centricular.com>
8 * @ingroup drv_wmr
9 */
10
11#pragma once
12
13#include "math/m_vec2.h"
14#include "math/m_vec3.h"
15#include "util/u_logging.h"
16
17/* Increase this number if anyone releases a headset with
18 * more cameras */
19#define WMR_MAX_CAMERAS 4
20
21/* Increase this number if anyone releases a controller with
22 * more tracking LEDs */
23#define WMR_MAX_LEDS 40
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29enum wmr_distortion_model
30{
31 WMR_DISTORTION_MODEL_UNKNOWN = 0,
32 WMR_DISTORTION_MODEL_POLYNOMIAL_3K,
33 WMR_DISTORTION_MODEL_POLYNOMIAL_6KT,
34};
35
36/* Location is used as camera_id for setting gain */
37enum wmr_camera_location
38{
39 WMR_CAMERA_LOCATION_HT0 = 0,
40 WMR_CAMERA_LOCATION_HT1 = 1,
41 WMR_CAMERA_LOCATION_DO0 = 2,
42 WMR_CAMERA_LOCATION_DO1 = 3,
43 WMR_CAMERA_LOCATION_HT2 = 4,
44 WMR_CAMERA_LOCATION_HT3 = 5,
45};
46
47enum wmr_camera_purpose
48{
49 WMR_CAMERA_PURPOSE_HEAD_TRACKING,
50 WMR_CAMERA_PURPOSE_DISPLAY_OBSERVER,
51};
52
54{
55 enum wmr_distortion_model model;
56
57 /* X/Y center of the distortion (pixels) */
58 struct xrt_vec2 eye_center;
59 /* k1,k2,k3 params for radial distortion as
60 * per the radial distortion model in
61 * https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html */
62 double k[3];
63};
64
66{
67 enum wmr_distortion_model model;
68
69 /* The config provides 15 float values: */
70 union {
71 struct
72 {
73 float cx, cy; /* Principal point */
74 float fx, fy; /* Focal length */
75 float k[6]; /* Radial distortion coefficients */
76 float dist_x, dist_y; /* Center of distortion */
77 float p2, p1; /* Tangential distortion parameters */
78 float metric_radius; /* Metric radius */
79 } params;
80 float v[15];
81 };
82};
83
85{
86 /* 3x3 camera matrix that moves from normalised camera coords (X/Z & Y/Z) to undistorted pixels */
87 struct xrt_matrix_3x3 affine_xform;
88
89 struct xrt_vec3 translation; //!< Raw translation (to HT0)
90 struct xrt_matrix_3x3 rotation; //!< Raw rotation (to HT0), row major
91 struct xrt_pose pose; //!< Pose from `translation` and `rotation`
92
93 /* Radius of the (undistorted) visible area from the center (pixels) (I think) */
94 double visible_radius;
95
96 /* Width, Height (pixels) of the full display */
97 struct xrt_vec2 display_size;
98 /* Center for the eye viewport visibility (pixels) */
99 struct xrt_vec2 visible_center;
100
101 /* RGB distortion params */
102 struct wmr_distortion_3K distortion3K[3];
103};
104
106{
107 enum wmr_camera_location location;
108 enum wmr_camera_purpose purpose;
109
110 struct xrt_rect roi;
111
112 struct xrt_vec3 translation; //!< Raw translation (to HT0)
113 struct xrt_matrix_3x3 rotation; //!< Raw rotation (to HT0), row major
114 struct xrt_pose pose; //!< Pose from `translation` and `rotation`
115
116 struct wmr_distortion_6KT distortion6KT;
117};
118
119/* Configuration for a single inertial sensor */
121{
122 struct xrt_vec3 translation; //!< Raw translation (to HT0). Usually non-zero only on accelerometers.
123 struct xrt_matrix_3x3 rotation; //!< Raw rotation (to HT0), row major
124 struct xrt_pose pose; //!< Pose from `translation` and `rotation`
125
126 /* Current bias and mix matrix extracted from
127 * the configuration, which provides coefficients
128 * for temperature adjustments - but they're always 0,
129 * so we just take the constant coefficient */
130 struct xrt_vec3 bias_offsets;
131 struct xrt_matrix_3x3 mix_matrix;
132
133 //! Bias random walk variance. @see slam_tracker::inertial_calibration.
135
136 //! Measurement noise standard deviation. @see slam_tracker::inertial_calibration.
138};
139
140/* Precomputed transforms to convert between OpenXR and WMR coordinate systems */
142{
143 struct xrt_pose P_oxr_acc; //!< Converts accel samples into OpenXR coordinates
144 struct xrt_pose P_oxr_gyr; //!< Converts gyro samples into OpenXR coordinates
145 struct xrt_pose P_ht0_me; //!< ME="middle of the eyes". HT0-to-ME transform but in OpenXR coordinates
146 struct xrt_pose P_imu_me; //!< IMU=accel. IMU-to-ME transform but in OpenXR coordinates
147};
148
149/* Configuration for the set of inertial sensors */
151{
152 struct wmr_inertial_sensor_config accel;
153 struct wmr_inertial_sensor_config gyro;
155
156 struct wmr_sensor_transforms_config transforms;
157};
158
160{
161 struct xrt_vec3 pos;
162 struct xrt_vec3 norm;
163};
164
166{
167 /* Left and Right eye mapping and distortion params */
168 struct wmr_distortion_eye_config eye_params[2];
169
170 struct wmr_inertial_sensors_config sensors;
171
172 int cam_count;
173 struct wmr_camera_config cams[WMR_MAX_CAMERAS];
174
175 struct wmr_camera_config *tcams[WMR_MAX_CAMERAS]; //!< Pointers to tracking cameras in `cameras`
176 int tcam_count; //!< Number of tracking cameras
177 int slam_cam_count; //!< Number of tracking cameras to use for SLAM
178};
179
180bool
181wmr_hmd_config_parse(struct wmr_hmd_config *c, char *json_string, enum u_logging_level log_level);
182
183
185{
186 struct wmr_inertial_sensors_config sensors;
187
188 int led_count;
189 struct wmr_led_config leds[WMR_MAX_LEDS];
190};
191
192bool
193wmr_controller_config_parse(struct wmr_controller_config *c, char *json_string, enum u_logging_level log_level);
194
195void
197 struct wmr_distortion_eye_config *eye_params);
198
199#ifdef __cplusplus
200}
201#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:40
C vec2 math library.
C vec3 math library.
Definition: wmr_config.h:106
struct xrt_vec3 translation
Raw translation (to HT0)
Definition: wmr_config.h:112
struct xrt_pose pose
Pose from translation and rotation
Definition: wmr_config.h:114
struct xrt_matrix_3x3 rotation
Raw rotation (to HT0), row major.
Definition: wmr_config.h:113
Definition: wmr_config.h:185
Definition: wmr_config.h:54
Definition: wmr_config.h:66
Definition: wmr_config.h:85
struct xrt_pose pose
Pose from translation and rotation
Definition: wmr_config.h:91
struct xrt_vec3 translation
Raw translation (to HT0)
Definition: wmr_config.h:89
struct xrt_matrix_3x3 rotation
Raw rotation (to HT0), row major.
Definition: wmr_config.h:90
Definition: wmr_config.h:166
struct wmr_camera_config * tcams[4]
Pointers to tracking cameras in cameras
Definition: wmr_config.h:175
int slam_cam_count
Number of tracking cameras to use for SLAM.
Definition: wmr_config.h:177
int tcam_count
Number of tracking cameras.
Definition: wmr_config.h:176
Definition: wmr_config.h:121
struct xrt_vec3 noise_std
Measurement noise standard deviation.
Definition: wmr_config.h:137
struct xrt_vec3 bias_var
Bias random walk variance.
Definition: wmr_config.h:134
struct xrt_pose pose
Pose from translation and rotation
Definition: wmr_config.h:124
struct xrt_vec3 translation
Raw translation (to HT0).
Definition: wmr_config.h:122
struct xrt_matrix_3x3 rotation
Raw rotation (to HT0), row major.
Definition: wmr_config.h:123
Definition: wmr_config.h:151
Definition: wmr_config.h:160
Definition: wmr_config.h:142
struct xrt_pose P_imu_me
IMU=accel.
Definition: wmr_config.h:146
struct xrt_pose P_ht0_me
ME="middle of the eyes".
Definition: wmr_config.h:145
struct xrt_pose P_oxr_acc
Converts accel samples into OpenXR coordinates.
Definition: wmr_config.h:143
struct xrt_pose P_oxr_gyr
Converts gyro samples into OpenXR coordinates.
Definition: wmr_config.h:144
A tightly packed 3x3 matrix of floats.
Definition: xrt_defines.h:533
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
Image rectangle.
Definition: xrt_defines.h:430
A 2 element vector with single floats.
Definition: xrt_defines.h:250
A 3 element vector with single floats.
Definition: xrt_defines.h:271
Basic logging functionality.
void wmr_config_precompute_transforms(struct wmr_inertial_sensors_config *sensors, struct wmr_distortion_eye_config *eye_params)
Precompute transforms to convert between OpenXR and WMR coordinate systems.
Definition: wmr_config.c:610