Monado OpenXR Runtime
Loading...
Searching...
No Matches
pssense_led_model.h
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief PlayStation Sense controller LED models. Data extracted from Sony's PC driver.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup drv_pssense
8 */
9
10#pragma once
11
12#include "xrt/xrt_tracking.h"
13
15
16#include "math/m_api.h"
17
18
19static const float LED_RADIUS_M = 0.006f; // 6mm
20static const float LED_VISIBILITY_ANGLE = DEG_TO_RAD(90);
21static const struct t_constellation_tracker_led_model_match_parameters DEFAULT_MATCH_PARAMETERS = {
23 .min_leds_for_correspondence_search_with_prior = 5,
24};
25
26//! Rotation on X axis from LED -> IMU.
27const float pssense_imu_angle = DEG_TO_RAD(-50.2703f);
28
29//! The offset from the LED origin -> IMU origin, for the left controller
30static struct xrt_vec3 T_led_imu_left = {
31 .x = 0.0093727f,
32 .y = -0.0122481f,
33 .z = -0.0060039f,
34};
35//! The offset from the LED origin -> IMU origin, for the right controller
36static struct xrt_vec3 T_led_imu_right = {
37 .x = -0.0200727f,
38 .y = -0.0122481f,
39 .z = -0.0060039f,
40};
41
42/*!
43 * IMU noise model for the PS VR2 controllers.
44 */
46 .gyro =
47 {
48 // 3e-4 (rad/s)^2 per sample
49 .noise_density = 1.5e-3,
50 // 0.5% scale factor and 0.25% cross axis error per sample
51 .scale_factor_noise_density = 4.3301270e-4,
52 .cross_axis_noise_density = 2.1650635e-4,
53 // 1900 deg/s, a saturated axis gets (100 deg/s)^2 per sample
54 .axis_saturation = 33.1612587,
55 .saturated_noise_density = 0.15114995,
56 // (0.001 deg/s)^2 per second
57 .bias_random_walk = 1.745e-5,
58 // 0.025 deg/s on factory calibrated samples
59 .bias_initial_sigma = 4.363e-4,
60 },
61 .accel =
62 {
63 // 1.08e-4 G^2 per sample
64 .noise_density = 8.8259848e-3,
65 .scale_factor_noise_density = 4.3301270e-4,
66 .cross_axis_noise_density = 2.1650635e-4,
67 // 7.8 G, a saturated axis gets (2.5 G)^2 per sample
68 .axis_saturation = 76.49187,
69 .saturated_noise_density = 2.1232020,
70 // No proper value, reasonable default
71 .bias_random_walk = 1e-3,
72 // 1 mg on factory calibrated samples
73 .bias_initial_sigma = 9.807e-3,
74 },
75 .accel_scale_random_walk = 1e-5,
76 .accel_scale_initial_sigma = 0.05,
77};
78
79/*
80 * Intercepted at address 0xdde10 in the driver, within a vector in the first
81 * parameter object.
82 */
83static const struct t_constellation_tracker_led pssense_left_leds[] = {
84 {
85 .position = {-0.012054, -0.055213, 0.038152},
86 .normal = {-0.176485, -0.811967, 0.556384},
87 .radius_m = LED_RADIUS_M,
88 .visibility_angle = LED_VISIBILITY_ANGLE,
89 .id = 0,
90 },
91 {
92 .position = {-0.033088, -0.055236, 0.020190},
93 .normal = {-0.426232, -0.891845, -0.151455},
94 .radius_m = LED_RADIUS_M,
95 .visibility_angle = LED_VISIBILITY_ANGLE,
96 .id = 1,
97 },
98 {
99 .position = {-0.053695, -0.031009, 0.028350},
100 .normal = {-0.788493, -0.456350, 0.412339},
101 .radius_m = LED_RADIUS_M,
102 .visibility_angle = LED_VISIBILITY_ANGLE,
103 .id = 2,
104 },
105 {
106 .position = {-0.066986, -0.010505, 0.008679},
107 .normal = {-0.980055, -0.153898, 0.125726},
108 .radius_m = LED_RADIUS_M,
109 .visibility_angle = LED_VISIBILITY_ANGLE,
110 .id = 3,
111 },
112 {
113 .position = {-0.063505, 0.024601, 0.004185},
114 .normal = {-0.930796, 0.360502, 0.060482},
115 .radius_m = LED_RADIUS_M,
116 .visibility_angle = LED_VISIBILITY_ANGLE,
117 .id = 4,
118 },
119 {
120 .position = {-0.047803, 0.044966, 0.018502},
121 .normal = {-0.701817, 0.660177, 0.267618},
122 .radius_m = LED_RADIUS_M,
123 .visibility_angle = LED_VISIBILITY_ANGLE,
124 .id = 5,
125 },
126 {
127 .position = {0.045472, -0.027042, 0.043022},
128 .normal = {0.667492, -0.396842, 0.630056},
129 .radius_m = LED_RADIUS_M,
130 .visibility_angle = LED_VISIBILITY_ANGLE,
131 .id = 6,
132 },
133 {
134 .position = {0.059535, -0.013977, 0.028536},
135 .normal = {0.961512, -0.273488, -0.026435},
136 .radius_m = LED_RADIUS_M,
137 .visibility_angle = LED_VISIBILITY_ANGLE,
138 .id = 7,
139 },
140 {
141 .position = {0.061060, 0.014608, 0.024725},
142 .normal = {0.984435, 0.154641, -0.083507},
143 .radius_m = LED_RADIUS_M,
144 .visibility_angle = LED_VISIBILITY_ANGLE,
145 .id = 8,
146 },
147 {
148 .position = {0.050994, 0.027255, 0.036184},
149 .normal = {0.748123, 0.399672, 0.529693},
150 .radius_m = LED_RADIUS_M,
151 .visibility_angle = LED_VISIBILITY_ANGLE,
152 .id = 9,
153 },
154 {
155 .position = {0.048475, 0.043025, 0.018776},
156 .normal = {0.795992, 0.580182, -0.172584},
157 .radius_m = LED_RADIUS_M,
158 .visibility_angle = LED_VISIBILITY_ANGLE,
159 .id = 10,
160 },
161 {
162 .position = {0.030569, 0.053446, 0.029350},
163 .normal = {0.448555, 0.783814, 0.429458},
164 .radius_m = LED_RADIUS_M,
165 .visibility_angle = LED_VISIBILITY_ANGLE,
166 .id = 11,
167 },
168 {
169 .position = {0.018498, 0.063913, 0.011230},
170 .normal = {0.346695, 0.893406, -0.285708},
171 .radius_m = LED_RADIUS_M,
172 .visibility_angle = LED_VISIBILITY_ANGLE,
173 .id = 12,
174 },
175 {
176 .position = {-0.002748, 0.064260, 0.022718},
177 .normal = {-0.040150, 0.942362, 0.332178},
178 .radius_m = LED_RADIUS_M,
179 .visibility_angle = LED_VISIBILITY_ANGLE,
180 .id = 13,
181 },
182 {
183 .position = {-0.029078, 0.013435, -0.060735},
184 .normal = {-0.417589, 0.258817, -0.870996},
185 .radius_m = LED_RADIUS_M,
186 .visibility_angle = LED_VISIBILITY_ANGLE,
187 .id = 14,
188 },
189 {
190 .position = {0.001067, 0.013435, -0.067327},
191 .normal = {0.014114, 0.258800, -0.965828},
192 .radius_m = LED_RADIUS_M,
193 .visibility_angle = LED_VISIBILITY_ANGLE,
194 .id = 15,
195 },
196 {
197 .position = {0.031783, 0.013435, -0.059270},
198 .normal = {0.458628, 0.258803, -0.850106},
199 .radius_m = LED_RADIUS_M,
200 .visibility_angle = LED_VISIBILITY_ANGLE,
201 .id = 16,
202 },
203};
204
205static const struct t_constellation_tracker_led pssense_right_leds[] = {
206 {
207 .position = {0.012054, -0.055213, 0.038152},
208 .normal = {0.176485, -0.811967, 0.556384},
209 .radius_m = LED_RADIUS_M,
210 .visibility_angle = LED_VISIBILITY_ANGLE,
211 .id = 0,
212 },
213 {
214 .position = {0.033088, -0.055236, 0.020190},
215 .normal = {0.426232, -0.891845, -0.151455},
216 .radius_m = LED_RADIUS_M,
217 .visibility_angle = LED_VISIBILITY_ANGLE,
218 .id = 1,
219 },
220 {
221 .position = {0.053695, -0.031009, 0.028350},
222 .normal = {0.788493, -0.456350, 0.412339},
223 .radius_m = LED_RADIUS_M,
224 .visibility_angle = LED_VISIBILITY_ANGLE,
225 .id = 2,
226 },
227 {
228 .position = {0.066986, -0.010505, 0.008679},
229 .normal = {0.980055, -0.153898, 0.125726},
230 .radius_m = LED_RADIUS_M,
231 .visibility_angle = LED_VISIBILITY_ANGLE,
232 .id = 3,
233 },
234 {
235 .position = {0.063505, 0.024601, 0.004185},
236 .normal = {0.930796, 0.360502, 0.060482},
237 .radius_m = LED_RADIUS_M,
238 .visibility_angle = LED_VISIBILITY_ANGLE,
239 .id = 4,
240 },
241 {
242 .position = {0.047803, 0.044966, 0.018502},
243 .normal = {0.701817, 0.660177, 0.267618},
244 .radius_m = LED_RADIUS_M,
245 .visibility_angle = LED_VISIBILITY_ANGLE,
246 .id = 5,
247 },
248 {
249 .position = {-0.045472, -0.027042, 0.043022},
250 .normal = {-0.667492, -0.396842, 0.630056},
251 .radius_m = LED_RADIUS_M,
252 .visibility_angle = LED_VISIBILITY_ANGLE,
253 .id = 6,
254 },
255 {
256 .position = {-0.059535, -0.013977, 0.028536},
257 .normal = {-0.961512, -0.273488, -0.026435},
258 .radius_m = LED_RADIUS_M,
259 .visibility_angle = LED_VISIBILITY_ANGLE,
260 .id = 7,
261 },
262 {
263 .position = {-0.061060, 0.014608, 0.024725},
264 .normal = {-0.984435, 0.154641, -0.083507},
265 .radius_m = LED_RADIUS_M,
266 .visibility_angle = LED_VISIBILITY_ANGLE,
267 .id = 8,
268 },
269 {
270 .position = {-0.050994, 0.027255, 0.036184},
271 .normal = {-0.748123, 0.399672, 0.529693},
272 .radius_m = LED_RADIUS_M,
273 .visibility_angle = LED_VISIBILITY_ANGLE,
274 .id = 9,
275 },
276 {
277 .position = {-0.048475, 0.043025, 0.018776},
278 .normal = {-0.795992, 0.580182, -0.172584},
279 .radius_m = LED_RADIUS_M,
280 .visibility_angle = LED_VISIBILITY_ANGLE,
281 .id = 10,
282 },
283 {
284 .position = {-0.030569, 0.053446, 0.029350},
285 .normal = {-0.448555, 0.783814, 0.429458},
286 .radius_m = LED_RADIUS_M,
287 .visibility_angle = LED_VISIBILITY_ANGLE,
288 .id = 11,
289 },
290 {
291 .position = {-0.018498, 0.063913, 0.011230},
292 .normal = {-0.346695, 0.893406, -0.285708},
293 .radius_m = LED_RADIUS_M,
294 .visibility_angle = LED_VISIBILITY_ANGLE,
295 .id = 12,
296 },
297 {
298 .position = {0.002748, 0.064260, 0.022718},
299 .normal = {0.040150, 0.942362, 0.332178},
300 .radius_m = LED_RADIUS_M,
301 .visibility_angle = LED_VISIBILITY_ANGLE,
302 .id = 13,
303 },
304 {
305 .position = {0.029078, 0.013435, -0.060735},
306 .normal = {0.417589, 0.258817, -0.870996},
307 .radius_m = LED_RADIUS_M,
308 .visibility_angle = LED_VISIBILITY_ANGLE,
309 .id = 14,
310 },
311 {
312 .position = {-0.001067, 0.013435, -0.067327},
313 .normal = {-0.014114, 0.258800, -0.965828},
314 .radius_m = LED_RADIUS_M,
315 .visibility_angle = LED_VISIBILITY_ANGLE,
316 .id = 15,
317 },
318 {
319 .position = {-0.031783, 0.013435, -0.059270},
320 .normal = {-0.458628, 0.258803, -0.850106},
321 .radius_m = LED_RADIUS_M,
322 .visibility_angle = LED_VISIBILITY_ANGLE,
323 .id = 16,
324 },
325};
326
327/*!
328 * Sony forgot to factor in the plastic when computing the original
329 * model, this is a fixup on top of that.
330 *
331 * This applies specifically to the right controller, and has X inverted for the left controller.
332 *
333 * Computed via a bundle adjustment of a large controller tracking dataset with CV1.
334 */
335static const struct xrt_vec3 pssense_led_emission_offsets[] = {
336 {0.000262, -0.001698, 0.000803}, // LED 0: +1.87 mm along normal
337 {0.000599, -0.001296, -0.000481}, // LED 1: +1.48 mm along normal
338 {0.001550, -0.001087, 0.000603}, // LED 2: +1.97 mm along normal
339 {0.001588, -0.000457, -0.000046}, // LED 3: +1.62 mm along normal
340 {0.001498, 0.000488, -0.000025}, // LED 4: +1.57 mm along normal
341 {0.001238, 0.000888, 0.000272}, // LED 5: +1.53 mm along normal
342 {-0.000983, -0.000921, 0.001300}, // LED 6: +1.84 mm along normal
343 {-0.001169, -0.000671, -0.000025}, // LED 7: +1.31 mm along normal
344 {-0.001315, -0.000090, -0.000021}, // LED 8: +1.28 mm along normal
345 {-0.001246, 0.000856, 0.000855}, // LED 9: +1.73 mm along normal
346 {-0.001071, 0.000414, -0.000405}, // LED 10: +1.16 mm along normal
347 {-0.000537, 0.001162, 0.000544}, // LED 11: +1.39 mm along normal
348 {-0.000372, 0.000718, -0.000602}, // LED 12: +0.94 mm along normal
349 {0.000399, 0.001257, 0.000289}, // LED 13: +1.30 mm along normal
350 {0.000331, 0.000033, -0.001030}, // LED 14: +1.04 mm along normal
351 {-0.000125, 0.000117, -0.001062}, // LED 15: +1.06 mm along normal
352 {-0.000648, 0.000286, -0.000970}, // LED 16: +1.20 mm along normal
353};
#define DEG_TO_RAD(DEG)
Degrees to radians conversion.
Definition m_api.h:87
C interface to math library.
const float pssense_imu_angle
Rotation on X axis from LED -> IMU.
Definition pssense_led_model.h:27
static struct xrt_vec3 T_led_imu_right
The offset from the LED origin -> IMU origin, for the right controller.
Definition pssense_led_model.h:36
static const struct xrt_imu_noise_calibration PSSENSE_IMU_CALIBRATION
IMU noise model for the PS VR2 controllers.
Definition pssense_led_model.h:45
static struct xrt_vec3 T_led_imu_left
The offset from the LED origin -> IMU origin, for the left controller.
Definition pssense_led_model.h:30
static const struct xrt_vec3 pssense_led_emission_offsets[]
Sony forgot to factor in the plastic when computing the original model, this is a fixup on top of tha...
Definition pssense_led_model.h:335
uint32_t min_leds_for_correspondence_search_without_prior
The minimum number of LEDs required to accept a brute-force solve without a prior.
Definition t_constellation.h:296
Definition t_constellation.h:280
struct xrt_vec3 position
The position of the LED in the model.
Definition t_constellation.h:282
IMU noise model and bias calibration, the noise density grows with the reading on each axis.
Definition xrt_tracking.h:213
struct xrt_imu_sensor_calibration gyro
Gyroscope calibration, in rad/s.
Definition xrt_tracking.h:215
double noise_density
Noise density at rest, in unit/sqrt(Hz).
Definition xrt_tracking.h:191
A 3 element vector with single floats.
Definition xrt_defines.h:323
Header defining the tracking system integration in Monado.
Header defining the tracking system integration in Monado.