Complete XYZAC switchkins transitions

This commit is contained in:
2026-09-02 09:31:55 +08:00
parent 6b689fd69e
commit 0a22c7bf1b
4 changed files with 70 additions and 6 deletions

View File

@@ -48,6 +48,23 @@ for (const [code, expected] of [["M429", 0], ["M428", 1], ["M430", 2]]) {
switchRows.push({ code, tick: result.simulation_tick, active_type: expected, state_hash: result.payload.panel_snapshot.state_hash });
}
// Direct panel selection must preserve the live WASM TP pose at a non-zero
// position for every pair of IDENTITY/TCP:XYZAC/USERK transitions.
const move = send("MDI_EXECUTE", "seed-position", { block: "G0 X10 Y5 Z20 A30 C45" });
assert.equal(move.kind, "COMMAND_RESULT");
for (let cycle = 0; cycle < 1000 && session.wasmMotion.read().state.queue_depth > 0; cycle += 1) send("SIM_STEP", `seed-step-${cycle}`, { cycles: 1 });
assert.equal(session.wasmMotion.read().state.queue_depth, 0);
const directSwitches = [];
for (const expected of [0, 1, 2, 0, 1, 2, 0]) {
const result = send("KINEMATICS_SELECT", `direct-${expected}-${seq}`, { type: expected });
assert.equal(result.kind, "COMMAND_RESULT");
assert.equal(result.payload.kinematics.active_type, expected);
const pose = result.payload.kinematics.pose;
const tpPose = result.payload.wasm_motion.state.position;
for (const axis of ["x", "y", "z", "a", "b", "c", "u", "v", "w"]) assert.ok(Math.abs(Number(pose[axis]) - Number(tpPose[axis])) <= 1e-9, `${axis}: ${pose[axis]} != ${tpPose[axis]}`);
directSwitches.push({ active_type: expected, state_hash: result.payload.kinematics.state_hash });
}
const pose = session.xyzacKinematics.forward([100, 50, 100, 30, 45]);
assert.equal(pose.status, "verified");
assert.equal(pose.joint_count, 5);
@@ -70,6 +87,7 @@ console.log(JSON.stringify({
motion_authority: loaded.payload.motion_authority,
control_count: controls.length,
switchkins: switchRows,
direct_switchkins: directSwitches,
pose: pose.pose,
wasm_state_hash: pose.wasm_state_hash,
state_hash: pose.state_hash,