Overview
This page uses Python to replay WUJI Gloveemf_poses and imu_raw/palm. Data Recording produces an MCAP file. The replay code reads that file, rebuilds the frames, and calls compute(frame) for Offline Solving.
SDK source examples: Python and C.
Prerequisites
Hardware
None. This is the only page in the series that needs no device.Software
Before You Start
To replay real data, read Recording Data first. Running the example’s synthetic frames needs no preparation.Data Flow
Channels the Pipeline Offers
The object returned byoffline_pipeline() exposes these methods:
The pipeline also provides these read-only properties:
sn, hand_side, urdf_source, and urdf_source_path.
Hand solving depends on the URDF. IMU fusion doesn’t. Swapping hand models changes only the first three methods.
Where the URDF Comes From
Create the pipeline with the capture device’s serial number and hand side. Check the serial number against the MCAP channel name. Get the hand side and model used during capture from the capture record. Raw frames in the recording don’t select a hand model automatically. To reproduce the hand outputs from capture, pass the absolute path to the URDF used then, or select the same SDK user. Checkpipeline.urdf_source and pipeline.urdf_source_path. An unreadable explicit path raises an error. If the managed model isn’t found, the SDK uses a built-in model and the results may differ. See Select and Verify the Hand Model for the lookup order.
Consistency With Online Results
This is the section worth reading.Method
- Connect a real glove and use
TopicRecorderto captureemf_poses,hand_joint_angles, andhand_skeletontogether for 4 seconds - Align the three streams by
header.seqin the MCAP file, yielding 525 common frames - Rebuild the recorded
emf_posesintoEmfPoseArrayand feed them to the offline pipeline - Subtract the offline results from the recorded online results, element by element
Results
Across the first 200 frames:
Joint angles are exactly identical. The 7-nanometer difference in skeleton positions comes from MCAP’s JSON serialization round-tripping a float, not from the algorithm.
Offline replay therefore reproduces online solving without loss. Tuning algorithms on recorded data, comparing hand models, and reproducing production issues all give trustworthy results.
Replay Code
This example readsemf_poses and imu_raw/palm from a recording and submits them to one pipeline in MCAP message order. Record both channels first. Get the serial number from /<serial-number>/emf_poses and confirm the hand side against the capture record. Use --urdf-path for the model used during capture. If you omit it, the SDK uses its normal model lookup rules.
Save this as replay_recording.py:
mcap, then replace the file path, serial number, and hand side with the values from your recording:
--urdf-path and check the reported Model. This example doesn’t write the results to a file. C applications can construct and submit the same frames as shown in the example. The application reads the MCAP file.
IMU Fusion
The fuser carries state and advances frame by frame. The example feeds a single frame, which shows nothing, so here is how it evolves over a continuous run.At Rest
Feedingangular_velocity=(0,0,0) and linear_acceleration=(0,0,9.8) for 399 frames:
Orientation locks to the identity quaternion with no drift. When gravity aligns with the ideal Z axis, the fuser produces no correction.
Rotating
Switching toangular_velocity=(0, 0, 1.0) rad/s with timestamps 5 ms apart, 200 frames (1.0 second):
One rad/s for one second should give 1 rad, or 57.30°, and the measurement reads 57.0°. That 0.3° gap exists because the first frame has no predecessor to compute a time delta against, so it doesn’t integrate. Only 199 frames integrate: 199/200 x 57.30° = 57.01°, matching the measurement.
As a result, input timestamps must be strictly increasing, because the fuser computes each integration step from the time difference between consecutive frames. The first frame always outputs the initial orientation and should not be used for decisions.
Integration Steps
See the Python example for a runnable program. The snippets below show the key calls in order. The example includes argument parsing, signal handling, and error paths.1. Create the Offline Pipeline
Use the serial number and hand side of the glove that captured the data. Reuse one pipeline for the whole replay. You don’t need to connect to a device.2. Prepare EMF Pose Frames
The Python example usesmake_emf_frame() to create synthetic frames with five fingers. For recorded data, rebuild each EmfPoseArray from the poses, confidence values, and frame header captured at the same time. Keep the frames in capture order.
3. Compute the Hand Outputs Frame by Frame
Pass each frame to the outputs you need. You can compute joint angles, fingertip poses, and the skeleton independently.4. Compute IMU Fusion When Needed
IMU fusion takes separate input. The Python example usesmake_raw_imu() to create a raw IMU frame. For recorded data, submit consecutive frames in capture order. The pipeline needs no explicit shutdown.
Running It
urdf_source reads builtin_default.
The three frames raise curl from 0.00 to 0.70, simulating fingers closing. The thumb’s fifth angle rises from 0.629 to 1.087 accordingly, in the right direction. thumb_conf stays at 0.475 because confidence on synthetic data doesn’t vary with curl.
Usage Notes
Adapting It
Compare Two Hand Models
Run the same data through two pipelines, one on the default model and one on a calibrated model, then compare joint angles frame by frame to quantify what calibration buys:Don’t Build a New Pipeline Per Frame
hand_joint_angles() returns a channel object on each call, and calling it repeatedly in a loop is fine. IMU fusion state, however, lives on the pipeline, so a new pipeline resets the fuser. Run a whole batch through one pipeline instance.
Use Synthetic Data for Regression Tests
It runs without hardware, which suits CI. The example’s hand-written three frames extend naturally into fixed-input, fixed-expected-output assertions.Related
- Recording Data: produce the MCAP files this page replays
- Hand Model Calibration: generate a URDF that matches your hand
- Setting a Custom Hand Model: switch models in an online session
- Common Data Types:
EmfPoseArray,ImuData,Pose, and related structures