Files
linuxcncWebWASM/web/workspace/machine-definitions.mjs

30 lines
1.7 KiB
JavaScript

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/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 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;
}