HumansXDocumentation Center 日本語Website ↗
Knowledge Base › Wuji Glove › Manual

Recording Data

SDK Practice

Overview

The public 2.recording.py example uses TopicRecorder to save Wuji Glove streams to an MCAP file.

This page uses Python. For C SDK recording, see Recording Examples.

Prerequisites

Example Configuration

ItemSetting
DeviceThe first Wuji Glove in the scan results
Streamstactile, emf_poses, and hand_skeleton
Compressionlz4
Recording duration10 seconds
Output file./data/YYYYMMDD_HHMMSS.mcap, named with the date and time when recording starts

Integration Steps

The following snippets run inside async def main() in the public example. See the example file for imports and the complete control flow.

Connect the Device

The example calls manager.scan(), filters for DeviceType.WujiGlove, and connects to the first glove by serial number. If no device or glove is found, it prints a message and exits.

Register the Channels

Create a recorder and register three device streams:

recorder = TopicRecorder(compression="lz4")
recorder.record(glove.tactile().subscribe())
recorder.record(glove.emf_poses().subscribe())
recorder.record(glove.hand_skeleton().subscribe())

Start Recording

Create the output directory, generate a timestamped filename, and start recording:

os.makedirs("./data", exist_ok=True)
path = f"./data/{datetime.now().strftime('%Y%m%d_%H%M%S')}.mcap"
handle = await recorder.start(path)

Stop and Clean Up

After 10 seconds, call handle.stop(). If the task is cancelled, asyncio.shield() protects the stop task, and the example waits for it to finish:

try:
    await asyncio.sleep(10)
finally:
    stop_task = asyncio.ensure_future(handle.stop())
    try:
        summary = await asyncio.shield(stop_task)
    except asyncio.CancelledError:
        summary = await stop_task

The outer finally block calls manager.disconnect_all() to disconnect the device.

Running It

Run the following command from the root of the public wuji-sdk repository:

python examples/python/wuji_glove/2.recording.py

The program prints the discovered devices, the connected glove’s serial number, and the output path. When recording ends, the Done line shows these results:

FieldOutput
summary.total_framesTotal frames in this recording
summary.file_sizeSize of the recorded file
summary.duration_sDuration of this recording

Open the MCAP file with Foxglove Studio or inspect it with mcap info.