Calibration
Calibration status and progress, and starting calibration manually.
Calibration
Before manual calibration, start the target device in CalibrationMode.MANUAL. Stopping, disconnecting, or closing the device cancels active calibration; the session and unfinished tasks report Cancelled with code "cancelled".
Calibration uses a completed capture.
When a new capture replaces the previous Capture for the same wearer and glove, the SDK invalidates calibrations derived from the old capture content; the next start of that source follows the current calibration policy again. If the Capture file is only temporarily unreadable during SDK construction, construction reports the I/O error but preserves the existing calibration record instead of treating the read failure as stale content. Restore file access and recreate Sdk to retry.
Complete reuse of unchanged Capture data keeps existing compatible calibration valid. Cancelling an unfinished calibration session discards this attempt’s new results, preserves the previous successful compatible results and completed capture data, and must not be used to retain partial results. Stopping after calibration has completed does not revoke the successful results.
Optional configuration: to adjust fingertip offsets or load personal bone profiles, see Hand model parameter configuration.
When a new capture fully reuses the current compatible data without changing it, the SDK preserves matching calibration. Capturing replacement data invalidates calibration derived from the replaced data.
Calibration readiness
device.calibration_status() is a synchronous, read-only snapshot with three call forms:
from qnbot_sdk import TargetName
# The device has a single target: omit the name
readiness = device.calibration_status()
# Multiple targets: name the one you want
readiness = device.calibration_status(name="dexhand")
# Skeleton: use TargetName.SKELETON
readiness = device.calibration_status(name=TargetName.SKELETON)Omitting the name requires the current device to have exactly one matching target; when the configuration already determines the device and target uniquely, the query can be made before start(), because the device and identity checks are already complete when the SDK is created.
The returned CalibrationReadiness has two fields: state and operator_id. state has three values:
state | Meaning |
|---|---|
NOT_REQUIRED | The target does not require calibration |
READY | All required calibration steps have a compatible and valid record for the current wearer |
NEEDS_CALIBRATION | At least one required calibration step is missing, invalid, or incompatible, or the current settings require recomputation |
operator_id is the wearer used for this determination; it comes from AlgorithmsConfig.capture.operator_id, and the caller does not need to pass another identifier.
For the complete fields, types, and nullability behavior, see CalibrationReadiness.
The value belongs to the current Sdk instance: to re-read saved calibration data, create a new Sdk.
Calibration progress and results
Read the computation status of the current target via device.calibration_progress():
| Read path | Meaning |
|---|---|
job.target_id | The target corresponding to the current calibration job |
job.state | The calibration status of the current target |
job.failure | The failure information of the current target |
For the complete fields, types, and nullability behavior, see CalibrationProgress.
A CalibrationSession always uses the capture from the completed CaptureSession and computes and saves results in the order of targets. After saving succeeds, the SDK automatically applies the calibration result, with no need to call additional interfaces. A calibration failure does not delete an already saved capture. For the complete fields, types, and nullability behavior, see CalibrationSessionSnapshot and CalibrationResult.
Results after stopping calibration
A cancelled calibration discards that session's new results.
When request_stop(), device stop, disconnect, or close interrupts calibration, terminal Cancelled means all new results from that session have been discarded and the preceding compatible successful calibration remains available. If no compatible result existed, the next start still requires calibration. Completed capture data remains available for another compatible calibration attempt.
Stopping after normal session completion preserves its successful results. Accepted explicit session cancellation follows the same discard behavior; cancellation can be rejected once activation of the complete result batch starts, so read the actual terminal state. Display Cancelled as “calibration interrupted” and treat only Completed as success for this attempt. See the migration guide for upgrade actions.
Starting calibration manually
When you need to decide for yourself when to start calibration, call start_calibration() on the same GloveDevice used for capture, passing in the completed CaptureSession that is still open. For the full capture-to-calibration session flow, see Starting capture manually.
Start an ordered calibration Session for targets whose capture has been completed:
from qnbot_sdk.glove import (
CalibrationJobState,
CalibrationSessionState,
)
calibration = device.start_calibration(
completed_capture_session=left_session,
targets=("dexhand",),
)
while True:
snapshot = calibration.snapshot()
render_calibration_session(snapshot)
if snapshot.state is CalibrationSessionState.COMPLETED:
break
failed = next((job for job in snapshot.jobs if job.state is CalibrationJobState.FAILED), None)
if failed is not None:
raise RuntimeError(failed.failure.message if failed.failure else "calibration failed")
if snapshot.state is CalibrationSessionState.CANCELLED:
raise RuntimeError("calibration cancelled")
glove.update().sleep()
results = calibration.result()
if results is None:
raise RuntimeError("completed calibration has no result")
calibration.close()
left_session.close()A single manual calibration can pass multiple targets to targets, and the SDK completes computation and saving in the order passed. For how to configure and read the output when one source drives multiple targets, see One-to-Many.
When selecting Skeleton, use TargetName.SKELETON or the string "skeleton" in targets. If you also need to subscribe to Skeleton output, call device.skeleton() of the corresponding device after the SDK is created and before start().
The snippets show the main flow; the application supplies the render_* functions. Set a timeout and close Sessions on cancellation or failure. For interaction, timeouts, and resource cleanup, see the runnable example linked from Starting capture manually.
Complete calibration-file export and replay
After a target successfully produces output, Glove/Core supports device.export_calibration(destination, target) to export its active algorithm configuration, bone configuration and calibration result as a complete .qnbotkey file. Choose a new destination. Specify target when multiple targets exist. Export reports unavailable when the current route has no valid calibration.
Before creating another application's SDK, set TargetAlgorithm.calibration_key to the file and match its target and hand side. Omitting it retains the default capture/calibration workflow. See Configuration reference for configuration and GloveDevice for the export return value.