Monado OpenXR Runtime
rift_s_firmware.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Jan Schmidt
3 * SPDX-License-Identifier: BSL-1.0
4 *
5 * OpenHMD - Free and Open Source API and drivers for immersive technology.
6 */
7/*!
8 * @file
9 * @brief Oculus Rift S firmware parsing interface
10 *
11 * Functions for parsing JSON configuration from the HMD
12 * and Touch Controller firmware.
13 *
14 * @author Jan Schmidt <jan@centricular.com>
15 * @ingroup drv_rift_s
16 */
17#ifndef __RTFT_S_FIRMWARE__
18#define __RTFT_S_FIRMWARE__
19
20#include "math/m_mathinclude.h"
21#include "math/m_api.h"
22
23enum rift_s_firmware_block
24{
25 RIFT_S_FIRMWARE_BLOCK_SERIAL_NUM = 0x0B,
26 RIFT_S_FIRMWARE_BLOCK_THRESHOLD = 0xD,
27 RIFT_S_FIRMWARE_BLOCK_IMU_CALIB = 0xE,
28 RIFT_S_FIRMWARE_BLOCK_CAMERA_CALIB = 0xF,
29 RIFT_S_FIRMWARE_BLOCK_DISPLAY_COLOR_CALIB = 0x10,
30 RIFT_S_FIRMWARE_BLOCK_LENS_CALIB = 0x12
31};
32
33enum rift_s_camera_id
34{
35 RIFT_S_CAMERA_TOP = 0x0,
36 RIFT_S_CAMERA_SIDE_LEFT = 0x1,
37 RIFT_S_CAMERA_FRONT_RIGHT = 0x2,
38 RIFT_S_CAMERA_FRONT_LEFT = 0x3,
39 RIFT_S_CAMERA_SIDE_RIGHT = 0x4,
40 RIFT_S_CAMERA_COUNT,
41};
42
43//! Order/index of cameras when dealing with multi-camera tracking
44static const enum rift_s_camera_id CAM_IDX_TO_ID[RIFT_S_CAMERA_COUNT] = {
45 RIFT_S_CAMERA_FRONT_LEFT, RIFT_S_CAMERA_FRONT_RIGHT, //
46 RIFT_S_CAMERA_SIDE_LEFT, RIFT_S_CAMERA_SIDE_RIGHT, //
47 RIFT_S_CAMERA_TOP,
48};
49
51{
52 struct xrt_matrix_4x4 device_from_imu;
53
54 struct
55 {
56 struct xrt_matrix_3x3 rectification;
57 struct xrt_vec3 offset;
58 } gyro;
59
60 struct
61 {
62 struct xrt_matrix_3x3 rectification;
63 struct xrt_vec3 offset_at_0C;
64 struct xrt_vec3 temp_coeff;
65 } accel;
66};
67
69{
70 float cx, cy; /* Principal point */
71 float fx, fy; /* Focal length */
72};
73
75{
76 float k[6]; /* Radial distortion coefficients */
77 float p2, p1; /* Tangential distortion parameters */
78};
79
81{
82 struct xrt_rect roi;
83 struct xrt_matrix_4x4 device_from_camera;
84
85 struct rift_s_projection_pinhole projection;
86 struct rift_s_fisheye62_distortion distortion;
87};
88
90{
91 struct rift_s_camera_calibration cameras[RIFT_S_CAMERA_COUNT];
92};
93
94/* Rift S controller LED entry */
96{
97 // Relative position in metres
98 struct xrt_vec3 pos;
99 // Normal
100 struct xrt_vec3 dir;
101
102 // 85.0, 80.0, 0.0 in all entries so far
103 struct xrt_vec3 angles;
104};
105
107{
108 int num_points;
109 float points[4];
110};
111
113{
114 struct
115 {
116 struct xrt_matrix_3x3 rectification;
117 struct xrt_vec3 offset;
118 } gyro;
119
120 struct
121 {
122 struct xrt_matrix_3x3 rectification;
123 struct xrt_vec3 offset;
124 } accel;
125
126 struct xrt_vec3 imu_position;
127
128 uint8_t num_leds;
129 struct rift_s_led *leds;
130
131 /* For some reason we have a separate calibration
132 * 4x4 matrix on top of the separate rectification
133 * and offset for gyro and accel
134 */
135 struct xrt_matrix_4x4 gyro_calibration;
136 struct xrt_matrix_4x4 accel_calibration;
137
138 /* Lensing models */
139 int num_lensing_models;
140 struct rift_s_lensing_model *lensing_models;
141};
142
143int
144rift_s_parse_proximity_threshold(char *json, int *proximity_threshold);
145int
146rift_s_parse_imu_calibration(char *json, struct rift_s_imu_calibration *c);
147int
148rift_s_parse_camera_calibration_block(char *json, struct rift_s_camera_calibration_block *c);
149int
150rift_s_controller_parse_imu_calibration(char *json, struct rift_s_controller_imu_calibration *c);
151void
152rift_s_controller_free_imu_calibration(struct rift_s_controller_imu_calibration *c);
153
154#endif
C interface to math library.
Wrapper header for <math.h> to ensure pi-related math constants are defined.
static enum rift_s_camera_id CAM_IDX_TO_ID[RIFT_S_CAMERA_COUNT]
Order/index of cameras when dealing with multi-camera tracking.
Definition: rift_s_firmware.h:44
Definition: rift_s_firmware.h:90
Definition: rift_s_firmware.h:81
Definition: rift_s_firmware.h:113
Definition: rift_s_firmware.h:75
Definition: rift_s_firmware.h:51
Definition: rift_s_firmware.h:96
Definition: rift_s_firmware.h:107
Definition: rift_s_firmware.h:69
A tightly packed 3x3 matrix of floats.
Definition: xrt_defines.h:533
A tightly packed 4x4 matrix of floats.
Definition: xrt_defines.h:560
Image rectangle.
Definition: xrt_defines.h:430
A 3 element vector with single floats.
Definition: xrt_defines.h:271