SDKJava (Android) SDK

Hand skeleton visualization

Android Java SDK: Hand skeleton visualization

Current version · 2.0.0

Hand skeleton visualization

The Android SDK does not ship a built-in viewer. It provides HandSkeletonPose, and the app draws the 25-point skeleton with any 3D renderer.

Read the skeleton

Skeleton.run(...) selects the built-in skeleton and subscribes to both jointAngles() and pose() before start, then starts the runtime loop. The former returns HandJointCommand for driving a robot hand; the latter returns HandSkeletonPose for display. The example class shares its name with com.qnbot.sdk.glove.Skeleton, so the source declares the SDK skeleton with its fully qualified name.

import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
import com.qnbot.sdk.glove.GloveDevice;

/**
 * Reads the built-in skeleton's joint angles and wrist-local pose.
 *
 * <p>Pass the host {@link Context}, an authorized transport, the glove port and side. The skeleton
 * is selected before start; its subscriptions print joint commands and pose nodes.
 */
public final class Skeleton {
  private Skeleton() {}

  public static void run(Context context, SerialTransport transport, String port, Side side) {
    SdkConfig config = SdkConfig.builder()
        .device(GloveConfig.builder()
                    .name("primary")
                    .side(side)
                    .connection(SerialConnection.port(port))
                    .build())
        .build();
    try (Sdk sdk = new Sdk(config, context, transport); Glove glove = sdk.glove()) {
      GloveDevice device = glove.device();
      com.qnbot.sdk.glove.Skeleton skeleton = device.skeleton();
      skeleton.jointAngles().subscribe(sample
          -> System.out.println("skeleton sequence=" + sample.sequence
              + " target=" + sample.value.target + " joints=" + sample.value.joints));
      skeleton.pose().subscribe(sample
          -> System.out.println("skeleton pose sequence=" + sample.sequence + " nodes="
              + sample.value.names.size() + " wrist=" + sample.value.positionsLocal.get(0)));
      glove.start();
      glove.runForever();
    }
  }
}

HandSkeletonPose provides names, positionsLocal, orientationsLocalXyzw, coordinateFrame, handSide and timestampMs.

Drawing steps

  1. Select the skeleton with device.skeleton() and subscribe to skeleton.pose() before start, then start the runtime loop.
  2. Read the fixed 25 nodes' positionsLocal and orientationsLocalXyzw by index in names.
  3. Convert local coordinates to world space with the app's wrist root transform; see Coordinate frames & poses.
  4. Connect and render joints by their parent-child relationship; node 0 is the wrist.

Draw

Match positions and rotations by the same index in names; positions are in wrist-local space. Apply the app's hand root transform before drawing in world space. Quaternions are xyzw. Parent-child relationships follow the joint naming convention; use the joint set confirmed by the delivery.

Helix can provide a separate wrist pose through device.pose().payload.wrist. Check presence, valid, fresh, timestampMs and coordinateFrame, then correlate it with Skeleton output by time and frame before constructing the scene's hand-root transform.

Keep it separate from robot-hand output

Use HandSkeletonPose to display the hand skeleton. jointAngles() returns HandJointCommand for driving a robot hand. Do not mix the two.