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