Skip to main content
Wuji SDK writes multiple subscribable resources to one MCAP file for offline analysis, algorithm debugging, and dataset creation. During recording, you can pause, resume, monitor data quality, or switch output files. After stopping, you can view a statistical summary.

Recorder Configuration

Compression Options

Set the compression algorithm and MCAP chunk size independently. The default chunk size targets 4 MiB of uncompressed data per chunk. LZ4 is the default compression algorithm.
compression accepts "lz4", "zstd", or "none". Omit chunk_size to use the default.

Register Channels

Each channel represents a public resource that supports subscriptions. Connect a device as described in Device Discovery and Connection. Device channel names in MCAP have a serial-number prefix. Registering the same channel twice returns an error. Choose resources for the connected device: The following examples show how to register recording channels for Wuji Hand 2. To record Wuji Glove, use the corresponding resources in the table above and follow the substitutions in Examples.
Pass a subscription object. The recorder reads its resource and device metadata.

Recording Global Resources

Register global resources alongside device channels. For example, tf_static records global static transforms without a device prefix in its MCAP channel name.
Use manager = SdkManager.instance() from the connection example.

Recording Session

Start Recording

Register at least one channel, then start recording with an output path. Each start returns an independent session for control and monitoring.
Starting a recording overwrites an existing file and doesn’t create parent directories. Create the output directory first, and choose a separate filename for each recording. A failed start can leave an incomplete file.

Pause and Resume

Pause and resume complete after the state change takes effect. Device data still arrives during a pause, but it isn’t written to the file or replayed when recording resumes.

Episode Switching

Reuse a recorder without registering its channels again. Stop each episode, then start the next with a new path to create a separate MCAP file. Each episode below records for 10 seconds.
Run this inside an async function with import asyncio.

Recording Monitoring

Monitor frame drop rate, inter-frame jitter, and sync offset during recording. Status and quality updates coalesce to the latest value, so don’t count notifications to measure recorded frames. See QualityMetrics for all fields and per-channel health details.
Create a background task inside an async function so recording control can continue.

Quality Alerts

Statistical process control (SPC) monitoring emits alerts when quality metrics exceed thresholds for a sustained period. Each alert includes the metric, current value, threshold, and message.
If the consumer falls behind, the SDK skips missed alerts, logs the count, and continues the iterator.

Recording Status

Status updates include the recording state, written message count, and elapsed time.

Monitor Lifecycle

Cancel and await monitoring tasks when monitoring ends. Canceling a task doesn’t stop recording. A stream ending doesn’t confirm that the file was written successfully. Call await handle.stop() to finish the file and check for errors.

Recording Results and Cleanup

Recording Summary

Stop recording to retrieve the total message count, file size, duration, quality statistics, and per-channel message counts. Channels are sorted by ID and include channels with no messages. total_frames sums MCAP messages across channels. When recording Wuji Hand 2 joint_states and joint_diagnostics, count each stream separately. The total does not represent the number of raw device samples. duration_s includes pauses and buffer draining, but excludes file finalization, flushing, and waiting for callbacks to exit.

Message Timestamps

Each MCAP message includes log_time and publish_time. log_time is when the host receives the message. publish_time comes from FrameHeader.timestamp_us, converted to nanoseconds to preserve the device-side event time. For messages with valid device timestamps, downstream tools can align streams on publish_time without transport and queuing latency. For resources without a FrameHeader (such as scalar parameters) and frames with timestamp_us=0, publish_time falls back to the host receive time. The alignment described above doesn’t apply to those messages. Device timestamp meaning depends on synchronization state. See Time Synchronization and Coordinate Transforms.

Control and Cleanup

Stop recording explicitly and check the result, then finish monitoring, release resources, and disconnect the device. Stopping the same session again returns an error.
Recording operations report errors through exceptions. This snippet finishes the three monitoring tasks created above. Run cleanup in a finally block.
Stop recording in a finally block even if recording control fails. await handle.stop() raises file-finalization errors.

Examples

The following examples use Wuji Hand 2. They connect to the device by serial number and write joint_states and joint_diagnostics to an MCAP file. They record for 5 seconds, pause for 2 seconds, record for another 5 seconds, and print total and per-channel message counts. Pass DEVICE_SN and an output file path as arguments. The output directory must already exist.
Save as record_topics.py, then run python record_topics.py DEVICE_SN ./data/session.mcap.
After the program finishes, the terminal should show the total and per-channel message counts, and the output path should contain a nonempty MCAP file. If Total frames is greater than 0 and each channel has messages, the selected resources were written to the file. Recording Wuji Glove Replace the device connection and channel registration code with the Wuji Glove versions. Keep the recording controls unchanged.
In record_topics.py:
  • Change the device connection to glove = manager.connect(sn=sn, device_name="recording_glove").
  • Register recorder.record(glove.emf_poses().subscribe()) and recorder.record(glove.imu_palm().subscribe()).
  • Replace hand2.disconnect() with glove.disconnect().
Run the corresponding example again with the Wuji Glove serial number as DEVICE_SN. Use a different output path to avoid overwriting the previous recording.

Interface List

“—” means Python has no corresponding manual release API.