# Unitree G1 CSV、MT 与 Isaac 数据格式 本文档定义本仓库转换脚本使用的输入 CSV,以及输出的 MT 和 Isaac NPZ 格式。 ## 通用约定 - `T`:输出动作的帧数。 - 位置:米(m)。 - 关节角:弧度(rad)。 - 线速度:米每秒(m/s)。 - 角速度:弧度每秒(rad/s)。 - 时序浮点字段:`float32`。 - `fps`:形状 `(1,)` 的 `int64` 数组。 - 输出帧数:`max(1, round(T_source × target_fps / source_fps))`。 - 位置与关节角使用线性插值,四元数使用 SLERP。 坐标轴方向由用户提供的 G1 MJCF 模型决定。 ## 输入 CSV 每行表示一帧。CSV 通常包含 `Frame`,转换必需的是根节点和 29 个 关节字段: ```text Frame # 可选,不参与时间计算 root_translateX root_translateY root_translateZ root_rotateX root_rotateY root_rotateZ {joint_name}_dof # 29 列 ``` 输入约定: | 内容 | 单位/表示 | |---|---| | `root_translate*` | 厘米 | | `root_rotate*` | XYZ 欧拉角,度 | | `*_dof` | 关节角,度 | CSV 的 29 个 DOF 使用以下 MT 顺序: ```python MT_JOINT_NAMES = [ "left_hip_pitch_joint", "left_hip_roll_joint", "left_hip_yaw_joint", "left_knee_joint", "left_ankle_pitch_joint", "left_ankle_roll_joint", "right_hip_pitch_joint", "right_hip_roll_joint", "right_hip_yaw_joint", "right_knee_joint", "right_ankle_pitch_joint", "right_ankle_roll_joint", "waist_yaw_joint", "waist_roll_joint", "waist_pitch_joint", "left_shoulder_pitch_joint", "left_shoulder_roll_joint", "left_shoulder_yaw_joint", "left_elbow_joint", "left_wrist_roll_joint", "left_wrist_pitch_joint", "left_wrist_yaw_joint", "right_shoulder_pitch_joint", "right_shoulder_roll_joint", "right_shoulder_yaw_joint", "right_elbow_joint", "right_wrist_roll_joint", "right_wrist_pitch_joint", "right_wrist_yaw_joint", ] ``` 时间间隔由 `--source-fps` 指定。 ## MT NPZ | 字段 | 形状 | 类型 | 含义 | |---|---:|---|---| | `root_pos` | `(T, 3)` | `float32` | 根节点世界坐标位置 | | `root_rot` | `(T, 4)` | `float32` | 根节点世界坐标四元数,`xyzw` | | `dof_pos` | `(T, 29)` | `float32` | MT 顺序的关节角 | | `local_body_pos` | `(T, 27, 3)` | `float32` | 根坐标系下的刚体位置 | | `joint_names` | `(29,)` | Unicode | `dof_pos` 的关节名称 | | `body_names` | `(27,)` | Unicode | `local_body_pos` 的刚体名称 | | `fps` | `(1,)` | `int64` | 输出帧率 | 局部刚体位置定义: ```text local_body_pos = inverse(root_rot) · (body_pos_w - root_pos) ``` MT 刚体顺序: ```python MT_BODY_NAMES = [ "pelvis", "left_hip_pitch_link", "left_hip_roll_link", "left_hip_yaw_link", "left_knee_link", "left_ankle_pitch_link", "left_ankle_roll_link", "right_hip_pitch_link", "right_hip_roll_link", "right_hip_yaw_link", "right_knee_link", "right_ankle_pitch_link", "right_ankle_roll_link", "torso_link", "left_shoulder_pitch_link", "left_shoulder_roll_link", "left_shoulder_yaw_link", "left_elbow_link", "left_wrist_roll_link", "right_shoulder_pitch_link", "right_shoulder_roll_link", "right_shoulder_yaw_link", "right_elbow_link", "right_wrist_roll_link", "head_mimic", "left_hand_mimic", "right_hand_mimic", ] ``` 当前实现使用以下近似: - `head_mimic` 复制 `torso_link` 的位置; - `left_hand_mimic` 复制 `left_wrist_roll_link` 的位置; - `right_hand_mimic` 复制 `right_wrist_roll_link` 的位置。 ## Isaac NPZ | 字段 | 形状 | 类型 | 含义 | |---|---:|---|---| | `fps` | `(1,)` | `int64` | 输出帧率 | | `joint_pos` | `(T, 29)` | `float32` | Isaac 顺序的关节角 | | `joint_vel` | `(T, 29)` | `float32` | Isaac 顺序的关节角速度 | | `body_pos_w` | `(T, 30, 3)` | `float32` | 刚体世界坐标位置 | | `body_quat_w` | `(T, 30, 4)` | `float32` | 刚体世界坐标四元数,`wxyz` | | `body_lin_vel_w` | `(T, 30, 3)` | `float32` | 刚体世界坐标线速度 | | `body_ang_vel_w` | `(T, 30, 3)` | `float32` | 刚体世界坐标角速度 | Isaac 关节顺序: ```python ISAAC_JOINT_NAMES = [ "left_hip_pitch_joint", "right_hip_pitch_joint", "waist_yaw_joint", "left_hip_roll_joint", "right_hip_roll_joint", "waist_roll_joint", "left_hip_yaw_joint", "right_hip_yaw_joint", "waist_pitch_joint", "left_knee_joint", "right_knee_joint", "left_shoulder_pitch_joint", "right_shoulder_pitch_joint", "left_ankle_pitch_joint", "right_ankle_pitch_joint", "left_shoulder_roll_joint", "right_shoulder_roll_joint", "left_ankle_roll_joint", "right_ankle_roll_joint", "left_shoulder_yaw_joint", "right_shoulder_yaw_joint", "left_elbow_joint", "right_elbow_joint", "left_wrist_roll_joint", "right_wrist_roll_joint", "left_wrist_pitch_joint", "right_wrist_pitch_joint", "left_wrist_yaw_joint", "right_wrist_yaw_joint", ] ``` Isaac 刚体顺序: ```python ISAAC_BODY_NAMES = [ "pelvis", "left_hip_pitch_link", "right_hip_pitch_link", "pelvis_contour_link", "left_hip_roll_link", "right_hip_roll_link", "waist_roll_link", "left_hip_yaw_link", "right_hip_yaw_link", "torso_link", "left_knee_link", "right_knee_link", "left_shoulder_pitch_link", "right_shoulder_pitch_link", "left_ankle_pitch_link", "right_ankle_pitch_link", "left_shoulder_roll_link", "right_shoulder_roll_link", "left_ankle_roll_link", "right_ankle_roll_link", "left_shoulder_yaw_link", "right_shoulder_yaw_link", "left_elbow_link", "right_elbow_link", "left_wrist_roll_link", "right_wrist_roll_link", "left_wrist_pitch_link", "right_wrist_pitch_link", "left_wrist_yaw_link", "right_wrist_yaw_link", ] ``` 根节点为刚体索引 `0`: ```python root_pos_w = data["body_pos_w"][:, 0] root_quat_wxyz = data["body_quat_w"][:, 0] ``` `pelvis_contour_link` 在当前实现中复制 `pelvis` 的状态。Isaac NPZ 不保存名称数组,读取方必须使用上述固定顺序。 ## MT 与 Isaac 的差异 | 项目 | MT | Isaac | |---|---|---| | 关节角字段 | `dof_pos` | `joint_pos` | | 关节顺序 | 按肢体分组 | 左右交替 | | 根四元数 | `root_rot`,`xyzw` | `body_quat_w[:, 0]`,`wxyz` | | 刚体位置 | 根节点局部坐标 | 世界坐标 | | 刚体数量 | 27 | 30 | | 速度 | 不保存 | 保存 | | 名称数组 | 保存 | 不保存 | 四元数重排: ```python # wxyz -> xyzw quat_xyzw = quat_wxyz[..., [1, 2, 3, 0]] # xyzw -> wxyz quat_wxyz = quat_xyzw[..., [3, 0, 1, 2]] ``` ## 加载示例 ```python import numpy as np with np.load("motion_mt.npz", allow_pickle=False) as data: fps = int(data["fps"][0]) dof_pos = data["dof_pos"] root_rot_xyzw = data["root_rot"] with np.load("motion_isaac.npz", allow_pickle=False) as data: fps = int(data["fps"][0]) joint_pos = data["joint_pos"] root_quat_wxyz = data["body_quat_w"][:, 0] ```