monado/src/xrt/auxiliary/util/u_hand_simulation.h

87 lines
2.1 KiB
C
Raw Normal View History

// Copyright 2019-2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Wrapper around Mercury's parametric hand code, used by Index and OpenGloves to simulate hand tracking.
* @author Christoph Haag <christoph.haag@collabora.com>
* @ingroup aux_util
*/
#pragma once
#include "xrt/xrt_defines.h"
#include "util/u_misc.h"
#include "util/u_hand_tracking.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* The hand tracking model being used.
*
* 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
*
* @ingroup aux_util
*/
// enum u_hand_tracking_model
// {
// XRT_HAND_TRACKING_MODEL_INTRINSIC,
// XRT_HAND_TRACKING_MODEL_EXTRINSIC,
// };
struct u_hand_sim_metacarpal
{
struct xrt_vec2 swing;
float twist;
};
struct u_hand_sim_finger
{
struct u_hand_sim_metacarpal metacarpal;
struct xrt_vec2 proximal_swing;
// rotation at intermediate joint, then rotation at distal joint
float rotations[2];
};
struct u_hand_sim_thumb
{
struct u_hand_sim_metacarpal metacarpal;
float rotations[2];
};
struct u_hand_sim_hand
{
// Distance from wrist to middle-proximal.
bool is_right;
float hand_size;
struct xrt_space_relation wrist_pose;
struct xrt_space_relation hand_pose;
struct u_hand_sim_thumb thumb;
struct u_hand_sim_finger finger[4];
};
void
u_hand_sim_simulate(struct u_hand_sim_hand *hand, struct xrt_hand_joint_set *out_set);
void
u_hand_sim_simulate_for_valve_index_knuckles(struct u_hand_tracking_curl_values *values,
bool is_right,
struct xrt_space_relation *root_pose,
struct xrt_hand_joint_set *out_set);
void
u_hand_sim_simulate_generic(const struct u_hand_tracking_values *values,
bool is_right,
const struct xrt_space_relation *root_pose,
struct xrt_hand_joint_set *out_set);
#ifdef __cplusplus
}
#endif