The open source OpenXR runtime
at main 109 lines 2.1 kB view raw
1// Copyright 2016-2019, Philipp Zabel 2// Copyright 2020, Collabora, Ltd. 3// SPDX-License-Identifier: BSL-1.0 4/*! 5 * @file 6 * @brief Vive Lighthouse Watchman implementation 7 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com> 8 * @ingroup drv_vive 9 */ 10 11#pragma once 12 13#include <math.h> 14#include <stdbool.h> 15#include <stdint.h> 16#include <stdlib.h> 17#include <string.h> 18#include <unistd.h> 19 20#include "xrt/xrt_defines.h" 21 22struct lighthouse_rotor_calibration 23{ 24 float tilt; 25 float phase; 26 float curve; 27 float gibphase; 28 float gibmag; 29}; 30 31struct lighthouse_base_calibration 32{ 33 struct lighthouse_rotor_calibration rotor[2]; 34}; 35 36struct lighthouse_frame 37{ 38 uint32_t sync_timestamp; 39 uint32_t sync_duration; 40 uint32_t sync_ids; 41 uint32_t sweep_ids; 42 uint32_t sweep_offset[32]; 43 uint16_t sweep_duration[32]; 44 uint32_t frame_duration; 45}; 46 47struct lighthouse_base 48{ 49 int data_sync; 50 int data_word; 51 int data_bit; 52 uint8_t ootx[40]; 53 54 int firmware_version; 55 uint32_t serial; 56 struct lighthouse_base_calibration calibration; 57 struct xrt_vec3 gravity; 58 char channel; 59 int model_id; 60 int reset_count; 61 62 uint32_t last_sync_timestamp; 63 int active_rotor; 64 65 struct lighthouse_frame frame[2]; 66}; 67 68struct lighthouse_pulse 69{ 70 uint32_t timestamp; 71 uint16_t duration; 72 uint8_t id; 73}; 74 75struct lighthouse_sensor 76{ 77 struct lighthouse_pulse sync; 78 struct lighthouse_pulse sweep; 79}; 80 81struct tracking_model 82{ 83 uint32_t num_points; 84 struct xrt_vec3 *points; 85 struct xrt_vec3 *normals; 86}; 87 88struct lighthouse_watchman 89{ 90 uint32_t id; 91 const char *name; 92 struct tracking_model model; 93 bool base_visible; 94 struct lighthouse_base base[2]; 95 struct lighthouse_base *active_base; 96 uint32_t seen_by; 97 uint32_t last_timestamp; 98 struct lighthouse_sensor sensor[32]; 99 struct lighthouse_pulse last_sync; 100 bool sync_lock; 101}; 102 103void 104lighthouse_watchman_handle_pulse(struct lighthouse_watchman *watchman, 105 uint8_t id, 106 uint16_t duration, 107 uint32_t timestamp); 108void 109lighthouse_watchman_init(struct lighthouse_watchman *watchman, const char *name);