Monado OpenXR Runtime
vive_config.h
Go to the documentation of this file.
1// Copyright 2020-2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief vive json header
6 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
7 * @author Moshi Turner <moshiturner@protonmail.com>
8 * @ingroup aux_vive
9 */
10
11#pragma once
12
13#include "xrt/xrt_compiler.h"
14#include "xrt/xrt_defines.h"
15
16#include "util/u_logging.h"
18#include "vive/vive_common.h"
19
20
21// public documentation
22#define INDEX_MIN_IPD 0.058
23#define INDEX_MAX_IPD 0.07
24
25// https://vr-compare.com/headset/htcvive
26// #define VIVE_MIN_IPD 0.061
27// #define VIVE_MAX_IPD 0.072
28
29// steamvr goes from ~60 to 75
30#define VIVE_MIN_IPD 0.060
31#define VIVE_MAX_IPD 0.075
32
33// arbitrary default values
34#define DEFAULT_HAPTIC_FREQ 150.0f
35#define MIN_HAPTIC_DURATION 0.05f
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41
42/*!
43 * Controller variant.
44 *
45 * @ingroup aux_vive
46 */
48{
49 CONTROLLER_VIVE_WAND,
50 CONTROLLER_INDEX_LEFT,
51 CONTROLLER_INDEX_RIGHT,
52 CONTROLLER_TRACKER_GEN1,
53 CONTROLLER_TRACKER_GEN2,
54 CONTROLLER_TRACKER_GEN3,
55 CONTROLLER_TRACKER_TUNDRA,
56 CONTROLLER_UNKNOWN
57};
58
59/*!
60 * A calibrated camera on an Index.
61 *
62 * @ingroup aux_vive
63 */
65{
66 // Note! All the values in this struct are directly pasted in from the JSON values.
67 // As such, in my opinion, plus_x, plus_z and position are all "wrong" - all the code I've had to write that
68 // uses this struct flips the signs of plus_x, plus_z, and the signs of the X- and Z-components of position.
69 // I have no idea why those sign flips were necessary - I suppose Valve/HTC just made some weird decisions when
70 // making the config file schemas. I figure it would be very confusing to try to "fix" these values as I'm
71 // parsing them, so if you're writing code downstream of this, beware and expect the values in here to be
72 // exactly the same as those in the compressed JSON. -Moshi
73 struct
74 {
75 struct xrt_vec3 plus_x;
76 struct xrt_vec3 plus_z;
77 struct xrt_vec3 position; // looks like from head pose
78 } extrinsics;
79
80 //! Pose in tracking space.
82
83 //! Pose in head space.
85
86 struct
87 {
88 double distortion[4]; // Kannala-Brandt
89 double center_x;
90 double center_y;
91
92 double focal_x;
93 double focal_y;
94 struct xrt_size image_size_pixels;
95 } intrinsics;
96};
97
98/*!
99 * A single lighthouse senosor point and normal, in IMU space.
100 *
101 * @ingroup aux_vive
102 */
104{
105 struct xrt_vec3 pos;
106 uint32_t _pad0;
107 struct xrt_vec3 normal;
108 uint32_t _pad1;
109};
110
111/*!
112 * A lighthouse consisting of sensors.
113 *
114 * All sensors are placed in IMU space.
115 *
116 * @ingroup aux_vive
117 */
119{
120 struct lh_sensor *sensors;
121 size_t sensor_count;
122};
123
124/*!
125 * headset config.
126 *
127 * @ingroup aux_vive
128 */
130{
131 //! log level accessed by the config parser
133
134 enum VIVE_VARIANT variant;
135
136 struct
137 {
138 double acc_range;
139 double gyro_range;
140 struct xrt_vec3 acc_bias;
141 struct xrt_vec3 acc_scale;
142 struct xrt_vec3 gyro_bias;
143 struct xrt_vec3 gyro_scale;
144
145 //! IMU position in tracking space.
147 } imu;
148
149 struct
150 {
151 double lens_separation;
152 double persistence;
153 int eye_target_height_in_pixels;
154 int eye_target_width_in_pixels;
155
156 struct xrt_quat rot[2];
157
158 //! Head position in tracking space.
159 struct xrt_pose trackref;
160 //! Head position in IMU space.
162 } display;
163
164 struct
165 {
166 uint32_t display_firmware_version;
167 uint32_t firmware_version;
168 uint8_t hardware_revision;
169 uint8_t hardware_version_micro;
170 uint8_t hardware_version_minor;
171 uint8_t hardware_version_major;
172 char mb_serial_number[32];
173 char model_number[32];
174 char device_serial_number[32];
175 } firmware;
176
177 struct
178 {
179 struct u_vive_values values[2];
180 struct xrt_fov fov[2];
181 } distortion;
182
183 struct
184 {
185 //! The two cameras.
187
188 //! Left view in right camera space.
190
191 //! The same but in OpenCV camera space.
193
194 //! Have we loaded the config.
195 bool valid;
196 } cameras;
197
198 struct lh_model lh;
199};
200
201/*!
202 * Controller config.
203 *
204 * @ingroup aux_vive
205 */
207{
208 enum u_logging_level log_level;
209
210 enum VIVE_CONTROLLER_VARIANT variant;
211
212 struct
213 {
214 uint32_t firmware_version;
215 uint8_t hardware_revision;
216 uint8_t hardware_version_micro;
217 uint8_t hardware_version_minor;
218 uint8_t hardware_version_major;
219 char mb_serial_number[32];
220 char model_number[32];
221 char device_serial_number[32];
222 } firmware;
223
224 struct
225 {
226 double acc_range;
227 double gyro_range;
228 struct xrt_vec3 acc_bias;
229 struct xrt_vec3 acc_scale;
230 struct xrt_vec3 gyro_bias;
231 struct xrt_vec3 gyro_scale;
232
233 //! IMU position in tracking space.
235 } imu;
236};
237
238
239/*
240 *
241 * Functions.
242 *
243 */
244
245/*!
246 * Parse a headset config.
247 *
248 * @ingroup aux_vive
249 */
250bool
251vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level log_level);
252
253/*!
254 * Free any allocated resources on this config.
255 *
256 * @ingroup aux_vive
257 */
258void
259vive_config_teardown(struct vive_config *config);
260
261/*!
262 * Parse a controller config.
263 *
264 * @ingroup aux_vive
265 */
266bool
267vive_config_parse_controller(struct vive_controller_config *d, char *json_string, enum u_logging_level log_level);
268
269
270#ifdef __cplusplus
271} // extern "C"
272#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:44
void vive_config_teardown(struct vive_config *config)
Free any allocated resources on this config.
Definition: vive_config.c:564
bool vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level log_level)
Parse a headset config.
Definition: vive_config.c:408
VIVE_CONTROLLER_VARIANT
Controller variant.
Definition: vive_config.h:48
bool vive_config_parse_controller(struct vive_controller_config *d, char *json_string, enum u_logging_level log_level)
Parse a controller config.
Definition: vive_config.c:581
VIVE_VARIANT
Headset variant.
Definition: vive_common.h:42
static Eigen::Map< const Eigen::Vector3f > position(const struct xrt_pose &pose)
Return a Eigen type wrapping a pose's position (const).
Definition: m_eigen_interop.hpp:217
A calibrated camera on an Index.
Definition: vive_config.h:65
struct xrt_pose headref
Pose in head space.
Definition: vive_config.h:84
struct xrt_pose trackref
Pose in tracking space.
Definition: vive_config.h:81
A lighthouse consisting of sensors.
Definition: vive_config.h:119
A single lighthouse senosor point and normal, in IMU space.
Definition: vive_config.h:104
Values to create a distortion mesh from Vive configuration values.
Definition: u_distortion_mesh.h:70
headset config.
Definition: vive_config.h:130
struct xrt_pose imuref
Head position in IMU space.
Definition: vive_config.h:161
bool valid
Have we loaded the config.
Definition: vive_config.h:195
enum u_logging_level log_level
log level accessed by the config parser
Definition: vive_config.h:132
struct xrt_pose opencv
The same but in OpenCV camera space.
Definition: vive_config.h:192
struct xrt_pose trackref
IMU position in tracking space.
Definition: vive_config.h:146
struct index_camera view[2]
The two cameras.
Definition: vive_config.h:186
struct xrt_pose left_in_right
Left view in right camera space.
Definition: vive_config.h:189
Controller config.
Definition: vive_config.h:207
struct xrt_pose trackref
IMU position in tracking space.
Definition: vive_config.h:234
Describes a projection matrix fov.
Definition: xrt_defines.h:484
A pose composed of a position and orientation.
Definition: xrt_defines.h:464
A quaternion with single floats.
Definition: xrt_defines.h:220
Image size.
Definition: xrt_defines.h:408
A 3 element vector with single floats.
Definition: xrt_defines.h:274
Code to generate disortion meshes.
Basic logging functionality.
Common things like defines for Vive and Index.
Header holding common defines.
Common defines and enums for XRT.