Hand skeleton visualization
Subscribe to Skeleton output, draw a 25-node skeleton, and display a hand with MuJoCo or your own model.
Hand skeleton visualization
Scope
This guide explains how an independent application subscribes to QnBot SDK hand output and displays it with MuJoCo, Unity, Unreal, Three.js, or another renderer. It requires the SDK distribution, the selected renderer, and model assets. The desktop app is not required.
Dynamic OpenXR outputs 25 skeleton nodes and 25 active joint angles. For node and segment drawing, look up node names from pose(). To drive a model, map the joint names from joint_angles() to the model’s joints.
First read Reading retargeting data and verify Skeleton output before adding a display.
Choose a display approach
| Goal | Channel | Application work | Display assets |
|---|---|---|---|
| Joint markers, bone segments, or a debug view | device.skeleton().pose() | Draw spheres and lines or cylinders from positions | No appearance mesh; the Skeleton runtime is still required |
| The skinned hand supplied with the SDK | device.skeleton().joint_angles() | Load the XML with MuJoCo and update joints by name | XML for the correct hand, .skn, and every referenced asset |
| A custom hand or game engine | Usually joint_angles(); pose() can also be adapted | Map joints, convert coordinates, and bind the skin | An engine-supported skeleton and mesh, such as your own FBX or glTF |
Start with pose() to verify data, then add the appearance model. A skeleton-point display does not require MuJoCo. MuJoCo is a convenient choice when reusing the supplied XML and high-resolution skin. Other engines require model adaptation.
device.pose() contains the device's captured pose; device.skeleton().pose() contains the solved 25-node hand skeleton; device.output() contains output from a configured target. Use the Skeleton channels for the human hand described here.
Prepare runtime and model assets
Dependencies
| Dependency | Requirement |
|---|---|
| SDK development package | Public headers, libraries, and build configuration for the selected language and version |
| SDK runtime | Dynamic libraries and dependencies matching the operating system and CPU architecture |
| Built-in Skeleton runtime | Native solver, dependencies, and hand definitions, normally distributed with the SDK runtime |
| Device and user data | Correct hand side, supported input, valid authorization, and compatible capture/calibration records; complete the required interaction on first use |
| Renderer and graphics environment | Install the selected renderer and its graphics dependencies. |
| Model assets | Required for the skinned hand; unnecessary when drawing only nodes and segments |
Run the solver without a window if needed. For rendering, create a graphics context for the selected backend. On a headless Linux host, select EGL or OSMesa if supported by your MuJoCo version and driver. Desktop programs can use a window context.
Resolve asset paths
Supply the SDK runtime root through the installer or application configuration and preserve the distribution's relative directories. The application manages version selection, installation paths, and library search paths.
A distribution with the built-in skeleton package has the following layout. The <algorithm-package> directory varies by release:
<sdk-runtime>/
lib/
share/qnbot/glove/algorithms/skeleton/<algorithm-package>/
RELEASE_MANIFEST.json
lib/
share/qnbot_hand/
hands/dynamic_openxr_hand/
dynamic_openxr_hand_system.yaml
pose_library.yaml
resources/
mujoco/left.xml
mujoco/right.xml
mujoco/left_skeleton.xml
mujoco/right_skeleton.xml
meshes/left/visual/left_hand_hd.skn
meshes/right/visual/right_hand_hd.skn
meshes/<side>/visual/*.obj
meshes/<side>/collision/*.obj
pinocchio/*.urdf- Locate the built-in skeleton package matching the SDK release and read that package's
RELEASE_MANIFEST.json. - Check
package_id, version,platform,architecture, and ABI compatibility. The listed sizes and hashes can be used to verify asset integrity. - Resolve
native_libraryandresource_rootrelative to the algorithm package directory. Forresource_root: share/qnbot_hand, the resource root is<algorithm-package>/share/qnbot_hand. - Select
hands/dynamic_openxr_hand/resources/mujoco/left.xmlorright.xmlbeneath that root and preserve the relative paths of referenced files.
Preserve the distribution layout and make both libraries and their dependencies visible to the system loader. On Windows, deploy the dependent DLLs shipped beside the algorithm library.
left.xml and right.xml reference a bound skin through .skn. Segmented OBJ files, URDF files, and *_skeleton.xml serve different geometry or kinematics use cases and do not reproduce the same appearance. Keep the solver's runtime assets intact. Before reducing a separate renderer's asset set, inspect every XML reference.
Subscribe to skeleton output
Lifecycle and calibration
- Create the SDK with the device connection, hand side, and operator identity.
- Obtain and retain the device's
skeleton()capability beforestart(). - Subscribe to
pose()orjoint_angles()and retain the subscription handles. - Call
start()to connect and start the configured scope, then run the SDK scheduling loop. - Complete capture/calibration or reuse compatible records. Display the model once the capability is ready and new samples are arriving.
- On exit, call
request_stop()andjoin(), unsubscribe, then callstop()andclose().
skeleton() configures a capability before startup. After startup, use the object you retained instead of calling device.skeleton() again. For two hands, retain separate capabilities, subscriptions, and latest-frame caches. Select devices explicitly by name or side when more than one is configured.
Use the SDK terminal interaction in terminal programs. For GUI or service applications, follow Capture and Calibration to display capture requests and submit the user’s confirmation through the external interaction APIs.
Subscription example
This is an integration fragment, assuming sdk is configured and compatible capture/calibration records are ready. Your application supplies thread-safe latest-frame caches named latest_pose and latest_angles, with a store() method, and implements the display loop.
from copy import deepcopy
skeleton = sdk.glove().device().skeleton() # Obtain before start().
pose_subscription = skeleton.pose().subscribe(
lambda sample: latest_pose.store(deepcopy(sample))
)
angles_subscription = skeleton.joint_angles().subscribe(
lambda sample: latest_angles.store(deepcopy(sample))
)
sdk.start()
sdk.run_background()
# Run the application's display loop on the graphics thread.
# Handle capture/calibration interaction if compatible records are unavailable.
sdk.request_stop()
sdk.join()
pose_subscription.unsubscribe()
angles_subscription.unsubscribe()
sdk.stop()
sdk.close()Also perform cleanup on exceptional exit. Retain subscriptions while receiving, and keep the caches alive longer than the callbacks.
connect() is a deprecated compatibility no-op, and disconnect() delegates to stop(). New applications use start(), stop(), and close() without additional connection or disconnection calls. See the SDK lifecycle API.
After start(), advance the solver with one execution mode: background run_background(), foreground run_forever(), or manual update() in your own loop. In background mode, the rendering thread reads samples from the cache. See Runtime modes.
Samples, polling, and threads
Sample<T>.value contains the payload, sequence identifies new samples, and source_time is producer time; SDK-generated Glove time follows Unix milliseconds or the reference set by sync_time(). observed_at is monotonic milliseconds since SDK creation, not Unix time. Both HandSkeletonPose.timestamp_ms and HandJointCommand.timestamp use milliseconds inherited from the input frame. Compare timestamps only within the same clock domain. The external-input compatibility field timestamp_sec is not a skeleton-output field.
For polling, use the retained capability's skeleton.pose().latest() or skeleton.joint_angles().latest(). Results can be empty, and repeated reads can return the same sample. Deduplicate using the sequence number.
- Track the last sequence per device and channel, and reset tracking after rebuilding the connection or SDK.
- Use each channel’s
sequenceto detect new samples. To pair samples across channels, match timestamps on a shared clock within the allowed tolerance. - In callbacks, validate and copy the sample into a latest-frame cache. Do not perform GPU, MuJoCo, or encoding work in the callback.
- Render the newest value at the display rate. Discard historical frames that cannot be displayed in time.
- Mark data stale when updates stop or the device disconnects. You may retain the last valid pose; do not replace missing samples with all-zero joint angles.
Payload fields are documented in HandSkeletonPose, HandJointCommand, and Sample.
Draw the 25-node skeleton
Positions and topology
Use names to map each node to its position. The positions in positions_local are in meters and share the wrist_local reference frame. They are not parent-relative offsets and must not be accumulated down the hierarchy. Positions alone are sufficient for drawing markers and segments.
Connect these five chains by name:
wrist → thumb_metacarpal → thumb_proximal → thumb_distal → thumb_tip
wrist → index_metacarpal → index_proximal → index_intermediate → index_distal → index_tip
wrist → middle_metacarpal → middle_proximal → middle_intermediate → middle_distal → middle_tip
wrist → ring_metacarpal → ring_proximal → ring_intermediate → ring_distal → ring_tip
wrist → little_metacarpal → little_proximal → little_intermediate → little_distal → little_tipThis produces 25 nodes and 24 segments. The skeleton uses little, while other input interfaces may use pinky. Do not infer topology from array or dictionary iteration order.
Drawing steps
- Validate matching name/position counts, required nodes, and finite coordinates.
- Place a sphere, marker, or instanced mesh at each position.
- For each parent/child pair, calculate
direction = position[child] - position[parent]and its length. - Place a cylinder at the midpoint, align its length axis with
direction, and set its length to the distance. Skip zero-length segments. - Put the whole hand under one scene root, then configure the camera, lighting, and display scale.
Convert units, up axes, and coordinate handedness for the target engine while keeping the original SDK data unchanged. Convert rotations using a coordinate-basis transform; swapping quaternion components alone does not perform an arbitrary basis conversion. See Coordinate frames & poses.
Render the skinned hand with MuJoCo
Load the model and map joints
Create MjModel and MjData from left.xml or right.xml for the correct side. Cache the mapping from SDK joint name to MuJoCo joint ID to qpos address. The supplied model has 25 active hinge joints with angles in radians.
The following Python fragment is renderer-side code. It consumes an already available HandJointCommand.joints name/radian mapping; it does not subscribe to the Python SDK. model_path and latest_joints are supplied by the application, and expected_joint_names contains the 25 names below with their side prefixes.
import math
import mujoco
model = mujoco.MjModel.from_xml_path(str(model_path))
data = mujoco.MjData(model)
addresses = {}
for name in expected_joint_names:
joint_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_JOINT, name)
if joint_id < 0:
raise ValueError(f"Model is missing SDK joint: {name}")
if model.jnt_type[joint_id] != mujoco.mjtJoint.mjJNT_HINGE:
raise ValueError(f"Expected a single-axis hinge joint: {name}")
addresses[name] = int(model.jnt_qposadr[joint_id])
def apply_joint_angles(joints):
values = {name: float(joints[name]) for name in addresses}
if not all(math.isfinite(value) for value in values.values()):
raise ValueError("Joint angles must be finite")
for name, value in values.items():
data.qpos[addresses[name]] = value
mujoco.mj_forward(model, data)
# Create and use Renderer on a thread with a valid graphics context.
renderer = mujoco.Renderer(model, height=480, width=640)
try:
apply_joint_angles(latest_joints)
renderer.update_scene(data)
pixels = renderer.render()
# Send pixels to the application's window, texture, or encoder.
finally:
renderer.close()For each display frame, consume the newest joints, update qpos, call mj_forward, update the scene, and render. Forward kinematics is enough to display an SDK pose; mj_step is unnecessary. Physical interaction requires its own controller and simulation stepping so that simulation results do not unintentionally overwrite the displayed pose.
Writing qpos directly does not enforce joint ranges. Validate and report invalid angles, then reject or clamp them according to application requirements. Missing expected joints in the supplied model indicate a resource or version mismatch. Joint IDs and qpos addresses are different indices; do not assign SDK container order directly to qpos[:].
Active joint names
Add left_ or right_ to each name:
| Finger | Names without the side prefix |
|---|---|
| Thumb (6) | thumb_cmc_abduction, thumb_cmc_flexion, thumb_cmc_opposition, thumb_mcp_abduction, thumb_mcp_flexion, thumb_ip_flexion |
| Index (4) | index_mcp_abduction, index_mcp_flexion, index_pip_flexion, index_dip_flexion |
| Middle (4) | middle_mcp_abduction, middle_mcp_flexion, middle_pip_flexion, middle_dip_flexion |
| Ring (5) | ring_cmc_cup, ring_mcp_abduction, ring_mcp_flexion, ring_pip_flexion, ring_dip_flexion |
| Little (6) | little_cmc_opposition, little_cmc_cup, little_mcp_abduction, little_mcp_flexion, little_pip_flexion, little_dip_flexion |
Adapt another engine or model
Drive bones with joint angles
In Unity, Unreal, and Three.js, load a skinned model supported by the engine or convert the MuJoCo XML and .skn offline. When exporting FBX or glTF, preserve the skeleton hierarchy, skin weights, and bind pose. If you start with only OBJ, supply those separately.
Preserve or reconstruct the hierarchy, joint axes, rest pose, bone lengths, left/right definitions, weights, and bind transforms. Map each SDK joint to a target bone, axis, angle direction, zero offset, and range. When several SDK degrees of freedom drive one bone, compose them using that model's axes and rotation order rather than assigning arbitrary Euler components.
Update bone-relative rotations on the rendering thread, then let the engine compute world transforms and skinning. Validate individual degrees of freedom before testing an open hand, fist, thumb opposition, and both hand sides.
Adapt the 25 positions
pose() directly supports a skeleton wireframe. A custom skin needs bone transforms derived from directions, rest poses, and available orientation data, with retargeting or IK where needed.
Use joint positions to draw bone segments. To drive bone twist in a skinned model, use orientations_local_xyzw, convert the rotations from wrist space to parent-relative rotations, and compensate for the bind pose.
Wrist placement and personal bone lengths
Rotate the whole hand
Skeleton describes hand shape relative to the wrist. Apply an overall transform to the hand scene root to show whole-hand orientation. A provided payload.wrist is an independent wrist pose. Check presence, validity, timing and coordinate_frame first. For ordinary gloves, an application can fuse IMU data or use another tracker. See Coordinate frames and poses.
To estimate wrist orientation from IMU data, select valid readings, convert units according to the value type, correct sensor bias, and run sensor fusion. Use an external tracker if you need absolute position or a stable long-term heading.
Check both order and frame: Skeleton orientations use XYZW, whereas MuJoCo quaternion APIs normally use WXYZ. Apply the whole-hand transform to the hand and skin while keeping the ground, lights, and camera independent. The supplied XML root is not a free joint into which an arbitrary quaternion can be written; use an appropriate scene-root or model transform instead of writing it into finger qpos entries.
Personal bone lengths and skin binding
For profile paths, operator_id, and use_bone_config, see Hand model parameter configuration. The following explains how to keep the display model consistent with those parameters.
For a display matching the operator, the solver and model must use the same personal parameters. Bone profiles are stored at:
<application-data-root>/glove/bone-configs/<encoded-operator_id>/left.yaml
<application-data-root>/glove/bone-configs/<encoded-operator_id>/right.yamlBefore creating the SDK, set QNBOT_SDK_HOME to an absolute path. If unset or empty, the SDK falls back to QNBOT_HOME; if both are unset or empty, it uses .qnbot in the user's home directory. The SDK and renderer must resolve the same data root. Operator directory encoding preserves UTF-8 bytes for letters, digits, -, and _, and percent-encodes the remaining bytes as %HH. Do not concatenate unprocessed user input into a path.
The renderer must read the hand-system configuration and inheritance, then apply the profile according to the selected version. Loading static XML does not automatically apply SDK bone profiles. Keep palm layout parameters consistent as well as finger lengths.
Adjust bone body offsets and collision geometry in memory or an application-owned asset copy, retaining valid resource references. With .skn, update the rest mesh and bone bind positions and rebind as required. Other engines also need matching skeleton and skin updates. Changing only bone length or mesh scale can cause stretching, misalignment, and incorrect fingertip positions.
Deployment and validation
Use the flow “SDK acquisition and solving → latest-frame cache per hand → model update → window, texture, or video output”. Serialize MuJoCo model updates and rendering on one thread or through explicit synchronization; do not render while another thread mutates MjData.
Check the following before delivery:
- The SDK, Skeleton library, and dependencies load without the desktop app installed, using matching distribution assets.
- Both first-time capture/calibration and compatible-record reuse reach a ready state and produce new
pose()andjoint_angles()samples. - Nodes are complete and finite, units and frames are correct, all 25 joints are mapped, and hand-side assets match.
- Referenced skin assets are present; the graphics backend creates, renders, and releases its context successfully.
- Finger flexion, spread, thumb opposition, and left/right behavior are correct. Whole-hand orientation affects only the hand root.
- Personal bone profiles, if used, match the solver and display model without unexpected skin deformation.
- Stale samples, disconnection, rebuilding, and exceptional exit are handled without accumulating delayed display frames.
The resource layout and joint definitions in this guide use the bundled qnbot_hand.dynamic_openxr_hand 0.3.4 assets. Validate SDK libraries, solver, calibration compatibility, and models together when changing versions.