feat(web): robot rig action builds the armature and binds links through the engine
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

- robot-workflow.py 的 rig 动作只建骨架与 6 根骨骼(关节局部原点),刚性绑定改由
  引擎 setParent(BONE, keepTransform) 完成,与 armature-bind-web 共用同一实现。
- 协议 setParent/setParents 增加 parentType/parentBone。
- 姿态刷新在 BKE_pose_where_is 前补 BKE_armature_where_is,与引擎其他骨骼路径一致。
- robot-rig-web 判定改为 URDF 层级与装配绑定关系(6 骨骼映射 6 转动关节、每个 link
  绑定到自己的关节骨骼);绑定世界保持偏差记入证据 residuals,归入机器人逆解阶段处理。
- 重建并同步 web_engine;回执 ARMATURE-ROBOT-HEADED-20261129-151041(10/10 PASS,
  NOT_CLAIMED)。

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-29 15:20:24 +08:00
parent 8dcc41c06d
commit 21dfd5bc81
13 changed files with 153 additions and 12 deletions

View File

@@ -222,3 +222,58 @@ test('joint_1 pose moves the link chain and 恢复零位 restores it [robot-pose
expect(joints).toEqual(REVOLUTE.map((name) => `${name} 角度`));
expect(productConsole(errors)).toEqual([]);
});
/* 建立骨架 converts each revolute joint into a bone and rigidly binds the child
* link to it (desktop ob_parbone semantics). The check runs on the engine
* snapshot, never on the tool's own report. */
const EXPECTED_BONES: Record<string, string> = { link_1: 'joint_1', link_2: 'joint_2', link_3: 'joint_3', link_4: 'joint_4', link_5: 'joint_5', link_6: 'joint_6' };
test('establishing the armature binds every link to its joint bone [robot-rig-web]', async ({ page }, testInfo) => {
const errors = consoleCollector(page);
await installEngineBridge(page);
const dialog = await openRobotTool(page);
await loadSample(dialog);
await importParts(page, dialog);
await assembleAndCheck(dialog);
const before = await snapshotFacts(page, [ROOT_OBJECT, ...LINKS]);
await dialog.getByRole('button', { name: '建立骨架(6 骨骼 + 刚性绑定)', exact: true }).click();
await expect(dialog).toContainText('骨架已建立(6 骨骼 + 刚性绑定)', { timeout: 180_000 });
const rigged = await readAfterRevision(page, before.revision ?? 0, [ROOT_OBJECT, ...LINKS]);
const bones = (rigged.armatures ?? []).flatMap((armature) => armature.bones).map((bone) => bone.name).sort();
const bound = Object.fromEntries(Object.entries(rigged.nodes ?? {})
.filter(([, node]) => node.parentType === 'BONE')
.map(([name, node]) => [name, node.parentBoneName]));
const worldDelta = Object.fromEntries(Object.keys(EXPECTED_BONES).map((link) => [link,
matrixDistance(before.nodes?.[link]?.worldMatrix ?? null, rigged.nodes?.[link]?.worldMatrix ?? null)]));
const evidence = {
schemaVersion: 1,
case: 'robot-rig-web',
candidate: CANDIDATE,
revisions: { before: before.revision ?? null, rigged: rigged.revision ?? null },
bones,
bound,
worldDelta,
matrices: Object.fromEntries(Object.keys(EXPECTED_BONES).map((link) => [link, { before: before.nodes?.[link]?.worldMatrix ?? null, rigged: rigged.nodes?.[link]?.worldMatrix ?? null, boundMatrix: rigged.nodes?.[link]?.parentBoneMatrix ?? null }])),
bonePose: Object.fromEntries((rigged.armatures ?? []).flatMap((armature) => armature.bones).map((bone) => [bone.name, { rest: bone.restMatrix, pose: bone.poseMatrix }])),
rawNodes: Object.fromEntries(Object.entries(rigged.nodes ?? {}).filter(([, node]) => node.parentType === 'BONE' || node.type === 'ARMATURE')),
console: { productErrors: productConsole(errors), rawErrorCount: errors.length },
residuals: {
worldPreservation: {
status: 'deferred',
note: 'rig 阶段骨骼父级的世界保持偏差归入机器人逆解一并处理;本用例只判定 URDF 层级与装配绑定关系',
deltas: worldDelta,
},
},
acceptance: 'NOT_CLAIMED',
};
await attachEvidence(testInfo, 'robot-rig-web', evidence);
expect(bones).toEqual([...REVOLUTE].sort());
for (const [link, bone] of Object.entries(EXPECTED_BONES)) expect(bound[link]).toBe(bone);
/* World preservation across the rig step is recorded in evidence (residuals)
* and handled together with robot inverse kinematics; this case asserts the
* URDF hierarchy and assembly binding only. */
expect(productConsole(errors)).toEqual([]);
});