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 struct xrt_vec3 pos;
108 uint32_t _pad0;
109 struct xrt_vec3 normal;
110 uint32_t _pad1;
111};
112
113/*!
114 * A lighthouse consisting of sensors.
115 *
116 * All sensors are placed in IMU space.
117 *
118 * @ingroup aux_vive
119 */
121{
122 struct lh_sensor *sensors;
123 size_t sensor_count;
124};
125
126/*!
127 * headset config.
128 *
129 * @ingroup aux_vive
130 */
132{
133 //! log level accessed by the config parser
135
136 enum VIVE_VARIANT variant;
137
138 struct
139 {
140 double acc_range;
141 double gyro_range;
142 struct xrt_vec3 acc_bias;
143 struct xrt_vec3 acc_scale;
144 struct xrt_vec3 gyro_bias;
145 struct xrt_vec3 gyro_scale;
146
147 //! IMU position in tracking space.
149 } imu;
150
151 struct
152 {
153 double lens_separation;
154 double persistence;
155 int eye_target_height_in_pixels;
156 int eye_target_width_in_pixels;
157
158 struct xrt_quat rot[2];
159
160 //! Head position in tracking space.
161 struct xrt_pose trackref;
162 //! Head position in IMU space.
164 } display;
165
166 struct
167 {
168 uint32_t display_firmware_version;
169 uint32_t firmware_version;
170 uint8_t hardware_revision;
171 uint8_t hardware_version_micro;
172 uint8_t hardware_version_minor;
173 uint8_t hardware_version_major;
174 char mb_serial_number[32];
175 char model_number[32];
176 char device_serial_number[32];
177 } firmware;
178
179 struct
180 {
181 struct u_vive_values values[2];
182 struct xrt_fov fov[2];
183 } distortion;
184
185 struct
186 {
187 //! The two cameras.
189
190 //! Left view in right camera space.
192
193 //! The same but in OpenCV camera space.
195
196 //! Have we loaded the config.
197 bool valid;
198 } cameras;
199
200 struct lh_model lh;
201};
202
203/*!
204 * Controller config.
205 *
206 * @ingroup aux_vive
207 */
209{
210 enum u_logging_level log_level;
211
212 enum VIVE_CONTROLLER_VARIANT variant;
213
214 struct
215 {
216 uint32_t firmware_version;
217 uint8_t hardware_revision;
218 uint8_t hardware_version_micro;
219 uint8_t hardware_version_minor;
220 uint8_t hardware_version_major;
221 char mb_serial_number[32];
222 char model_number[32];
223 char device_serial_number[32];
224 } firmware;
225
226 struct
227 {
228 double acc_range;
229 double gyro_range;
230 struct xrt_vec3 acc_bias;
231 struct xrt_vec3 acc_scale;
232 struct xrt_vec3 gyro_bias;
233 struct xrt_vec3 gyro_scale;
234
235 //! IMU position in tracking space.
237 } imu;
238};
239
240
241/*
242 *
243 * Functions.
244 *
245 */
246
247/*!
248 * Parse a headset config.
249 *
250 * @ingroup aux_vive
251 */
252bool
253vive_config_parse(struct vive_config *d, char *json_string, enum u_logging_level log_level);
254
255/*!
256 * Free any allocated resources on this config.
257 *
258 * @ingroup aux_vive
259 */
260void
261vive_config_teardown(struct vive_config *config);
262
263/*!
264 * Parse a controller config.
265 *
266 * @ingroup aux_vive
267 */
268bool
269vive_config_parse_controller(struct vive_controller_config *d, char *json_string, enum u_logging_level log_level);
270
271
272#ifdef __cplusplus
273} // extern "C"
274#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: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: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:121
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:132
struct xrt_pose imuref
Head position in IMU space.
Definition: vive_config.h:163
bool valid
Have we loaded the config.
Definition: vive_config.h:197
enum u_logging_level log_level
log level accessed by the config parser
Definition: vive_config.h:134
struct xrt_pose opencv
The same but in OpenCV camera space.
Definition: vive_config.h:194
struct xrt_pose trackref
IMU position in tracking space.
Definition: vive_config.h:148
struct index_camera view[2]
The two cameras.
Definition: vive_config.h:188
struct xrt_pose left_in_right
Left view in right camera space.
Definition: vive_config.h:191
Controller config.
Definition: vive_config.h:209
struct xrt_pose trackref
IMU position in tracking space.
Definition: vive_config.h:236
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.