2020-10-12 00:41:35 +00:00
|
|
|
// Copyright 2019-2020, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Hand Tracking API interface.
|
|
|
|
* @author Christoph Haag <christoph.haag@collabora.com>
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "xrt/xrt_defines.h"
|
|
|
|
#include "util/u_misc.h"
|
|
|
|
|
2020-10-26 22:50:54 +00:00
|
|
|
|
2020-10-12 00:41:35 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* The hand tracking model being used.
|
|
|
|
*
|
2022-07-20 08:35:36 +00:00
|
|
|
* XRT_HAND_TRACKING_MODEL_INTRINSIC for devices that measure hand tracking through sensors, ie gloves and knuckles
|
|
|
|
* XRT_HAND_TRACKING_MODEL_EXTRINSIC for devices that measure hand tracking through external factors like cameras
|
2020-10-12 00:41:35 +00:00
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-11-18 21:41:54 +00:00
|
|
|
enum u_hand_tracking_model
|
2020-10-12 00:41:35 +00:00
|
|
|
{
|
2022-07-20 08:35:36 +00:00
|
|
|
XRT_HAND_TRACKING_MODEL_INTRINSIC,
|
|
|
|
XRT_HAND_TRACKING_MODEL_EXTRINSIC,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct u_hand_tracking_finger_value
|
|
|
|
{
|
|
|
|
float splay;
|
|
|
|
|
2022-08-01 16:43:13 +00:00
|
|
|
float joint_curls[4];
|
2022-07-20 08:35:36 +00:00
|
|
|
int joint_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct u_hand_tracking_values
|
|
|
|
{
|
|
|
|
struct u_hand_tracking_finger_value little;
|
|
|
|
struct u_hand_tracking_finger_value ring;
|
|
|
|
struct u_hand_tracking_finger_value middle;
|
|
|
|
struct u_hand_tracking_finger_value index;
|
|
|
|
struct u_hand_tracking_finger_value thumb;
|
2020-10-12 00:41:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Values used for the XRT_HAND_TRACKING_MODEL_FINGERL_CURL model.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
struct u_hand_tracking_curl_values
|
|
|
|
{
|
|
|
|
float little;
|
|
|
|
float ring;
|
|
|
|
float middle;
|
|
|
|
float index;
|
|
|
|
float thumb;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* A space relation of a single joint.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
struct u_joint_space_relation
|
|
|
|
{
|
|
|
|
enum xrt_hand_joint joint_id;
|
|
|
|
struct xrt_space_relation relation;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* A set of joints in a single finger.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
struct u_finger_joint_set
|
|
|
|
{
|
|
|
|
struct u_joint_space_relation joints[5];
|
2021-11-08 22:53:52 +00:00
|
|
|
int joint_count;
|
2020-10-12 00:41:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* The set of joints in the XR_HAND_JOINT_SET_DEFAULT_EXT.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
struct u_hand_joint_default_set
|
|
|
|
{
|
|
|
|
struct u_joint_space_relation palm;
|
|
|
|
struct u_joint_space_relation wrist;
|
|
|
|
|
|
|
|
struct u_finger_joint_set fingers[XRT_FINGER_COUNT];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Main struct drivers can use to implement hand and finger tracking.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
struct u_hand_tracking
|
|
|
|
{
|
|
|
|
// scales dimensions like bone lengths
|
|
|
|
float scale;
|
|
|
|
|
2020-11-18 21:41:54 +00:00
|
|
|
enum u_hand_tracking_model model;
|
2020-10-12 00:41:35 +00:00
|
|
|
union {
|
2022-07-20 08:35:36 +00:00
|
|
|
struct u_hand_tracking_values finger_values;
|
2020-10-12 00:41:35 +00:00
|
|
|
} model_data;
|
|
|
|
|
|
|
|
struct u_hand_joint_default_set joints;
|
2020-11-18 22:42:14 +00:00
|
|
|
|
|
|
|
uint64_t timestamp_ns;
|
2020-10-12 00:41:35 +00:00
|
|
|
};
|
|
|
|
|
2022-08-01 16:42:20 +00:00
|
|
|
/*!
|
|
|
|
* Applies joint width to set.
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_hand_joints_apply_joint_width(struct xrt_hand_joint_set *set);
|
|
|
|
|
2020-10-26 22:50:54 +00:00
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-10-12 00:41:35 +00:00
|
|
|
bool
|
|
|
|
u_hand_joint_is_tip(enum xrt_hand_joint joint);
|
|
|
|
|
2020-10-26 22:50:54 +00:00
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-10-12 00:41:35 +00:00
|
|
|
bool
|
|
|
|
u_hand_joint_is_metacarpal(enum xrt_hand_joint joint);
|
|
|
|
|
2020-12-25 22:52:33 +00:00
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_hand_joint_is_proximal(enum xrt_hand_joint joint);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_hand_joint_is_intermediate(enum xrt_hand_joint joint);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_hand_joint_is_distal(enum xrt_hand_joint joint);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_hand_joint_is_thumb(enum xrt_hand_joint joint);
|
|
|
|
|
2020-10-26 22:50:54 +00:00
|
|
|
/*!
|
|
|
|
* Simple helper function for positioning hands on Valve Index controllers.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-10-12 00:41:35 +00:00
|
|
|
void
|
|
|
|
u_hand_joints_offset_valve_index_controller(enum xrt_hand hand,
|
2021-04-26 20:20:13 +00:00
|
|
|
const struct xrt_vec3 *static_offset,
|
2020-10-12 00:41:35 +00:00
|
|
|
struct xrt_pose *offset);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|