Keep XYZAC tool motion smooth and expose rotary DRO values
This commit is contained in:
39
web/react/src/test_xyzac_motion_projection.mjs
Normal file
39
web/react/src/test_xyzac_motion_projection.mjs
Normal file
@@ -0,0 +1,39 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { INITIAL_STATE, reduceFrontendState } from "./store.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 = {
|
||||
schema: "axis-panel-snapshot.v1",
|
||||
context_id: INITIAL_STATE.contextId,
|
||||
session_id: "motion-projection",
|
||||
simulation_tick: 1,
|
||||
state_hash: "fnv1a64:panel",
|
||||
task: { state: "RUNNING", mode: "AUTO", program_status: "running", current_line: 1 },
|
||||
program: { program_status: "running", current_line: 1 },
|
||||
motion: { axes: [10, 20, 30, 40, 50], joints: [10, 20, 30, 40, 50] },
|
||||
coordinates: { machine: [10, 20, 30, 40, 50], relative: [10, 20, 30, 40, 50] },
|
||||
overrides: { feed: 1, spindle: [1] },
|
||||
wasm_motion: { status: "verified", state: { position: { x: 10, y: 20, z: 30, a: 40, c: 50 }, queue_depth: 1 } },
|
||||
visual: { schema: "axis-visual.v1", pose: { x: 10, y: 20, z: 30, a: 40, c: 50 }, joints: [10, 20, 30, 40, 50], toolpath: [], active_segment_id: 1, active_progress: 0.1, source: "wasm_canonical_motion" },
|
||||
kinematics: { coordinates: "XYZAC", joint_count: 5, pose: { x: 10, y: 20, z: 30, a: 40, c: 50 }, joints: [10, 20, 30, 40, 50], offsets: {} },
|
||||
xyzac: { coordinates: "XYZAC", joint_count: 5 },
|
||||
gates: {},
|
||||
};
|
||||
|
||||
const initial = reduceFrontendState(INITIAL_STATE, envelope("STATE_SNAPSHOT", 1, { panel_snapshot: panel }, 1));
|
||||
const next = reduceFrontendState(initial, envelope("COMMAND_RESULT", 2, {
|
||||
status: "verified",
|
||||
snapshot_mode: "motion_delta",
|
||||
motion_sample: { tick: 2, pose: { x: 11, y: 21, z: 31, a: 41, c: 51 }, joints: [11, 21, 31, 41, 51], active_segment_id: 1, active_progress: 0.2 },
|
||||
motion_trace: [],
|
||||
wasm_motion: { status: "verified", state: { position: { x: 11, y: 21, z: 31, a: 41, c: 51 }, queue_depth: 1 } },
|
||||
motion: { axes: [11, 21, 31, 41, 51], joints: [11, 21, 31, 41, 51] },
|
||||
task: panel.task,
|
||||
program: panel.program,
|
||||
state_hash: "fnv1a64:delta",
|
||||
}, 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);
|
||||
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 } }));
|
||||
Reference in New Issue
Block a user