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.
|
|
|
|
*
|
|
|
|
* XRT_HAND_TRACKING_MODEL_FINGERL_CURL uses one curl value per finger to
|
|
|
|
* synthesize hand joint positions.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-11-18 21:41:54 +00:00
|
|
|
enum u_hand_tracking_model
|
2020-10-12 00:41:35 +00:00
|
|
|
{
|
|
|
|
XRT_HAND_TRACKING_MODEL_FINGERL_CURL,
|
2020-11-25 20:37:57 +00:00
|
|
|
XRT_HAND_TRACKING_MODEL_CAMERA,
|
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];
|
|
|
|
int num_joints;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* 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 {
|
|
|
|
struct u_hand_tracking_curl_values curl_values;
|
|
|
|
} 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
|
|
|
};
|
|
|
|
|
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_tip(enum xrt_hand_joint joint);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_hand_joint_is_thumb(enum xrt_hand_joint joint);
|
|
|
|
|
2020-10-12 00:41:35 +00:00
|
|
|
/*!
|
|
|
|
* Initializes a hand tracking set with default data.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_hand_joints_init_default_set(struct u_hand_tracking *set,
|
|
|
|
enum xrt_hand hand,
|
2020-11-18 21:41:54 +00:00
|
|
|
enum u_hand_tracking_model model,
|
2020-10-12 00:41:35 +00:00
|
|
|
float scale);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Helper function using hand_relation and hand_offset to transform joint
|
|
|
|
* locations from an xrt_hand_tracking data in hand space
|
|
|
|
* to an xrt_hand_joint_set in global space.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u_hand_joints_set_out_data(struct u_hand_tracking *set,
|
|
|
|
enum xrt_hand hand,
|
2021-04-26 20:20:13 +00:00
|
|
|
const struct xrt_space_relation *hand_relation,
|
|
|
|
const struct xrt_pose *hand_offset,
|
2020-11-13 00:30:25 +00:00
|
|
|
struct xrt_hand_joint_set *out_value);
|
2020-10-12 00:41:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Curl model specific functions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-10-26 22:50:54 +00:00
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-10-12 00:41:35 +00:00
|
|
|
void
|
2021-04-26 20:20:13 +00:00
|
|
|
u_hand_joint_compute_next_by_curl(const struct u_hand_tracking *set,
|
|
|
|
const struct u_joint_space_relation *prev,
|
2020-10-12 00:41:35 +00:00
|
|
|
enum xrt_hand hand,
|
2020-11-18 22:42:14 +00:00
|
|
|
uint64_t at_timestamp_ns,
|
2020-10-12 00:41:35 +00:00
|
|
|
struct u_joint_space_relation *out_joint,
|
|
|
|
float curl_value);
|
|
|
|
|
2020-10-26 22:50:54 +00:00
|
|
|
/*!
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-10-12 00:41:35 +00:00
|
|
|
void
|
|
|
|
u_hand_joints_update_curl(struct u_hand_tracking *set,
|
|
|
|
enum xrt_hand hand,
|
2020-11-18 22:42:14 +00:00
|
|
|
uint64_t at_timestamp_ns,
|
2020-10-12 00:41:35 +00:00
|
|
|
struct u_hand_tracking_curl_values *curl_values);
|
|
|
|
|
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
|