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_FLIPVR_LEFT,
53 CONTROLLER_FLIPVR_RIGHT,
54 CONTROLLER_TRACKER_GEN1,
55 CONTROLLER_TRACKER_GEN2,
56 CONTROLLER_TRACKER_GEN3,
57 CONTROLLER_TRACKER_TUNDRA,
58 CONTROLLER_UNKNOWN
59};
60
61/*!
62 * A calibrated camera on an Index.
63 *
64 * @ingroup aux_vive
65 */
67{
68 // Note! All the values in this struct are directly pasted in from the JSON values.
69 // As such, in my opinion, plus_x, plus_z and position are all "wrong" - all the code I've had to write that
70 // uses this struct flips the signs of plus_x, plus_z, and the signs of the X- and Z-components of position.
71 // I have no idea why those sign flips were necessary - I suppose Valve/HTC just made some weird decisions when
72 // making the config file schemas. I figure it would be very confusing to try to "fix" these values as I'm
73 // parsing them, so if you're writing code downstream of this, beware and expect the values in here to be
74 // exactly the same as those in the compressed JSON. -Moshi
75 struct
76 {
77 struct xrt_vec3 plus_x;
78 struct xrt_vec3 plus_z;
79 struct xrt_vec3 position; // looks like from head pose
80 } extrinsics;
81
82 //! Pose in tracking space.
84
85 //! Pose in head space.
87
88 struct
89 {
90 double distortion[4]; // Kannala-Brandt
91 double center_x;
92 double center_y;
93
94 double focal_x;
95 double focal_y;
96 struct xrt_size image_size_pixels;
97 } intrinsics;
98};
99
100/*!
101 * A single lighthouse senosor point and normal, in IMU space.
102 *
103 * @ingroup aux_vive
104 */
106{
107 uint8_t channel;
108 struct xrt_vec3 pos;
109 uint32_t _pad0;
110 struct xrt_vec3 normal;
111 uint32_t _pad1;
112};
113
114/*!
115 * A lighthouse consisting of sensors.
116 *
117 * All sensors are placed in IMU space.
118 *
119 * @ingroup aux_vive
120 */
122{
123 struct lh_sensor *sensors;
124 uint8_t sensor_count;
125};
126
127/*!
128 * headset config.
129 *
130 * @ingroup aux_vive
131 */
133{
134 //! log level accessed by the config parser
136
137 enum VIVE_VARIANT variant;
138
139 struct
140 {
141 double acc_range;
142 double gyro_range;
143 struct xrt_vec3 acc_bias;
144 struct xrt_vec3 acc_scale;
145 struct xrt_vec3 gyro_bias;
146 struct xrt_vec3 gyro_scale;
147
148 //! IMU position in tracking space.
150 } imu;
151
152 struct
153 {
154 double lens_separation;
155 double persistence;
156 int eye_target_height_in_pixels;
157 int eye_target_width_in_pixels;
158
159 struct xrt_quat rot[2];
160
161 //! Head position in tracking space.
162 struct xrt_pose trackref;
163 //! Head position in IMU space.
165 } display;
166
167 struct
168 {
169 uint32_t display_firmware_version;
170 uint32_t firmware_version;
171 uint8_t hardware_revision;
172 uint8_t hardware_version_micro;
173 uint8_t hardware_version_minor;
174 uint8_t hardware_version_major;
175 char mb_serial_number[32];
176 char model_number[32];
177 char device_serial_number[32];
178 } firmware;
179
180 struct
181 {
182 struct u_vive_values values[2];
183 struct xrt_fov fov[2];
184 } distortion;
185
186 struct
187 {
188 //! The two cameras.
190
191 //! Left view in right camera space.
193
194 //! The same but in OpenCV camera space.
196
197 //! Have we loaded the config.
198 bool valid;
199 } cameras;
200
201 struct lh_model lh;
202};
203
204/*!
205 * Controller config.
206 *
207 * @ingroup aux_vive
208 */
210{
211 enum u_logging_level log_level;
212
213 enum VIVE_CONTROLLER_VARIANT variant;
214
215 struct
216 {
217 uint32_t firmware_version;
218 uint8_t hardware_revision;
219 uint8_t hardware_version_micro;
220 uint8_t hardware_version_minor;
221 uint8_t hardware_version_major;
222 char mb_serial_number[32];
223 char model_number[32];
224 char device_serial_number[32];
225 } firmware;
226
227 struct
228 {
229 double acc_range;
230 double gyro_range;
231 struct xrt_vec3 acc_bias;
232 struct xrt_vec3 acc_scale;
233 struct xrt_vec3 gyro_bias;
234 struct xrt_vec3 gyro_scale;
235
236 //! IMU position in tracking space.
238 } imu;
239};
240
241
242/*
243 *
244 * Functions.
245 *
246 */
247
248/*!
249 * Parse a headset config.
250 *
251 * @ingroup aux_vive
252 */
253bool
254vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level log_level);
255
256/*!
257 * Free any allocated resources on this config.
258 *
259 * @ingroup aux_vive
260 */
261void
262vive_config_teardown(struct vive_config *config);
263
264/*!
265 * Parse a controller config.
266 *
267 * @ingroup aux_vive
268 */
269bool
270vive_config_parse_controller(struct vive_controller_config *d, char *json_string, enum u_logging_level log_level);
271
272
273#ifdef __cplusplus
274} // extern "C"
275#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:45
void vive_config_teardown(struct vive_config *config)
Free any allocated resources on this config.
Definition: vive_config.c:558
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:402
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:575
VIVE_VARIANT
Headset variant.
Definition: vive_common.h:44
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:67
struct xrt_pose headref
Pose in head space.
Definition: vive_config.h:86
struct xrt_pose trackref
Pose in tracking space.
Definition: vive_config.h:83
A lighthouse consisting of sensors.
Definition: vive_config.h:122
A single lighthouse senosor point and normal, in IMU space.
Definition: vive_config.h:106
Values to create a distortion mesh from Vive configuration values.
Definition: u_distortion_mesh.h:70
headset config.
Definition: vive_config.h:133
struct xrt_pose imuref
Head position in IMU space.
Definition: vive_config.h:164
bool valid
Have we loaded the config.
Definition: vive_config.h:198
enum u_logging_level log_level
log level accessed by the config parser
Definition: vive_config.h:135
struct xrt_pose opencv
The same but in OpenCV camera space.
Definition: vive_config.h:195
struct xrt_pose trackref
IMU position in tracking space.
Definition: vive_config.h:149
struct index_camera view[2]
The two cameras.
Definition: vive_config.h:189
struct xrt_pose left_in_right
Left view in right camera space.
Definition: vive_config.h:192
Controller config.
Definition: vive_config.h:210
struct xrt_pose trackref
IMU position in tracking space.
Definition: vive_config.h:237
Describes a projection matrix fov.
Definition: xrt_defines.h:499
A pose composed of a position and orientation.
Definition: xrt_defines.h:479
A quaternion with single floats.
Definition: xrt_defines.h:235
Image size.
Definition: xrt_defines.h:423
A 3 element vector with single floats.
Definition: xrt_defines.h:289
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.