SDKPython SDK

Reading raw data

Glove pose, IMU and device status: produced by the device, no algorithm package needed.

Current version · 1.4.0

Reading raw data

This chapter covers values produced directly by the device firmware, with no algorithm package: after start(), pose is published with valid device frames, and IMU is published when a device frame carries it. run_forever(), run_background() and update() neither generate this data nor change its publishing rate. For the full source description, see Data channels & read methods.

Glove pose

device.pose() should be obtained after the SDK is created and the device is selected. When processing pose continuously, put the parsing logic into a callback and register it before startup:

from threading import Event

from qnbot_sdk import Sdk
from qnbot_sdk.glove import GloveConfig

def on_pose(sample):
    pose = sample.value
    print(pose.meta.source)
    print(pose.payload.root_pose.position)
    print(pose.payload.root_pose.quaternion_xyzw)
    print(pose.payload.fingertip_world)
    print(pose.payload.fingertip_local)
    print(pose.payload.raw_valid_mask)
    print(pose.payload.held_mask)
    print(pose.payload.quality_flags)

sdk = Sdk(devices=(GloveConfig(),))
glove = sdk.glove()
try:
    glove.device().pose().subscribe(on_pose)
    glove.start()
    Event().wait()
finally:
    glove.close()

Choose a read path by what you need:

What you want to doRead path
Split frames by their source (several gloves or inputs)meta.source
Place the wrist or palmpayload.root_pose
Put a virtual hand in world coordinates, drive an external skeletonpayload.fingertip_world
Retarget or compute against the wristpayload.fingertip_local
Skip fingers whose raw data is invalidpayload.raw_valid_mask
Spot fingers reusing their previous valid valuepayload.held_mask
Judge the quality of the whole framepayload.quality_flags

For complete fields, types and nullability behavior, see GlovePose and GloveFeaturePayload.

IMU (experimental feature)

device.imu() is used to read the GloveImu raw counts provided by a USB serial device in the data JSON:

from threading import Event

from qnbot_sdk import Sdk
from qnbot_sdk.glove import GloveConfig

def on_imu(sample):
    imu = sample.value
    print(imu.payload.valid)
    print(imu.payload.gyroscope_raw)
    print(imu.payload.accelerometer_raw)

sdk = Sdk(devices=(GloveConfig(),))
glove = sdk.glove()
try:
    glove.device().imu().subscribe(on_imu)
    glove.start()
    Event().wait()
finally:
    glove.close()

gyroscope_raw and accelerometer_raw are both three signed 16-bit integers, corresponding in order to the three axes in the device protocol. The SDK does not perform unit conversion, calibration or pose fusion on this data. When valid is False, the raw counts are still retained and published; you can decide whether to use them according to your actual use case. Currently only IMU in wired USB serial JSON is supported; the binary IMU of the wireless receiver is not supported in this version.

Choose a read path by what you need:

What you want to doRead path
Tell whether this reading can be usedpayload.valid
Read the raw three-axis gyroscope countspayload.gyroscope_raw
Read the raw three-axis accelerometer countspayload.accelerometer_raw

For complete fields, types and nullability behavior, see GloveImu and GloveImuPayload.

Device status

device.status() is also produced directly by the device rather than computed: whether it is connected, whether data is stale, the last error and the reconnect count. See Diagnostics & errors for the fields and how to use them for diagnosis.