Support XYZAC and XYZBC in shared web machine UI

This commit is contained in:
2026-09-11 06:25:13 +08:00
parent aac1ceb250
commit 02dcc573b0
20 changed files with 318 additions and 146 deletions

View File

@@ -1,5 +1,6 @@
import assert from "node:assert/strict";
import { INITIAL_STATE, reduceFrontendState } from "./store.ts";
import { projectXyzacPanel } from "./xyzac-panel-contract.ts";
const envelope = (kind, seq, payload, tick) => ({ schema_version: 1, kind, context_id: INITIAL_STATE.contextId, session_id: "motion-projection", seq, simulation_tick: tick, payload });
const panel = {
@@ -36,4 +37,8 @@ const next = reduceFrontendState(initial, envelope("COMMAND_RESULT", 2, {
assert.deepEqual(next.snapshot.motion.axes, [11, 21, 31, 41, 51]);
assert.equal(next.snapshot.visual.pose.a, 41);
assert.equal(next.snapshot.visual.pose.c, 51);
const xyzbcPanel = projectXyzacPanel({ simulation_tick: 3, state_hash: "bc", kinematics: { schema: "wasm-xyzac-kinematics.v1", status: "verified", active_type: 1, native_type: "xyzbc-trt-kins", coordinates: "XYZBC", joint_count: 5, linear_units: "mm", angular_units: "deg", pose: { x: 0, y: 0, z: 0, a: 0, b: 12, c: 20, u: 0, v: 0, w: 0 }, joints: [1, 2, 3, 12, 20], offsets: { x_rot_point: 0, y_rot_point: 0, z_rot_point: 0, x_offset: -20, y_offset: 0, z_offset: -15, tool_offset: 0 }, generation: 1, switch_count: 1, state_hash: "k", wasm_state_hash: "w" }, xyzac: { coordinates: "XYZBC", joint_count: 5, active_type: 1, hal_pin_vars: true, switchkins_net: true, finite_offsets: true, userk_capability: true }, visual: { pose: { x: 0, y: 0, z: 0, a: 0, b: 12, c: 20 }, joints: [1, 2, 3, 12, 20] } });
assert.equal(xyzbcPanel.machine.coordinates, "XYZBC");
assert.deepEqual(xyzbcPanel.machine.axes, ["x", "y", "z", "b", "c"]);
assert.deepEqual(xyzbcPanel.joints, [1, 2, 3, 12, 20]);
console.log(JSON.stringify({ schema: "xyzac-motion-projection.v1", status: "verified", axes: next.snapshot.motion.axes, pose: { a: next.snapshot.visual.pose.a, c: next.snapshot.visual.pose.c } }));