Data channels & read methods
The two data families, the callback, latest-value and async read methods, and the external input source.
Data channels & read methods
pose() returns optional payload.hand / payload.wrist components. Select IMU sensors by id / location within payload.imus. pressure() provides raw readings and kPa estimates; emf() provides raw I/Q paired with hand pose. Obtaining the emf() channel selects paired acquisition, which subsequent latest() / subscribe() reads retain. See Reading raw data for fields, units and device requirements.
Wired-glove start() directly enables telemetry and supported IMUs and returns after command acknowledgement. Device streams do not depend on subscriptions; existing APIs receive data when the first frame arrives. An unavailable IMU degrades gracefully and does not block pose data.
Wireless gloves use the same device.imu() call and need matched combined-frame firmware; see Wireless IMU.
The two data families
The SDK publishes two families of data: raw values produced by the device, and values the SDK computes. They are read the same way; only how the data is produced differs:
| Raw data | SDK-processed data | |
|---|---|---|
| Typical API | pose(), imu(), pressure(), emf(), status() | skeleton(), output() |
| Algorithm package | Not required | Required for dexterous hand output, see Package management; Skeleton is provided by the SDK and needs none |
| Run mode | Not required | Required, see Runtime modes |
Raw data is covered in Reading raw data; SDK-processed data (retargeting) in Reading retargeting data.
Data reading methods
All three read methods deliver the same Sample[T]. Callback subscription is the recommended default: each sample is handled as it is produced, with no polling; use latest() when you only need the current value, and asynchronous reading in an asyncio program.
latest() and next() obtain a Sample[T]; subscribe() returns a Subscription, and the registered callback receives Sample[T]; each item of async iteration is also a Sample[T]. Field definitions: Sample[T].
Raw pose, IMU, SDK-processed data and device state all support latest(), subscribe(), next() and async iteration. After creating the SDK, select the device and prepare to read. Call subscribe() before or after startup; registering callbacks before start() is recommended to receive from the first frame:
device = glove.device()
device.pose().subscribe(on_pose)
glove.start()After startup you can still use next(), async for or add a new subscribe(); the scope of the related calls is:
| Call | Scope |
|---|---|
subscribe(), latest(), next(), async for | Usable after startup; these calls only register software subscriptions or read channel data, while start() enables the device streams. Reads wait only for data. |
unsubscribe() | Stops only that callback |
stop() | Closes the data streams |
close() | Releases the subscription registrations |
To read SDK-processed data, choose a runtime mode. Automatic reconnection advances independently, without a runner or continuous update() calls; see the section below for connection recovery rules.
Callback subscription
from qnbot_sdk import Sample
from qnbot_sdk.glove import GlovePose
def on_pose(sample: Sample[GlovePose]) -> None:
print(sample.sequence, sample.value)
device.pose().subscribe(on_pose)Register callbacks with subscribe() before or after start(); registering early is recommended to receive from the first frame. The SDK holds registered subscriptions until glove.close() or sdk.close() releases them; save the Subscription returned by subscribe() and call unsubscribe() only to stop one callback early while the SDK keeps running.
The SDK runs the callback when data arrives; keep it short. For long-running work, see Runtime modes; for exception handling, see Common questions.
Callback or sample-decoder exceptions in subscribe() do not propagate to the registering thread. See Diagnostics & errors for error reporting and application recovery. next() and async iteration deliver decoder errors to the waiting caller.
Configuring subscription delivery
Subscriptions keep only the newest pending value by default. To cap callback or async-iteration delivery rate, or to request a bounded ordered queue, create a configured channel view with SubscriptionConfig:
from qnbot_sdk import SubscriptionConfig
latest_30_hz = device.pose().with_config(
SubscriptionConfig.latest(max_rate_hz=30)
)
fifo = device.pose().with_config(
SubscriptionConfig.fifo(capacity=128, max_rate_hz=30)
)
latest_30_hz.subscribe(on_pose)
async for sample in fifo:
process(sample)latest() coalesces pending values. fifo() preserves order up to capacity and drops the oldest pending value when full. max_rate_hz is an upper delivery bound; the first available value is still delivered immediately. The configuration affects only later subscribe() calls and async for on that view. It does not mutate the original channel or existing subscriptions, reduce SDK/algorithm computation, or change latest() and next() semantics.
Without max_rate_hz, a plain subscribe() or SubscriptionConfig.latest() (or SubscriptionConfig.latest(None)) adds no delivery-rate ceiling. An explicitly configured rate limits only its own subscription. The SDK imposes no SDK-wide 200 Hz delivery cap; throughput at higher input rates depends on the input and application processing capacity, and latest can still coalesce pending data.
Callback work counts within the configured delivery period; Python asynchronous reading also stops adding a full period after processing. Evaluate cadence over the time window between the first and last deliveries, allowing up to one sample of boundary allowance; an individual delivery interval may be shorter than the configured period. With sufficient input and lightweight processing, delivery can approach the configured rate more closely. Input rate, application processing time and OS scheduling still affect the observed rate; exact timing is not guaranteed. Idle time or processing overruns do not earn credit, and missed periods are not replayed as catch-up deliveries. latest still coalesces pending values, and fifo remains bounded. Review the processing budget in the migration guide before upgrading.
For a complete runnable example, see subscription_config.py.
Getting the latest value
pose = device.pose()
sample = pose.latest()
if sample is None:
print("No pose received yet")
else:
print(sample.sequence, sample.value)latest() does not block. It returns None when there is no data yet, otherwise it returns Sample[T]. It is suitable for reading the current value from other logic during runtime, or for reading the last piece of data after run_forever() returns and before close().
Asynchronous reading
await next() waits for the next piece of data, and async for reads continuously. Raw pose/IMU can be read right after start() succeeds, without choosing a run mode; just keep the asyncio event loop running:
import asyncio
from qnbot_sdk import Sdk
from qnbot_sdk.glove import GloveConfig
async def main() -> None:
sdk = Sdk(devices=(GloveConfig(),))
glove = sdk.glove()
try:
pose = glove.device().pose()
glove.start()
try:
first = await pose.next()
print(first.value)
async for sample in pose:
print(sample.value)
finally:
glove.stop()
finally:
await asyncio.to_thread(glove.close)
if __name__ == "__main__":
asyncio.run(main())Cancelling the task that awaits next() or iterates asynchronously raises Python's native asyncio.CancelledError.
The SDK coalesces duplicate data notifications before posting to asyncio and keeps the latest value, reducing backlog when the event loop is busy. The SDK stops and cleans up during interpreter shutdown, but normal paths should still close explicitly.
Asynchronous reading of IMU works the same way as pose.
The max_rate_hz delivery period includes callback processing time; only the remainder of the period is waited, rather than a full period after processing. The first available sample is delivered immediately. Scheduling jitter can vary individual intervals, so this is not a fixed sampling frequency. async for uses the same timing rule.
External input
When there is no physical glove, or when the frames come from your own device or a simulated hand, ExternalConnection and push_frame() feed external hand frames as the input source. External frames join the same data path as a physical glove: raw poses are read directly, and the SDK computes the retargeting result.
Configuration and usage
External input has no device identity handshake, so side must be configured explicitly in GloveConfig:
from qnbot_sdk import Side
from qnbot_sdk.glove import ExternalConnection, GloveConfig
glove_config = GloveConfig(
side=Side.RIGHT,
connection=ExternalConnection(),
)After configuring the target, first subscribe to the output and start the SDK, then keep submitting external frames:
device = glove.device()
output = device.output(name="hand")
output.subscribe(lambda sample: print(sample.value.joints))
device.start()
glove.run_background()
pose = device.push_frame(frame)push_frame() synchronously returns the GlovePose corresponding to the current frame; the target joint result is read via output(), not the return value of push_frame(). The example uses background mode.
External input uses the background or manual runtime: keep calling push_frame(frame) in background mode; in manual mode, submit each frame before calling update(). If the first run requires calibration, complete Capture and Calibration before expecting target output. See the complete background and manual update examples.
Glove supports automatic terminal calibration for external input. Background startup returning does not mean readiness; keep supplying frames during capture and calibration. See the runtime notes for startup, manual waiting, and error handling.
Frame constraints
- The five fingertip poses (
thumb,index,middle,ring,pinky) are required, and each is aGloveNodePose. positionis three finite floating-point numbers, in meters.quaternion_xyzwis four finite XYZW components with a non-zero overall norm; the SDK normalizes them before use.timestamp_msmay be omitted; when provided it must be a finite number of milliseconds and strictly increasing for the same device; when omitted, the current shared time reference is used. See Timestamps & external time sync for the time unit, default reference, and synchronization flow.timestamp_secis retained only for compatibility with existing code. The SDK multiplies it by1000to convert it to milliseconds; do not set it together withtimestamp_ms.
The SDK defines the input units and quaternion component order, but the coordinate origin, X/Y/Z axis directions, and relative rotation reference frame are determined by the algorithm package, and must be consistent with the product documentation of the selected algorithm package. side is not passed with the frame; the device identifier and sequence are generated by the SDK from the current configuration. For fields, types and nullability, see ExternalGloveFrame and GloveNodePose.
Starting streams, reading, and recovery
start() starts device streams. subscribe(), latest(), next(), and asynchronous reads observe data and do not enable hardware streams.
Subscribe before or after starting. Wait for the first valid frame after start() returns; latest() may be empty until then.
Stream failures are reported through startup errors or device status; repeated reads do not resolve a failed start.
IMU availability on a directly connected glove depends on the device/firmware; unavailable IMU does not imply unavailable pose data.
Connection recovery operates independently of target algorithm scheduling, including applications reading only raw data.
Algorithm outputs still require a runtime mode, and external sources still require continued push_frame() calls.
See Configuration reference for subscription pacing.