触觉数据帧
理解 FrameBatch 的通道、序列号、微秒级时间戳与图像数据。
更新于 2026年10月12日约 2 分钟阅读
从 FrameBatch 开始
TouchGlove.poll() 返回当前可用的 FrameBatch。一个批次中包含来自五个触觉通道的数据帧;轮询循环应逐帧处理,而不是假设每次调用只返回一帧。
读取批次
import time
from imprintx.glove import TouchGlove, list_ports
ports = list_ports()
if not ports:
raise RuntimeError("未发现 ImprintX 设备")
with TouchGlove(port=ports[0]) as device:
device.start()
for _ in range(100):
batch = device.poll()
for frame in batch:
print(
frame.channel,
frame.seq_id,
frame.timestamp_us,
frame.image.shape,
)
time.sleep(0.01)Frame 字段
| 字段 | 说明 |
|---|---|
channel | 当前帧所属的触觉通道 |
seq_id | 用于检查顺序和丢帧情况的帧序列号 |
timestamp_us | 与设备时钟对齐的微秒级时间戳 |
image | 当前通道的触觉图像数组 |
位移与力场
需要模型输出的稠密三维位移或力场时,调用 get_dense_fields():
fields = device.get_dense_fields()
print(fields.shape) # (5, 32, 32, 3)在做跨通道融合或外部传感器同步时,请使用
timestamp_us对齐数据,并使用seq_id监测数据是否连续。
