godot_openvr icon indicating copy to clipboard operation
godot_openvr copied to clipboard

Exposing skeleton finger data.

Open 2-3-5-41 opened this issue 3 years ago • 16 comments
trafficstars

The data in question:

  • Finger curl
  • Raw skeleton bone positions and rotations

I'd like to be able to reference finger curl, or raw data from the SteamVR skeletal system to be applied to an IK Avatar.

2-3-5-41 avatar Jul 20 '22 00:07 2-3-5-41

@vilhalmer is this something we can do with the new openvr?

fire avatar Apr 28 '25 03:04 fire

Yeah, there's a TODO about grabbing skeleton data. I've not looked into what is needed to do it, but I will eventually want access to this data as well. Someone is welcome to pick that up, I don't think it will conflict with any other works.

vilhalmer avatar Apr 29 '25 15:04 vilhalmer

Do you have any pointers where?

fire avatar Apr 29 '25 19:04 fire

I haven't checked to see what state the existing skeleton code is in, but this seems to be where it needs to be fed in: https://github.com/GodotVR/godot_openvr/blob/b1aea64ac07732d6f73910d871b4d3af66965850/src/open_vr/openvr_data.cpp#L427

vilhalmer avatar Apr 29 '25 20:04 vilhalmer

There's two primary data sources for openvr skeletons according to Google Gemini search (Could be wrong so need to verify).

https://github.com/ValveSoftware/openvr/wiki/SteamVR-Skeletal-Input

  1. Raw Bone Transforms:

    • The function vr::VRInput()->GetSkeletalBoneData() is used to retrieve an array of vr::VRBoneTransform_t structures, which contain the position and orientation for each bone.
    • The VRBoneTransform_t structure is defined in the OpenVR headers (like openvr_driver.h) and typically contains a position vector (e.g., HmdVector4_t) and an orientation quaternion (e.g., HmdQuaternionf_t).
    • This data can be requested in different coordinate spaces (EVRSkeletalTransformSpace) and motion ranges (EVRSkeletalMotionRange).
  2. Summary Data (Finger Curls and Splays):

    • The function vr::VRInput()->GetSkeletalSummaryData() retrieves a VRSkeletalSummaryData_t structure.
    • This structure contains arrays of float values (typically 0.0 to 1.0) representing the curl of each finger (flFingerCurl) and the splay between adjacent fingers (flFingerSplay).

fire avatar Apr 30 '25 13:04 fire

Wouldn't trust Gemini's advice as far as I can throw their data center, given that the wiki it's sourcing from is barely ever even up to date. :)

vilhalmer avatar Apr 30 '25 13:04 vilhalmer

  1. https://github.com/ValveSoftware/openvr/blob/ae46a8dd0172580648c8922658a100439115d3eb/headers/openvr.h#L5211
  2. https://github.com/ValveSoftware/openvr/blob/ae46a8dd0172580648c8922658a100439115d3eb/headers/openvr.h#L4944
  3. https://github.com/ValveSoftware/openvr/blob/ae46a8dd0172580648c8922658a100439115d3eb/headers/openvr.h#L4944

All the data structures and methods mentioned seem to be correct.

fire avatar Apr 30 '25 13:04 fire

Are you planning to pick this up? If so I'll stay out of that area of the code as much as I can.

vilhalmer avatar Apr 30 '25 13:04 vilhalmer

I can't promise anything, but if anyone provides a pull request we can review.

fire avatar Apr 30 '25 13:04 fire

My plan is to do the raw bone transforms mapping them to the Godot Humanoid via https://docs.godotengine.org/en/latest/tutorials/xr/openxr_hand_tracking.html.

Will be postponing Finger Curls and Splays until someone wants it.

fire avatar Apr 30 '25 16:04 fire

@Malcolmnixon did I miss any approaches?

fire avatar Apr 30 '25 17:04 fire

@Malcolmnixon did I miss any approaches?

I don't believe so. My https://github.com/Malcolmnixon/GodotXRHandPoseDetector project subscribes to the https://docs.godotengine.org/en/stable/classes/class_xrhandtracker.html#class-xrhandtracker events, as it provides easy access to the joint data. From there it calculates the spread and curl information.

Malcolmnixon avatar May 01 '25 01:05 Malcolmnixon

@Malcolmnixon Does the entire skeleton need to be remapped to Godot Engine Humanoid or can I leave it raw?

fire avatar May 01 '25 02:05 fire

@Malcolmnixon Does the entire skeleton need to be remapped to Godot Engine Humanoid or can I leave it raw?

It doesn't need a skeleton. The XRHandTracker data (tracking data from the XR subsystem) contains joint data you can read directly, however if you really want a skeleton, you can use an XRHandModifier3D to drive a Godot-Humanoid skeleton from the tracking data, then harvest what you want from the skeleton instead - although that would be slower.

Malcolmnixon avatar May 01 '25 02:05 Malcolmnixon

I am implementing the openvr skeleton source. Huh?

fire avatar May 01 '25 02:05 fire

Ah sorry, trying to read everything over the phone. So yes your strategy of converting the vr::VRBoneTransform_t values into Godot Humanoid and feeding the result into an XRHandTracker sounds correct - the data would then be usable by XRHandModifier3D, the old OpenXRHand, and any scripts like my HandPoseDetector plugin.

Malcolmnixon avatar May 01 '25 03:05 Malcolmnixon

I rearranged how poses are collected in #177, the skeleton actions can probably follow the pattern of always living under /actions/godot.

vilhalmer avatar Nov 04 '25 00:11 vilhalmer