Monado OpenXR Runtime
vive_device.h
Go to the documentation of this file.
1// Copyright 2019-2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief vive device header
6 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
7 * @ingroup drv_vive
8 */
9
10#pragma once
11
12#include "xrt/xrt_device.h"
13#include "os/os_threading.h"
14#include "util/u_logging.h"
15#include "util/u_debug.h"
16#include "util/u_time.h"
17#include "util/u_var.h"
18#include "math/m_imu_3dof.h"
20
21#include "vive/vive_config.h"
22
23#include "vive_lighthouse.h"
24#include "xrt/xrt_tracking.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*!
31 * @implements xrt_device
32 */
34{
35 struct xrt_device base;
36 struct os_hid_device *mainboard_dev;
37 struct os_hid_device *sensors_dev;
38 struct os_hid_device *watchman_dev;
39
40 struct lighthouse_watchman watchman;
41
42 struct os_thread_helper sensors_thread;
43 struct os_thread_helper watchman_thread;
44 struct os_thread_helper mainboard_thread;
45
46 struct
47 {
48 timepoint_ns last_sample_ts_ns;
49 uint32_t last_sample_ticks;
50 uint8_t sequence;
51 } imu;
52
53 struct
54 {
55 uint16_t ipd;
56 uint16_t lens_separation;
57 uint16_t proximity;
58 uint8_t button;
59 uint8_t audio_button;
60 } board;
61
62 enum u_logging_level log_level;
63 bool disconnect_notified;
64
65 struct
66 {
67 struct u_var_button switch_tracker_btn;
68 char hand_status[128];
69 char slam_status[128];
70 } gui;
71
72 struct vive_config config;
73
74 struct
75 {
76 //! Protects all members of the `fusion` substruct.
78
79 //! Main fusion calculator.
81
82 //! Prediction
84 } fusion;
85
86 //! Fields related to camera-based tracking (SLAM and hand tracking)
87 struct
88 {
89 //! SLAM tracker.
91
92 //! Set at start. Whether the SLAM tracker was initialized.
94
95 //! Set at start. Whether the hand tracker was initialized.
97
98 //! SLAM systems track the IMU pose, enabling this corrects it to middle of the eyes
99 bool imu2me;
101
102 /*!
103 * Offset for tracked pose offsets (applies to both fusion and SLAM).
104 * Applied when getting the tracked poses, so is effectively a offset
105 * to increase or decrease prediction.
106 */
108
109 struct xrt_pose P_imu_me; //!< IMU to head/display/middle-of-eyes transform in OpenXR coords
110
111 //! Whether to track the HMD with 6dof SLAM or fallback to the 3dof tracker
113
114 //! In charge of managing raw samples, redirects them for tracking
116
117 //! Last tracked pose
119
120 //! Additional offset to apply to `pose`
122};
123
124
125/*!
126 * Summary of the status of various trackers.
127 *
128 * @todo Creation flow is a bit broken for now, in the future this info should be closer
129 * to the tracker creation code, thus avoiding the need to pass it around like this.
130 */
132{
133 bool slam_wanted;
134 bool slam_supported;
135 bool slam_enabled;
136
137 //! Has Monado been built with the correct libraries to do optical hand tracking?
139
140 //! Did we find controllers?
142
143 //! If this is set to ON, we always do optical hand tracking even if controllers were found.
144 //! If this is set to AUTO, we do optical hand tracking only if no controllers were found.
145 //! If this is set to OFF, we don't do optical hand tracking.
146 enum debug_tristate_option hand_wanted;
147
148 //! Computed in target_builder_lighthouse.c based on the past three
150};
151
152void
153vive_set_trackers_status(struct vive_device *d, struct vive_tracking_status status);
154
155struct vive_device *
156vive_device_create(struct os_hid_device *mainboard_dev,
157 struct os_hid_device *sensors_dev,
158 struct os_hid_device *watchman_dev,
159 enum VIVE_VARIANT variant,
160 struct vive_tracking_status tstatus,
161 struct vive_source *vs);
162
163#ifdef __cplusplus
164}
165#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:43
int64_t timepoint_ns
Integer timestamp type.
Definition: u_time.h:70
VIVE_VARIANT
Headset variant.
Definition: vive_config.h:47
A IMU fusion specially made for 3dof devices.
Small utility for keeping track of the history of an xrt_space_relation, ie.
Wrapper around OS threading native functions.
Definition: vive_lighthouse.h:89
Definition: m_imu_3dof.h:35
Definition: m_relation_history.cpp:46
Representing a single hid interface on a device.
Definition: os_hid.h:29
A wrapper around a native mutex.
Definition: os_threading.h:55
All in one helper that handles locking, waiting for change and starting a thread.
Definition: os_threading.h:453
Simple pushable button.
Definition: u_var.h:79
Draggable single precision float information.
Definition: u_var.h:120
headset config.
Definition: vive_config.h:143
Definition: vive_device.h:34
struct xrt_pose P_imu_me
IMU to head/display/middle-of-eyes transform in OpenXR coords.
Definition: vive_device.h:109
struct vive_device::@190 tracking
Fields related to camera-based tracking (SLAM and hand tracking)
struct m_relation_history * relation_hist
Prediction.
Definition: vive_device.h:83
struct u_var_draggable_f32 tracked_offset_ms
Offset for tracked pose offsets (applies to both fusion and SLAM).
Definition: vive_device.h:107
struct xrt_pose offset
Additional offset to apply to pose
Definition: vive_device.h:121
struct vive_source * source
In charge of managing raw samples, redirects them for tracking.
Definition: vive_device.h:115
bool imu2me
SLAM systems track the IMU pose, enabling this corrects it to middle of the eyes.
Definition: vive_device.h:99
bool slam_enabled
Set at start. Whether the SLAM tracker was initialized.
Definition: vive_device.h:93
struct m_imu_3dof i3dof
Main fusion calculator.
Definition: vive_device.h:80
struct os_mutex mutex
Protects all members of the fusion substruct.
Definition: vive_device.h:77
struct xrt_tracked_slam * slam
SLAM tracker.
Definition: vive_device.h:90
struct xrt_pose pose
Last tracked pose.
Definition: vive_device.h:118
bool slam_over_3dof
Whether to track the HMD with 6dof SLAM or fallback to the 3dof tracker.
Definition: vive_device.h:112
bool hand_enabled
Set at start. Whether the hand tracker was initialized.
Definition: vive_device.h:96
Manages the data streaming state related to a vive headset.
Definition: vive_source.c:31
Summary of the status of various trackers.
Definition: vive_device.h:132
bool hand_supported
Has Monado been built with the correct libraries to do optical hand tracking?
Definition: vive_device.h:138
enum debug_tristate_option hand_wanted
If this is set to ON, we always do optical hand tracking even if controllers were found.
Definition: vive_device.h:146
bool hand_enabled
Computed in target_builder_lighthouse.c based on the past three.
Definition: vive_device.h:149
bool controllers_found
Did we find controllers?
Definition: vive_device.h:141
A single HMD or input device.
Definition: xrt_device.h:241
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
An adapter that wraps an external SLAM tracker to provide SLAM tracking.
Definition: xrt_tracking.h:294
Small debug helpers.
Basic logging functionality.
Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.
Variable tracking code.
vive json header
Vive Lighthouse Watchman implementation.
Header defining an xrt display or controller device.
Header defining the tracking system integration in Monado.