手部动作计算
更新时间:2026-07-29
简介
从手部逐帧 6D 位姿(位置 + 旋转)+ 可选相机位姿计算对齐 LeRobot / Open X-Embodiment 约定的 7-DoF 相对动作序列 [dx,dy,dz,drx,dry,drz,gripper] 及绝对状态向量,AIHC 自研,纯几何计算、离线 CPU、无模型依赖。
功能描述
• 7-DoF 动作:逐帧计算相对上一帧的平移增量 + 旋转增量 + gripper 绝对值(delta_mode=relative),或直接输出绝对量(absolute)
• 旋转编码:支持 axis_angle(默认,3 维无万向锁)/ euler_xyz / quaternion(取增量四元数虚部 3 维)
• 坐标系:默认相机系 camera;提供相机外参时可切世界系 world
• gripper 归一化:默认归一化到 [0,1](0=闭,1=开),可用 gripper_open_dist 指定开合尺度或自动 min-max
算子参数
输入
| 输入 | 含义 |
|---|---|
| hand_pose_seq | 每帧手部 6D 位姿,list |
| camera_pose(可选) | 相机外参(4x4 展平为 16 元素),coordinate_frame=world 时使用;不用可省略。 |
输出
| 输出 | 含义 |
|---|---|
| result | struct{action: list<list |
参数
| 参数名称 | 类型 | 默认值 | 描述 | |
|---|---|---|---|---|
| coordinate_frame | str | camera | 坐标系,可选 camera/world(world 需提供 camera_pose) | |
| rotation_format | str | axis_angle | 旋转编码,可选 axis_angle/euler_xyz/quaternion | |
| gripper_range | tuple[float,float] | (0.0, 1.0) | gripper 归一化目标区间 [g_lo, g_hi] | |
| gripper_open_dist | float |None | None | gripper 完全张开对应的原始开合度;None 时按序列 min-max 归一化 | |
| delta_mode | str | relative | 动作模式,relative(相对上一帧增量)/ absolute(绝对量) |
调用示例
Python
1from __future__ import annotations
2import os
3import math
4import daft
5from daft import col
6from daft.aihc.common.udf import aihc_udf
7from daft.aihc.functions.embodied.hand_action_compute import HandActionCompute
8
9def _rot_z(theta):
10 c, s = math.cos(theta), math.sin(theta)
11 return [c, -s, 0, s, c, 0, 0, 0, 1]
12
13if __name__ == "__main__":
14 if os.getenv("DAFT_RUNNER", "native") == "ray":
15 import ray
16 ray.init(dashboard_host="0.0.0.0", ignore_reinit_error=True)
17 daft.set_runner_ray()
18 daft.set_execution_config(min_cpu_per_task=0)
19
20 # 一条 5 帧序列:沿 x 平移 0.01/帧,无旋转,无 gripper
21 seq = [{"position": [0.01 * i, 0.0, 0.0], "rotation": _rot_z(0.0), "gripper": None} for i in range(5)]
22 samples = {"hand_pose_seq": [seq]}
23 ds = daft.from_pydict(samples)
24 ds = ds.with_column(
25 "result",
26 aihc_udf(
27 HandActionCompute,
28 construct_args={
29 "coordinate_frame": "camera",
30 "rotation_format": "axis_angle",
31 "delta_mode": "relative",
32 "gripper_range": [0.0, 1.0],
33 },
34 num_cpus=1, concurrency=1, batch_size=1,
35 )(col("hand_pose_seq")),
36 )
37 ds.show()
评价此篇文章
