Make machine configuration authoritative and restore native checkpoints exactly

This commit is contained in:
2026-09-18 09:09:41 +08:00
parent 6a69511276
commit 4a568f1f4c
94 changed files with 10882 additions and 301 deletions

View File

@@ -1,25 +1,12 @@
const TRT_ROOT = "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting";
import catalog from "./machine-catalog.json" with { type: "json" };
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/boat-${stem}.ngc`,
switchkins_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 const MACHINE_DEFINITIONS = Object.freeze(catalog.machines.map((entry) => {
if (!entry.id || !entry.entrypoint || !entry.program || !entry.source_path || !["XYZAC", "XYZBC"].includes(entry.coordinates)) throw new Error("machine_catalog_invalid");
return Object.freeze({ ...entry, label: `${entry.coordinates} TRT`, axes: [...entry.coordinates.toLowerCase()], joint_count: entry.coordinates.length, runtime: "trt" });
}));
if (new Set(MACHINE_DEFINITIONS.map((entry) => entry.id)).size !== MACHINE_DEFINITIONS.length) throw new Error("machine_catalog_duplicate");
export const DEFAULT_MACHINE = MACHINE_DEFINITIONS.find((entry) => entry.id === catalog.default_machine);
if (!DEFAULT_MACHINE) throw new Error("machine_catalog_default_missing");
export function machineDefinition(value) {
return MACHINE_DEFINITIONS.find((entry) => [entry.id, entry.entrypoint, entry.coordinates].includes(value)) ?? null;
}