Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt_body_tracker.h
Go to the documentation of this file.
1// Copyright 2026, NVIDIA CORPORATION.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Header defining xrt body tracker.
6 * @ingroup xrt_iface
7 */
8
9#pragma once
10
11#include "xrt/xrt_defines.h"
12#include "xrt/xrt_results.h"
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19struct xrt_device;
20struct xrt_body_tracker;
21struct xrt_space;
23
24/*!
25 * Creation parameters for @ref xrt_body_tracker.
26 *
27 * @ingroup xrt_iface
28 */
30{
31 /*!
32 * Which body-tracking data to produce. One of the body-tracking input
33 * names, for example @ref XRT_INPUT_FB_BODY_TRACKING,
34 * @ref XRT_INPUT_META_FULL_BODY_TRACKING, @ref XRT_INPUT_BD_BODY_TRACKING,
35 * or @ref XRT_INPUT_BD_BODY_TRACKING_WITHOUT_ARM.
36 */
38
39 /*!
40 * Device to pull body-tracking data from, or NULL to let the system
41 * choose the backing device (typically the body-tracking role).
42 */
44};
45
46/*!
47 * Capability flags for a body tracker, fixed when it is created.
48 *
49 * Determined by @ref xrt_body_tracker_create_info::body_tracking_type: each
50 * OpenXR body tracker variant implies which of these capabilities the tracker
51 * must provide. The flags are set once at creation and do not change. The
52 * tracker is responsible for meeting them for every successful data path; if
53 * it cannot, it must not return body-tracking data (for example @ref locate
54 * reports inactive / empty results rather than partial or inconsistent
55 * capability).
56 *
57 * @ingroup xrt_iface
58 */
60{
61 bool body_tracking;
62 bool body_tracking_calibration;
63 bool body_tracking_fidelity;
64};
65
66/*!
67 * Result of a locate call. joint_set is the RAW device joint set (joint
68 * relations still expressed relative to the body pose). base_body is the body
69 * pose resolved into the requested base space (T_base_body). The caller chains
70 * each joint relation with base_body, exactly as oxr does today.
71 *
72 * @ingroup xrt_iface
73 */
75{
76 struct xrt_body_joint_set joint_set;
77 struct xrt_space_relation base_body;
78 bool is_active;
79};
80
81/*!
82 * A body tracker, owns the policy for selecting which device and body-tracking
83 * source back a single OpenXR body-tracker handle (XrBodyTrackerFB /
84 * XrBodyTrackerBD).
85 *
86 * Created from an @ref xrt_system_devices (see
87 * @ref xrt_system_devices::create_body_tracker). The OpenXR state tracker holds
88 * one of these per body-tracker handle instead of reaching into an
89 * @ref xrt_device directly, mirroring @ref xrt_hand_tracker. This moves
90 * device/source selection and the base-space transform (in @ref locate) to the
91 * service side of the IPC layer, and lets external runtimes provide different
92 * body-tracking behavior without changing the OpenXR code. Implementations may
93 * change which @ref xrt_device backs a tracker over its lifetime (for example
94 * when the body-tracking role changes); the interface allows that, though not
95 * every implementation must support runtime switching. The FB, META full-body
96 * and BD (PICO) variants are selected via
97 * @ref xrt_body_tracker_create_info::body_tracking_type.
98 *
99 * @ingroup xrt_iface
100 */
102{
103 //! Capability flags for this tracker; see @ref xrt_body_tracker_supported.
105
106 /*!
107 * Locate the tracked body joints.
108 *
109 * @param xbt Pointer to self.
110 * @param xso Space overseer used to resolve the base space.
111 * @param base_space Space to locate the body in.
112 * @param base_offset Offset applied on top of @p base_space.
113 * @param at_timestamp_ns Time to locate at.
114 * @param out_location Resulting raw joint set plus the body pose
115 * resolved into the base space, see
116 * @ref xrt_body_tracker_location.
117 */
119 struct xrt_space_overseer *xso,
120 struct xrt_space *base_space,
121 const struct xrt_pose *base_offset,
122 int64_t at_timestamp_ns,
123 struct xrt_body_tracker_location *out_location);
124
125 /*!
126 * Get the body skeleton (the joint hierarchy and rest pose) for this
127 * tracker's body-tracking source.
128 *
129 * @param xbt Pointer to self.
130 * @param out_skeleton Resulting skeleton.
131 */
132 xrt_result_t (*get_skeleton)(struct xrt_body_tracker *xbt, struct xrt_body_skeleton *out_skeleton);
133
134 /*!
135 * Reset the body-tracking calibration, for
136 * XR_META_body_tracking_calibration.
137 *
138 * @param xbt Pointer to self.
139 */
141
142 /*!
143 * Suggest a body-tracking calibration override, for
144 * XR_META_body_tracking_calibration.
145 *
146 * @param xbt Pointer to self.
147 * @param body_height Suggested body height, in meters.
148 */
150
151 /*!
152 * Request a body-tracking fidelity level, for
153 * XR_META_body_tracking_fidelity.
154 *
155 * @param xbt Pointer to self.
156 * @param fidelity Requested fidelity level.
157 */
158 xrt_result_t (*set_fidelity_meta)(struct xrt_body_tracker *xbt, enum xrt_body_tracking_fidelity_meta fidelity);
159
160 /*!
161 * Destroy this body tracker.
162 *
163 * Code consuming this interface should use @ref xrt_body_tracker_destroy.
164 *
165 * @param xbt Pointer to self.
166 */
167 void (*destroy)(struct xrt_body_tracker *xbt);
168};
169
170/*!
171 * @copydoc xrt_body_tracker::locate
172 *
173 * @public @memberof xrt_body_tracker
174 */
175static inline xrt_result_t
177 struct xrt_space_overseer *xso,
178 struct xrt_space *base_space,
179 const struct xrt_pose *base_offset,
180 int64_t at_timestamp_ns,
181 struct xrt_body_tracker_location *out_location)
182{
183 return xbt->locate(xbt, xso, base_space, base_offset, at_timestamp_ns, out_location);
184}
185
186/*!
187 * @copydoc xrt_body_tracker::get_skeleton
188 *
189 * @public @memberof xrt_body_tracker
190 */
191XRT_NONNULL_ALL static inline xrt_result_t
193{
194 return xbt->get_skeleton(xbt, out_skeleton);
195}
196
197/*!
198 * @copydoc xrt_body_tracker::reset_calibration_meta
199 *
200 * @public @memberof xrt_body_tracker
201 */
202XRT_NONNULL_ALL static inline xrt_result_t
207
208/*!
209 * @copydoc xrt_body_tracker::set_calibration_override_meta
210 *
211 * @public @memberof xrt_body_tracker
212 */
213XRT_NONNULL_ALL static inline xrt_result_t
215{
216 return xbt->set_calibration_override_meta(xbt, body_height);
217}
218
219/*!
220 * @copydoc xrt_body_tracker::set_fidelity_meta
221 *
222 * @public @memberof xrt_body_tracker
223 */
224XRT_NONNULL_ALL static inline xrt_result_t
225xrt_body_tracker_set_fidelity_meta(struct xrt_body_tracker *xbt, enum xrt_body_tracking_fidelity_meta fidelity)
226{
227 return xbt->set_fidelity_meta(xbt, fidelity);
228}
229
230/*!
231 * Destroy an xrt_body_tracker - helper function.
232 *
233 * @param[in,out] xbt_ptr A pointer to the xrt_body_tracker struct pointer.
234 *
235 * Will destroy the tracker if `*xbt_ptr` is not NULL. Will then set
236 * `*xbt_ptr` to NULL.
237 *
238 * @public @memberof xrt_body_tracker
239 */
240XRT_NONNULL_ALL static inline void
242{
243 struct xrt_body_tracker *xbt = *xbt_ptr;
244 if (xbt == NULL) {
245 return;
246 }
247
248 *xbt_ptr = NULL;
249 xbt->destroy(xbt);
250}
251
252#ifdef __cplusplus
253}
254#endif
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition xrt_defines.h:930
enum xrt_result xrt_result_t
Result type used across Monado.
Definition xrt_defines.h:2301
Definition xrt_defines.h:2198
Creation parameters for xrt_body_tracker.
Definition xrt_body_tracker.h:30
struct xrt_device * locked_xdev
Device to pull body-tracking data from, or NULL to let the system choose the backing device (typicall...
Definition xrt_body_tracker.h:43
enum xrt_input_name body_tracking_type
Which body-tracking data to produce.
Definition xrt_body_tracker.h:37
Result of a locate call.
Definition xrt_body_tracker.h:75
Capability flags for a body tracker, fixed when it is created.
Definition xrt_body_tracker.h:60
A body tracker, owns the policy for selecting which device and body-tracking source back a single Ope...
Definition xrt_body_tracker.h:102
static xrt_result_t xrt_body_tracker_locate(struct xrt_body_tracker *xbt, struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_body_tracker_location *out_location)
Locate the tracked body joints.
Definition xrt_body_tracker.h:176
static XRT_NONNULL_ALL void xrt_body_tracker_destroy(struct xrt_body_tracker **xbt_ptr)
Destroy an xrt_body_tracker - helper function.
Definition xrt_body_tracker.h:241
static XRT_NONNULL_ALL xrt_result_t xrt_body_tracker_set_calibration_override_meta(struct xrt_body_tracker *xbt, float body_height)
Suggest a body-tracking calibration override, for XR_META_body_tracking_calibration.
Definition xrt_body_tracker.h:214
void(* destroy)(struct xrt_body_tracker *xbt)
Destroy this body tracker.
Definition xrt_body_tracker.h:167
static XRT_NONNULL_ALL xrt_result_t xrt_body_tracker_reset_calibration_meta(struct xrt_body_tracker *xbt)
Reset the body-tracking calibration, for XR_META_body_tracking_calibration.
Definition xrt_body_tracker.h:203
xrt_result_t(* reset_calibration_meta)(struct xrt_body_tracker *xbt)
Reset the body-tracking calibration, for XR_META_body_tracking_calibration.
Definition xrt_body_tracker.h:140
xrt_result_t(* set_fidelity_meta)(struct xrt_body_tracker *xbt, enum xrt_body_tracking_fidelity_meta fidelity)
Request a body-tracking fidelity level, for XR_META_body_tracking_fidelity.
Definition xrt_body_tracker.h:158
struct xrt_body_tracker_supported supported
Capability flags for this tracker; see xrt_body_tracker_supported.
Definition xrt_body_tracker.h:104
xrt_result_t(* get_skeleton)(struct xrt_body_tracker *xbt, struct xrt_body_skeleton *out_skeleton)
Get the body skeleton (the joint hierarchy and rest pose) for this tracker's body-tracking source.
Definition xrt_body_tracker.h:132
xrt_result_t(* locate)(struct xrt_body_tracker *xbt, struct xrt_space_overseer *xso, struct xrt_space *base_space, const struct xrt_pose *base_offset, int64_t at_timestamp_ns, struct xrt_body_tracker_location *out_location)
Locate the tracked body joints.
Definition xrt_body_tracker.h:118
xrt_result_t(* set_calibration_override_meta)(struct xrt_body_tracker *xbt, float body_height)
Suggest a body-tracking calibration override, for XR_META_body_tracking_calibration.
Definition xrt_body_tracker.h:149
static XRT_NONNULL_ALL xrt_result_t xrt_body_tracker_set_fidelity_meta(struct xrt_body_tracker *xbt, enum xrt_body_tracking_fidelity_meta fidelity)
Request a body-tracking fidelity level, for XR_META_body_tracking_fidelity.
Definition xrt_body_tracker.h:225
static XRT_NONNULL_ALL xrt_result_t xrt_body_tracker_get_skeleton(struct xrt_body_tracker *xbt, struct xrt_body_skeleton *out_skeleton)
Get the body skeleton (the joint hierarchy and rest pose) for this tracker's body-tracking source.
Definition xrt_body_tracker.h:192
A single HMD or input device.
Definition xrt_device.h:340
A pose composed of a position and orientation.
Definition xrt_defines.h:492
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
A relation with two spaces, includes velocity and acceleration.
Definition xrt_defines.h:683
A space very similar to a OpenXR XrSpace but not a full one-to-one mapping, but used to power XrSpace...
Definition xrt_space.h:32
Common defines and enums for XRT.
Internal result type for XRT.