Files
workinf_Blender_Wasm/docs/web/ARMATURE-ROBOT-HEADED-TESTS.md
mes123456 8f08c1bda9
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
feat(web): armature properties split edit, pose and object modes with Ctrl+Tab
- Properties gates the rest-edit forms (add bone, per-bone rest form, bone
  operations) to Edit mode and the pose readback form to Pose mode; Object
  mode shows a read-only summary with 进入编辑模式 / 进入姿态模式 buttons.
  The workbench root carries data-armature-mode for assertions.
- Ctrl+Tab on an armature object toggles Pose/Object; Tab still enters Edit.
- armature-ui-readback-web waits for the native object.mode_set to report
  模式:Pose/模式:Object before pressing shortcuts, matching the app's
  pending guard that ignores keys during a mode change.
- armature-editor-coverage-ui-production enters Edit mode before the
  rest-edit operations.

The coverage spec still cannot run as written: the app worker already holds
the web-blender:native-files lock, so the spec's own WebEngineClient fails
with WASM_INIT_FAILED. Pre-existing on this branch (also fails with the
previous App.tsx); tracked separately from this change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-29 18:33:01 +08:00

84 lines
5.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 骨骼 / ABB IRB120 有头测试
面向浏览器真实操作的有头(headed)验证:Chromium 打开产品入口、走真实的加载/装配/姿态路径,
断言从引擎快照读回,回执绑定候选构件哈希且标记 `NOT_CLAIMED`(不宣称验收通过)。
## 运行
```bash
# 全量(需要 X11,默认 headed;candidate 默认 web/dist)
DISPLAY=:1 node tools/web/run-armature-robot-headed.mjs --candidate /abs/path/to/web/dist
# 单例
DISPLAY=:1 node tools/web/run-armature-robot-headed.mjs --candidate web/dist --grep armature-viewport-web
# 校验最新回执
node tools/web/check-armature-robot-headed.mjs
node tools/web/check-armature-robot-headed.mjs --dir /abs/tests/golden/ARMATURE-ROBOT-HEADED-<stamp>
```
退出码:`0` 通过、`1` 失败、`2` 前置检查 BLOCKED(缺 DISPLAY/Chrome/候选/机器人样例 provenance)、`64` 参数错误。
回执写入 `tests/golden/ARMATURE-ROBOT-HEADED-<YYYYMMDD-HHMMSS>/`,同名冲突追加 `-HHMMSS`,历史回执不覆盖。
## 用例
| id | 入口 | 断言 |
| --- | --- | --- |
| `robot-sample-web` | 六轴机器人工具 → 加载 ABB IRB120 样例 | provenance/URDF 哈希一致,零件导入后各 link 挂在根对象下 |
| `robot-assemble-check-web` | 建立 URDF 层级 → 六轴检查 | 真实父子链与六轴检查通过 |
| `robot-pose-web` | joint_1 30° → 应用关节角度 → 恢复零位 | link_1 world 变化、复位还原 |
| `armature-bones-web` | 引擎命令 `setArmatureBones` | Root/Child 骨链、rest/pose 通道读回 |
| `armature-bind-web` | `setParent` + `parentType:"BONE"` | 刚性绑定后 world 不变;未知骨名返回 `PARENT_BONE_INVALID` |
| `armature-pose-web` | `setPoseBoneTransform` | poseMatrix/子物体 world 变化、重复写入幂等、归零复原 |
| `armature-viewport-web` | 属性面板姿态表单 → Apply Pose | 画布 `data-armature-bone-count`、截图前后不同 |
| `armature-decimal-input-web` | 用户逐键输入 `0.5` | `缩放 X` 与姿态 `Scale X` 保留小数;姿态提交后 poseScale 读回 0.5 |
| `armature-ui-readback-web` | 物体模式 → 进入姿态模式;姿态表单回填;Ctrl+Tab 往返 | 物体模式只读(无 rest 操作/姿态表单);UI 显示角度/缩放 = 引擎 pose 通道(弧度×180/π),`data-testid="armature-pose-readback"`;Ctrl+Tab 回到物体模式并再进姿态 |
| `armature-reopen-web` | 文件 → 保存到浏览器 OPFS → 最近打开 | worker `openBlend` 成功回复为前置;重开后骨骼、骨骼父级、姿态与世界矩阵与保存前一致 |
## 门禁(checker 硬校验)
- `bundleHasRobotTool`:候选包含「加载 ABB IRB120 样例」入口。
- `engineHasArmatureCommands`:wasm 含 `ARMATURE_BONES_INVALID`。
- `engineHasBoneParent`:wasm 含 `PARENT_BONE_INVALID`。
- `enginePoseEvaluated`:wasm 含 `ARMATURE_POSE_EVALUATED`。
- `bundleHasArmatureReadback`:候选包含姿态读回表单。
- `matchesSyncedRuntime`:候选 wasm 与 `web/app/public/vendor/blender` 同步产物一致。
## ABB IRB120 骨骼映射(关节 → 骨骼 → 刚性绑定)
| 关节 | 骨骼 | 子 link | 说明 |
| --- | --- | --- | --- |
| joint_1 | J1 | link_1 | 基座回转,URDF 轴 Z |
| joint_2 | J2 | link_2 | 大臂,轴 Y |
| joint_3 | J3 | link_3 | 小臂,轴 Y |
| joint_4 | J4 | link_4 | 腕回转,轴 Z |
| joint_5 | J5 | link_5 | 腕摆动,轴 Y |
| joint_6 | J6 | link_6 | 法兰,轴 Z |
绑定语义镜像桌面 `ob_parbone`:`pose_mat` 的 Y 列 × 骨长 × `parent_bone_head_tail_factor`(DNA 默认 1.0),
`partype = PARBONE`,`parsubstr = <骨名>`;world = 骨架对象 world × 骨骼矩阵 × `parentinv` × basis。
## 约束
- 全部落盘走 OPFS;禁用 IDBFS/IndexedDB;测试产物不写入 OPFS。
- 下载 `.blend` 只能由用户手动触发独立入口,保存/编辑流程不得自动下载。
- 回执 `acceptance:"NOT_CLAIMED"`,绑定候选哈希,不覆盖历史回执;不以单例通过宣称整体验收。
## 残余
- rig 阶段骨骼父级的世界保持偏差:绑定后各 link 的世界矩阵与绑定前不一致(`robot-rig-web` 证据
`residuals.worldPreservation.deltas`,最大约 1.26)。按用户指示归入机器人逆解一并处理;该用例当前
只判定 URDF 层级与装配绑定关系(6 骨骼对应 6 个转动关节、每个 link 绑定到自己的关节骨骼、无产品控制台错误)。
- 机器人工具动作「建立骨架(6 骨骼 + 刚性绑定)」已落地:Python 只建骨架与 6 根骨骼,刚性绑定经引擎
`setParent(BONE, keepTransform)` 完成,与 `armature-bind-web` 共用同一实现。
- `armature-reopen-web` 已落地:保存走「文件 → 保存到浏览器 OPFS」,重开走「文件 → 最近打开」。
断言前必须等到 worker 的 `openBlend` 成功回复计数增长(证据 `openBlendReplies` 1→2),否则活着的
Main 会直接回答快照、比较恒真;实测重开前 r4 → 重开后 r1,骨骼 / 父级 / 姿态 / 世界矩阵零偏差。
- 姿态表单已按 `uiState.context.mode` 分离,与桌面骨骼模式一致:编辑模式显示 rest 编辑(添加骨骼、
逐骨 rest 变换、`armature-edit-operations` 五项操作);姿态模式显示姿态读回/提交表单
(`armature-pose-readback`);物体模式只读,显示 `armature-mode-actions` 与「进入编辑模式 / 进入姿态模式」
按钮。工作台根节点带 `data-armature-mode`,便于断言当前模式。
- 快捷键:骨骼对象上 Ctrl+Tab 在姿态 / 物体间切换,Tab 仍进入编辑模式。原生 `object.mode_set`
进行中(状态栏显示「正在切换到 … 模式…」)时 App 会忽略快捷键,属刻意的 pending 守卫;物体模式按钮
始终可用,切换完成后再按快捷键生效。