Monado OpenXR Runtime
Loading...
Searching...
No Matches
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
16#include "util/u_logging.h"
18#include "xrt/xrt_tracking.h"
19
20#define WMR_MAX_CAMERAS 4
21#define WMR_HMD_IMU_INDEX 0
22#define WMR_LEFT_CTRL_IMU_INDEX 1
23#define WMR_RIGHT_CTRL_IMU_INDEX 2
24
25/* Increase this number if anyone releases a controller with
26 * more tracking LEDs */
27#define WMR_MAX_LEDS 40
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33enum wmr_distortion_model
34{
35 WMR_DISTORTION_MODEL_UNKNOWN = 0,
36 WMR_DISTORTION_MODEL_POLYNOMIAL_3K,
37 WMR_DISTORTION_MODEL_POLYNOMIAL_6KT,
38};
39
40/* Location is used as camera_id for setting gain */
41enum wmr_camera_location
42{
43 WMR_CAMERA_LOCATION_HT0 = 0,
44 WMR_CAMERA_LOCATION_HT1 = 1,
45 WMR_CAMERA_LOCATION_DO0 = 2,
46 WMR_CAMERA_LOCATION_DO1 = 3,
47 WMR_CAMERA_LOCATION_HT2 = 4,
48 WMR_CAMERA_LOCATION_HT3 = 5,
49};
50
51enum wmr_camera_purpose
52{
53 WMR_CAMERA_PURPOSE_HEAD_TRACKING,
54 WMR_CAMERA_PURPOSE_DISPLAY_OBSERVER,
55};
56
58{
59 enum wmr_distortion_model model;
60
61 /* The config provides 15 float values: */
62 union {
63 struct
64 {
65 float cx, cy; /* Principal point */
66 float fx, fy; /* Focal length */
67 float k[6]; /* Radial distortion coefficients */
68 float dist_x, dist_y; /* Center of distortion */
69 float p2, p1; /* Tangential distortion parameters */
70 float metric_radius; /* Metric radius */
71 } params;
72 float v[15];
73 };
74};
75
77{
78 struct xrt_vec3 translation; //!< Raw translation (to HT0)
79 struct xrt_matrix_3x3 rotation; //!< Raw rotation (to HT0), row major
80 struct xrt_pose pose; //!< Pose from `translation` and `rotation`
81
82 /* Radius of the (undistorted) visible area from the center (pixels) (I think) */
83 double visible_radius;
84
85 /* Width, Height (pixels) of the full display */
86 struct xrt_vec2 display_size;
87 /* Center for the eye viewport visibility (pixels) */
88 struct xrt_vec2 visible_center;
89
90 struct u_poly_3k_eye_values poly_3k; //!< Distortion parameters for each channel
91};
92
94{
95 enum wmr_camera_location location;
96 enum wmr_camera_purpose purpose;
97
98 struct xrt_rect roi;
99
100 struct xrt_vec3 translation; //!< Raw translation (to HT0)
101 struct xrt_matrix_3x3 rotation; //!< Raw rotation (to HT0), row major
102 struct xrt_pose pose; //!< Pose from `translation` and `rotation`
103
104 struct wmr_distortion_6KT distortion6KT;
105};
106
107/* Configuration for a single inertial sensor */
109{
110 struct xrt_vec3 translation; //!< Raw translation (to HT0). Usually non-zero only on accelerometers.
111 struct xrt_matrix_3x3 rotation; //!< Raw rotation (to HT0), row major
112 struct xrt_pose pose; //!< Pose from `translation` and `rotation`
113
114 /* Current bias and mix matrix extracted from
115 * the configuration, which provides coefficients
116 * for temperature adjustments - but they're always 0,
117 * so we just take the constant coefficient */
118 struct xrt_vec3 bias_offsets;
119 struct xrt_matrix_3x3 mix_matrix;
120
121 //! Bias random walk variance. @see slam_tracker::inertial_calibration.
123
124 //! Measurement noise standard deviation. @see slam_tracker::inertial_calibration.
126};
127
128/* Precomputed transforms to convert between OpenXR and WMR coordinate systems */
130{
131 struct xrt_pose P_oxr_acc; //!< Converts accel samples into OpenXR coordinates
132 struct xrt_pose P_oxr_gyr; //!< Converts gyro samples into OpenXR coordinates
133 struct xrt_pose P_ht0_me; //!< ME="middle of the eyes". HT0-to-ME transform but in OpenXR coordinates
134 struct xrt_pose P_imu_me; //!< IMU=accel. IMU-to-ME transform but in OpenXR coordinates
135};
136
137/* Configuration for the set of inertial sensors */
139{
140 struct wmr_inertial_sensor_config accel;
141 struct wmr_inertial_sensor_config gyro;
143
144 struct wmr_sensor_transforms_config transforms;
145};
146
148{
149 struct xrt_vec3 pos;
150 struct xrt_vec3 norm;
151};
152
154{
155 /* Left and Right eye mapping and distortion params */
156 struct wmr_distortion_eye_config eye_params[2];
157
158 struct wmr_inertial_sensors_config sensors;
159
160 int cam_count;
161 struct wmr_camera_config cams[WMR_MAX_CAMERAS];
162
163 struct wmr_camera_config *tcams[WMR_MAX_CAMERAS]; //!< Pointers to tracking cameras in `cameras`
164 int tcam_count; //!< Number of tracking cameras
165 int slam_cam_count; //!< Number of tracking cameras to use for SLAM
166 int sinks_count; //!< 2x @ref tcam_count to split SLAM and camera streams
167};
168
169bool
170wmr_hmd_config_parse(struct wmr_hmd_config *c, char *json_string, enum u_logging_level log_level);
171
172
174{
175 struct wmr_inertial_sensors_config sensors;
176
177 int led_count;
178 struct wmr_led_config leds[WMR_MAX_LEDS];
179};
180
181bool
182wmr_controller_config_parse(struct wmr_controller_config *c, char *json_string, enum u_logging_level log_level);
183
184void
186 struct wmr_distortion_eye_config *eye_params);
187
188#ifdef __cplusplus
189}
190#endif
u_logging_level
Logging level enum.
Definition u_logging.h:45
C vec2 math library.
C vec3 math library.
Definition u_distortion_mesh.h:182
Definition wmr_config.h:94
struct xrt_vec3 translation
Raw translation (to HT0)
Definition wmr_config.h:100
struct xrt_pose pose
Pose from translation and rotation
Definition wmr_config.h:102
struct xrt_matrix_3x3 rotation
Raw rotation (to HT0), row major.
Definition wmr_config.h:101
Definition wmr_config.h:174
Definition wmr_config.h:58
Definition wmr_config.h:77
struct xrt_pose pose
Pose from translation and rotation
Definition wmr_config.h:80
struct xrt_vec3 translation
Raw translation (to HT0)
Definition wmr_config.h:78
struct xrt_matrix_3x3 rotation
Raw rotation (to HT0), row major.
Definition wmr_config.h:79
struct u_poly_3k_eye_values poly_3k
Distortion parameters for each channel.
Definition wmr_config.h:90
Definition wmr_config.h:154
struct wmr_camera_config * tcams[4]
Pointers to tracking cameras in cameras
Definition wmr_config.h:163
int sinks_count
2x tcam_count to split SLAM and camera streams
Definition wmr_config.h:166
int slam_cam_count
Number of tracking cameras to use for SLAM.
Definition wmr_config.h:165
int tcam_count
Number of tracking cameras.
Definition wmr_config.h:164
Definition wmr_config.h:109
struct xrt_vec3 noise_std
Measurement noise standard deviation.
Definition wmr_config.h:125
struct xrt_vec3 bias_var
Bias random walk variance.
Definition wmr_config.h:122
struct xrt_pose pose
Pose from translation and rotation
Definition wmr_config.h:112
struct xrt_vec3 translation
Raw translation (to HT0).
Definition wmr_config.h:110
struct xrt_matrix_3x3 rotation
Raw rotation (to HT0), row major.
Definition wmr_config.h:111
Definition wmr_config.h:139
Definition wmr_config.h:148
Definition wmr_config.h:130
struct xrt_pose P_imu_me
IMU=accel.
Definition wmr_config.h:134
struct xrt_pose P_ht0_me
ME="middle of the eyes".
Definition wmr_config.h:133
struct xrt_pose P_oxr_acc
Converts accel samples into OpenXR coordinates.
Definition wmr_config.h:131
struct xrt_pose P_oxr_gyr
Converts gyro samples into OpenXR coordinates.
Definition wmr_config.h:132
A tightly packed 3x3 matrix of floats.
Definition xrt_defines.h:569
A pose composed of a position and orientation.
Definition xrt_defines.h:502
Image rectangle.
Definition xrt_defines.h:467
A 2 element vector with single floats.
Definition xrt_defines.h:268
A 3 element vector with single floats.
Definition xrt_defines.h:299
Code to generate disortion meshes.
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:621
Header defining the tracking system integration in Monado.