Support XYZAC and XYZBC in shared web machine UI
This commit is contained in:
28
web/workspace/machine-definitions.mjs
Normal file
28
web/workspace/machine-definitions.mjs
Normal file
@@ -0,0 +1,28 @@
|
||||
const TRT_ROOT = "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting";
|
||||
|
||||
function trt(id, coordinates, type, offsets, model) {
|
||||
const stem = coordinates.toLowerCase();
|
||||
return Object.freeze({
|
||||
id, label: `${coordinates} TRT`, coordinates, axes: [...stem], joint_count: coordinates.length,
|
||||
entrypoint: `${TRT_ROOT}/${id}.ini`, program: `${TRT_ROOT}/demos/${stem}_switchkins.ngc`,
|
||||
kinematics_type: type, runtime: "trt", model,
|
||||
source_path: `linuxcnc/src/hal/user_comps/vismach/${id}-gui.py`,
|
||||
subroutines: [`${stem}_switchkins_sub`, `helix_${stem.slice(3)}`],
|
||||
offsets,
|
||||
joint_limits: { x: [-200, 200], y: [-100, 100], z: [-120, 120], [stem[3]]: [-100, 50], c: [-36000, 36000] },
|
||||
axis_limits: { x: [-200, 200], y: [-100, 100], z: [-120, 120], [stem[3]]: coordinates === "XYZAC" ? [-100, 50] : [-36000, 36000], c: [-36000, 36000] },
|
||||
});
|
||||
}
|
||||
|
||||
export const MACHINE_DEFINITIONS = Object.freeze([
|
||||
trt("xyzac-trt", "XYZAC", 2, { x_rot_point: 0, y_offset: 20, z_offset: 10, tool_offset: 0 }, "trt-moving-knee"),
|
||||
trt("xyzbc-trt", "XYZBC", 3, { x_rot_point: 0, y_rot_point: 0, z_rot_point: 0, x_offset: -20, y_offset: 0, z_offset: -15, tool_offset: 0 }, "trt-moving-head"),
|
||||
]);
|
||||
export const DEFAULT_MACHINE = MACHINE_DEFINITIONS[0];
|
||||
export function machineDefinition(value) {
|
||||
return MACHINE_DEFINITIONS.find((entry) => [entry.id, entry.entrypoint, entry.coordinates].includes(value)) ?? null;
|
||||
}
|
||||
export function machineAxes(snapshot) {
|
||||
const coordinates = snapshot?.kinematics?.coordinates ?? snapshot?.visual?.machine_model?.coordinate_system;
|
||||
return machineDefinition(coordinates)?.axes ?? DEFAULT_MACHINE.axes;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { fnv1a64 } from "../worker/replay.mjs";
|
||||
import { runtimeResourceFixture } from "./resource-resolver.mjs";
|
||||
import { SIM_CASE_CATALOG, SIM_FILE_INDEX, SIM_HAL_COMPONENTS } from "./sim-case-catalog.mjs";
|
||||
import { isOptionalSourceKey } from "./linuxcnc-source-semantics.mjs";
|
||||
import { MACHINE_DEFINITIONS, machineDefinition } from "./machine-definitions.mjs";
|
||||
|
||||
export const SIMULATION_CASE_SCHEMA = "simulation-case-bundle.v1";
|
||||
const RESOURCE_KEYS = new Set([
|
||||
@@ -17,6 +18,7 @@ const CASE_KINEMATICS = Object.freeze({
|
||||
"linuxcnc/configs/sim/axis/ldelta.ini": Object.freeze({ type: "lineardelta", path_mode: "kins" }),
|
||||
"linuxcnc/configs/sim/axis/rdelta.ini": Object.freeze({ type: "rotarydelta", path_mode: "kins" }),
|
||||
"linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzac-trt.ini": Object.freeze({ type: "xyzac-trt", path_mode: "wasm", coordinates: "XYZAC", joint_count: 5, max_linear_velocity: 35, axis_linear_velocity_limit: 20, max_acceleration: 300, max_jerk: 1000000000, servo_cycle_time: 0.001, task_cycle_time: 0.01, cycle_time: 0.001, switchkins: { 0: "identity", 1: "xyzac", 2: "userk" }, offsets: { x_rot_point: 0, y_offset: 20, z_offset: 10, tool_offset: 0 } }),
|
||||
"linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzbc-trt.ini": Object.freeze({ type: "xyzbc-trt", path_mode: "wasm", coordinates: "XYZBC", joint_count: 5, max_linear_velocity: 35, axis_linear_velocity_limit: 20, axis_angular_velocity_limit: 30, max_acceleration: 300, max_jerk: 1000000000, servo_cycle_time: 0.001, task_cycle_time: 0.01, cycle_time: 0.001, switchkins: { 0: "identity", 1: "xyzbc", 2: "userk" }, 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 } }),
|
||||
});
|
||||
const RUNTIME_FIXTURES = Object.freeze({
|
||||
"linuxcnc/configs/sim/axis/minimal_xyz.ini": Object.freeze({
|
||||
@@ -49,6 +51,12 @@ const RUNTIME_FIXTURES = Object.freeze({
|
||||
with: "HALFILE = xyzac-trt-headless_cmds.hal",
|
||||
reason: "LinuxCNC basic_sim.tcl generated XYZAC HAL command fixture",
|
||||
}),
|
||||
"linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzbc-trt.ini": Object.freeze({
|
||||
generated_hal: "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzbc-trt_cmds.hal",
|
||||
replace: "HALFILE = LIB:basic_sim.tcl",
|
||||
with: "HALFILE = xyzbc-trt_cmds.hal",
|
||||
reason: "LinuxCNC basic_sim.tcl generated XYZBC HAL command fixture",
|
||||
}),
|
||||
});
|
||||
|
||||
function clone(value) { return structuredClone(value); }
|
||||
@@ -117,7 +125,7 @@ function generatedResource(path, key) {
|
||||
return generated ? { ...generated, data_hash: fnv1a64(generated.content) } : null;
|
||||
}
|
||||
function inManifest(path) {
|
||||
return MANIFEST.has(path) || path === "linuxcnc/configs/nc_files/3dtest.ngc";
|
||||
return MANIFEST.has(path) || path === "linuxcnc/configs/nc_files/3dtest.ngc" || path === "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzbc-trt_cmds.hal";
|
||||
}
|
||||
function responseUrl(baseUrl, path) { return `${String(baseUrl ?? "").replace(/\/$/, "")}/${path}`.replace(/^\//, "/"); }
|
||||
|
||||
@@ -218,8 +226,9 @@ export async function loadSimulationCase({ path, fetchImpl = globalThis.fetch, b
|
||||
// the Web renderer. It is not referenced as a normal INI resource, so
|
||||
// resolve it explicitly and carry it through the Worker configuration for
|
||||
// source hashing and model provenance.
|
||||
if (catalog.path === "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzac-trt.ini") {
|
||||
const visualSource = "linuxcnc/src/hal/user_comps/vismach/xyzac-trt-gui.py";
|
||||
const machine = machineDefinition(catalog.path);
|
||||
if (machine) {
|
||||
const visualSource = machine.source_path;
|
||||
if (!(visualSource in files)) {
|
||||
const content = await fetchText(fetchImpl, baseUrl, visualSource);
|
||||
if (content === null) missing.push(visualSource);
|
||||
@@ -269,7 +278,7 @@ export function toWorkerConfiguration(bundle) {
|
||||
optional_missing: clone(bundle.optional_missing ?? []),
|
||||
runtime_fixtures: clone(bundle.runtime_fixtures ?? []),
|
||||
...(bundle.entrypoint === "linuxcnc/configs/sim/axis/vismach/3axis-tutorial/3axis-tutorial.ini" ? { home_limits: { z: [-240, 100] } } : {}),
|
||||
...(bundle.entrypoint === "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzac-trt.ini" ? { home_limits: { joint_count: 5, kinematics_type: 2, coordinates: "XYZAC", x: [-200, 200], y: [-100, 100], z: [-120, 120], a: [-100, 50], c: [-36000, 36000] } } : {}),
|
||||
...(machineDefinition(bundle.entrypoint) ? { home_limits: { joint_count: 5, kinematics_type: machineDefinition(bundle.entrypoint).kinematics_type, coordinates: machineDefinition(bundle.entrypoint).coordinates, ...machineDefinition(bundle.entrypoint).joint_limits } } : {}),
|
||||
...(CASE_KINEMATICS[bundle.entrypoint] ? { kinematics: clone(CASE_KINEMATICS[bundle.entrypoint]) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user