diff --git a/configs/sim/axis/vismach/twinspindle/README b/configs/sim/axis/vismach/twinspindle/README new file mode 100644 index 00000000000..3b75fd5cfb6 --- /dev/null +++ b/configs/sim/axis/vismach/twinspindle/README @@ -0,0 +1,37 @@ +A mill-turn with a tilting head between two spindles, on twinspindlekins. + +The head carries the tool on X Y Z and tilts it on B, about Y. The main +spindle turns its part on C; the sub spindle faces it along Z, 500 away, +and turns its own part on W. W is an angle, so [AXIS_W] declares it +TYPE = ANGULAR, and both spindles are WRAPPED_ROTARY. The vismach window +draws the spindle line across the screen as on a lathe: main spindle on +the left, Z to the right, X up. + +Kinematics type 0 works on the part in the main spindle and orients the +tool with C and B; type 1 works on the part in the sub spindle and orients +it with W and B. Each part's frame has its Z out of its own spindle's face, +so a program reads the same on either part. Type 2 is the identity, the +machine frame, which G13.1 selects. + +The INI sets MACHINE_MOVES_IN_MACHINE_FRAME, so G53, G28 and G30 move +the slides in that machine frame whichever spindle's type is in force. + +Demo program: + + twin-spindle-holes.ngc -- one subroutine drills a ring of six holes, + each tilted 20 degrees out from the part axis, + into the face of the part the kinematics type + in force works on; the program runs it on the + main spindle (G12.1 P0, G54) and then on the + sub spindle (G12.1 P1, G55). The subroutine + names no rotary: G53.3 turns the ones the type + orients with, and the report on the terminal + reads them by number, #<_kins_orient_1> and + #<_kins_orient_2>, 5 and 4 (C and B) on the + main spindle, 8 and 4 (W and B) on the sub + spindle, with their angles #<_orient_rot1> and + #<_orient_rot2>. + +The tool table provides tool 1, length 50. The drawing hands its pivot +length and spindle distance to the kinematics (twinspindle.hal), so the +two agree. diff --git a/configs/sim/axis/vismach/twinspindle/twin-spindle-holes.ngc b/configs/sim/axis/vismach/twinspindle/twin-spindle-holes.ngc new file mode 100644 index 00000000000..941a611c778 --- /dev/null +++ b/configs/sim/axis/vismach/twinspindle/twin-spindle-holes.ngc @@ -0,0 +1,67 @@ +; twin-spindle-holes.ngc - one subroutine drills the same ring of tilted +; holes into the part in the main spindle and into the part in the sub +; spindle. +; +; configs/sim/axis/vismach/twinspindle and tests/twinspindle each keep a +; copy of this program: change both, they are the same file. +; +; Kinematics type 0 works on the main spindle's part and orients the tool +; with C and B; type 1 works on the sub spindle's part and orients it with +; W and B. The subroutine names neither: G53.3 turns whatever rotaries the +; type in force orients with, and the report reads them by number, +; #<_kins_orient_1> and #<_kins_orient_2>, with their angles in the same +; order, #<_orient_rot1> and #<_orient_rot2>. Each part's frame has its Z +; out of its own spindle, so both faces are at Z60 and the offsets read +; the same. + +o sub + # = 6 ; holes + # = 30 ; hole circle radius on the face + # = 20 ; tilt of each hole out from the part axis + # = 0 + o101 while [# lt #] + # = [# * 360 / #] + ; the hole's plane: origin on the face, X along the hole circle, + ; Z the hole axis + g68.2 p3 q1 x[#*cos[#]] y[#*sin[#]] z0 i[-sin[#]] j[cos[#]] k0 + g68.2 p3 q2 i[sin[#]*cos[#]] j[sin[#]*sin[#]] k[cos[#]] + g53.2 ; solve the pose, report it + (print, hole #: axis #<_kins_orient_1> to #<_orient_rot1>, axis #<_kins_orient_2> to #<_orient_rot2>) + g53.3 x0 y0 z5 ; orient and go, 5 above the hole + g1 z-10 + g0 z5 + # = [# + 1] + o101 endwhile + g0 z40 + g69 +o endsub + +; from one part to the other in the machine frame, the identity type: +; up, clear of both parts, and the head pointing down +o sub + g13.1 + g53 g0 x300 + g53 g0 z50 b90 +o endsub + +g21 g90 g94 g17 g40 +t1 m6 +g43 +f300 + +g10 l2 p1 x0 y0 z60 c0 w0 ; G54, the main spindle's part +g10 l2 p2 x0 y0 z60 c0 w0 ; G55, the sub spindle's part + +o call +g12.1 p0 ; the main spindle's part +g54 +o call + +o call +g12.1 p1 ; the sub spindle's part +g55 +o call + +o call +g54 +m2 diff --git a/configs/sim/axis/vismach/twinspindle/twinspindle.hal b/configs/sim/axis/vismach/twinspindle/twinspindle.hal new file mode 100644 index 00000000000..7df29902d24 --- /dev/null +++ b/configs/sim/axis/vismach/twinspindle/twinspindle.hal @@ -0,0 +1,15 @@ +loadusr -W ./twinspindlegui.py + +net jx joint.0.pos-fb twinspindlegui.jx +net jy joint.1.pos-fb twinspindlegui.jy +net jz joint.2.pos-fb twinspindlegui.jz +net jb joint.3.pos-fb twinspindlegui.jb +net jc joint.4.pos-fb twinspindlegui.jc +net jw joint.5.pos-fb twinspindlegui.jw + +# the drawing and the kinematics share the geometry +net pivot-len twinspindlegui.pivot_len twinspindlekins.pivot-length +net spindle-distance twinspindlegui.spindle_distance twinspindlekins.spindle-distance + +net tool-len motion.tooloffset.z twinspindlegui.tool_length +net tool-diam halui.tool.diameter twinspindlegui.tool_diam diff --git a/configs/sim/axis/vismach/twinspindle/twinspindle.ini b/configs/sim/axis/vismach/twinspindle/twinspindle.ini new file mode 100644 index 00000000000..d03f27002e7 --- /dev/null +++ b/configs/sim/axis/vismach/twinspindle/twinspindle.ini @@ -0,0 +1,166 @@ +[EMC] +VERSION = 1.1 +MACHINE = Sim-twinspindlekins (XYZBCW mill-turn, two spindles) + DEBUG = 0 + +[DISPLAY] +# X Y Z are already the tip in the frame of the part the type works on, so +# the plot takes them as they are: a rotary in GEOMETRY would turn them +# again, and W, a translation there, would draw as a move along Z + GEOMETRY = XYZ + DISPLAY = axis + OPEN_FILE = ./twin-spindle-holes.ngc + INCREMENTS = 10 mm, 1 mm, .1 mm + JOG_AXES = XYZ + CYCLE_TIME = 0.100 + POSITION_OFFSET = RELATIVE +POSITION_FEEDBACK = ACTUAL +MAX_FEED_OVERRIDE = 2.0 + PROGRAM_PREFIX = ../../nc_files/ + INTRO_GRAPHIC = linuxcnc.gif + INTRO_TIME = 2 + TOOL_EDITOR = tooledit z diam + +[RS274NGC] +RS274NGC_STARTUP_CODE = G17 G21 G40 G49 G54 G80 G90 G94 G97 + PARAMETER_FILE = twinspindle.var +# Off the machine frame kinematics (on either spindle's type), G53, G28 and +# G30 move the slides in the machine frame, as G53.5, G28.5 and G30.5 do, +# wherever the tool and the head point, and G28.1 and G30.1 store that +# position. Unset, they move in the world of the spindle's type. See +# MACHINE_MOVES_IN_MACHINE_FRAME in the INI file documentation. +MACHINE_MOVES_IN_MACHINE_FRAME = 1 + +[EMCMOT] + EMCMOT = motmod +COMM_TIMEOUT = 1.0 +SERVO_PERIOD = 1000000 + +[TASK] + TASK = milltask +CYCLE_TIME = 0.010 + +[HAL] + HALUI = halui +HALFILE = LIB:basic_sim.tcl +HALFILE = twinspindle.hal + +[TRAJ] + COORDINATES = XYZBCW + LINEAR_UNITS = mm + ANGULAR_UNITS = degree +DEFAULT_LINEAR_VELOCITY = 50.0 + MAX_LINEAR_VELOCITY = 200.0 +MAX_LINEAR_ACCELERATION = 800.0 +DEFAULT_LINEAR_ACCELERATION = 800.0 + MAX_ANGULAR_VELOCITY = 360.0 + +[EMCIO] +TOOL_TABLE = twinspindle.tbl + +[KINS] +# type 0: the part in the main spindle, C and B orient +# type 1: the part in the sub spindle, W and B orient +# type 2: identity, the machine frame +KINEMATICS = twinspindlekins + JOINTS = 6 + +[AXIS_X] + MIN_LIMIT = -400 + MAX_LIMIT = 500 + MAX_VELOCITY = 200 +MAX_ACCELERATION = 800 + +[AXIS_Y] + MIN_LIMIT = -300 + MAX_LIMIT = 300 + MAX_VELOCITY = 200 +MAX_ACCELERATION = 800 + +[AXIS_Z] + MIN_LIMIT = -300 + MAX_LIMIT = 800 + MAX_VELOCITY = 200 +MAX_ACCELERATION = 800 + +[AXIS_B] + MIN_LIMIT = -30 + MAX_LIMIT = 210 + MAX_VELOCITY = 90 +MAX_ACCELERATION = 400 + +# the main spindle +[AXIS_C] + WRAPPED_ROTARY = 1 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + MAX_VELOCITY = 180 +MAX_ACCELERATION = 720 + +# the sub spindle: an angle, so ANGULAR, however the letter reads +[AXIS_W] + TYPE = ANGULAR + WRAPPED_ROTARY = 1 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + MAX_VELOCITY = 180 +MAX_ACCELERATION = 720 + +# the joints home to the head over the middle, pointing down at the +# spindle line, clear of both parts +[JOINT_0] + TYPE = LINEAR + MAX_VELOCITY = 200 +MAX_ACCELERATION = 800 + MIN_LIMIT = -400 + MAX_LIMIT = 500 + HOME = 300 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_1] + TYPE = LINEAR + MAX_VELOCITY = 200 +MAX_ACCELERATION = 800 + MIN_LIMIT = -300 + MAX_LIMIT = 300 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_2] + TYPE = LINEAR + MAX_VELOCITY = 200 +MAX_ACCELERATION = 800 + MIN_LIMIT = -300 + MAX_LIMIT = 800 + HOME = 50 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_3] + TYPE = ANGULAR + MAX_VELOCITY = 90 +MAX_ACCELERATION = 400 + MIN_LIMIT = -30 + MAX_LIMIT = 210 + HOME = 90 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_4] + TYPE = ANGULAR + MAX_VELOCITY = 180 +MAX_ACCELERATION = 720 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_5] + TYPE = ANGULAR + MAX_VELOCITY = 180 +MAX_ACCELERATION = 720 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 diff --git a/configs/sim/axis/vismach/twinspindle/twinspindle.tbl b/configs/sim/axis/vismach/twinspindle/twinspindle.tbl new file mode 100644 index 00000000000..569cf6b70b2 --- /dev/null +++ b/configs/sim/axis/vismach/twinspindle/twinspindle.tbl @@ -0,0 +1 @@ +T1 P1 Z50 D10 ;drill diff --git a/configs/sim/axis/vismach/twinspindle/twinspindlegui.py b/configs/sim/axis/vismach/twinspindle/twinspindlegui.py new file mode 100755 index 00000000000..4d4f25178cb --- /dev/null +++ b/configs/sim/axis/vismach/twinspindle/twinspindlegui.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# The twinspindlekins machine: a B tilting head on X Y Z between a main +# spindle (C) and a sub spindle (W) that face each other along Z. The model +# is built in machine coordinates and turned at the end so that Z, the +# spindle line, runs across the screen as on a lathe: main spindle on the +# left, Z to the right, X up. +# +# pivot_len and spindle_distance are handed to the kinematics by +# twinspindle.hal, so the drawing and the maths agree; they can be set at +# invocation, example: twinspindlegui.py pivot_len=200 + +from vismach import * +import hal +import sys + +pivot_len = 150 # gauge line to the B axis +spindle_distance = 500 # main spindle face to sub spindle face +lat, lon = -80, 0 # the starting view, from the front + +for setting in sys.argv[1:]: + exec(setting) + +c = hal.component("twinspindlegui") +for pin in ("jx", "jy", "jz", "jb", "jc", "jw", "tool_length", "tool_diam"): + c.newpin(pin, hal.Type.REAL, hal.Dir.IN) +c.newpin("pivot_len", hal.Type.REAL, hal.Dir.OUT) +c.newpin("spindle_distance", hal.Type.REAL, hal.Dir.OUT) +c["pivot_len"] = pivot_len +c["spindle_distance"] = spindle_distance +c.ready() + +class HalToolCylinder(CylinderZ): + def __init__(self, comp, *args): + CylinderZ.__init__(self, *args) + self.comp = comp + + def coords(self): + r = 5 # default if hal pin not set + if c.tool_diam > 0: r = c.tool_diam/2 + return -self.comp.tool_length, r, 0, r + +# a chuck and a part, face at z 0, the part standing on +z; the flat on +# the part shows the spindle turning +def spindle(work=None): + part = [CylinderZ(0, 50, 60, 50), + Color([1, 0.2, 0.2, 1], [Box(40, -8, 0, 52, 8, 60)])] + if work: + part.append(Translate([work], 0, 0, 60)) + return Collection([Color([0.6, 0.6, 0.7, 1], [CylinderZ(-100, 90, 0, 90)]), + Color([0.9, 0.8, 0.5, 1], part)]) + +# the main spindle turns the work by -C: its frame is Rz(-C) +work = Capture() +main_spindle = HalRotate([spindle(work)], c, "jc", -1, 0, 0, 1) +main_spindle = Collection([main_spindle, + Box(-160, -160, -400, 160, 160, -100)]) + +# the sub spindle is the same, turned by -W, then half a turn about X to +# face the main spindle from spindle_distance +sub_spindle = HalRotate([spindle()], c, "jw", -1, 0, 0, 1) +sub_spindle = Collection([sub_spindle, + Box(-160, -160, -400, 160, 160, -100)]) +sub_spindle = Rotate([sub_spindle], 180, 1, 0, 0) +sub_spindle = HalTranslate([sub_spindle], c, "spindle_distance", 0, 0, 1) + +# the head, gauge line at z 0: the tool below it, the spindle motor above +# up to the B axis at pivot_len, which is then put at the origin +tooltip = Capture() +head = Collection([HalTranslate([tooltip], c, "tool_length", 0, 0, -1), + Color([0.9, 0.9, 0.2, 1], [HalToolCylinder(c)]), + CylinderZ(0, 30, 40, 45), + CylinderZ(40, 45, pivot_len - 45, 45), + Translate([CylinderY(-55, 55, 55, 55)], 0, 0, pivot_len)]) +head = Translate([head], 0, 0, -pivot_len) +head = HalRotate([head], c, "jb", 1, 0, 1, 0) + +# the ram carries the B axis from behind, along -Y, clear of the head +# whichever way it tilts; the slides read the gauge line at B 0, pivot_len +# below the B axis +head = Collection([head, + Box(-50, -700, -50, 50, -60, 50)]) +head = Translate([head], 0, 0, pivot_len) +head = HalTranslate([head], c, "jx", 1, 0, 0) +head = HalTranslate([head], c, "jy", 0, 1, 0) +head = HalTranslate([head], c, "jz", 0, 0, 1) + +bed = Box(-420, -900, -450, -400, 300, 1000) + +model = Collection([bed, main_spindle, sub_spindle, head]) +# Z across the screen to the right, X up, as on a lathe +model = Rotate([model], -90, 0, 1, 0) +model = Rotate([model], 180, 0, 0, 1) + +main(model, tooltip, work, size=900, lat=lat, lon=lon) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index e8b42b525dc..d6e48e021ae 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1778,12 +1778,12 @@ change the tool length with the tool axis untilted, motion stops the program otherwise. Of those, the modules that also report where the tool points (5axiskins, -the trt modules, the trsrn modules) apply an X and Y of the offset along -the tool's own X and Y, as they apply the length along the tool axis. The -offset is given in the tool's axes, which are the machine's with the -rotaries at zero, so a tool held off the spindle axis keeps its offset as -the head or the table turns. Under the identity and the other modules, X -and Y apply along the work axes. +the trt modules, the trsrn modules, twinspindlekins) apply an X and Y of +the offset along the tool's own X and Y, as they apply the length along +the tool axis. The offset is given in the tool's axes, which are the +machine's with the rotaries at zero, so a tool held off the spindle axis +keeps its offset as the head or the table turns. Under the identity and +the other modules, X and Y apply along the work axes. [NOTE] 'G43 H0' is a little special. Its behavior is different on random diff --git a/docs/src/man/man9/kins.9.adoc b/docs/src/man/man9/kins.9.adoc index 4b48ec336a7..16ebf850e4b 100644 --- a/docs/src/man/man9/kins.9.adoc +++ b/docs/src/man/man9/kins.9.adoc @@ -44,6 +44,8 @@ kins, genhexkins, genserkins, maxkins, pentakins, pumakins, rotatekins, scarakin *loadrt 5axiskins* +*loadrt twinspindlekins* + == DESCRIPTION Rather than exporting HAL pins and functions, these components provide @@ -427,6 +429,39 @@ expected by it (XYZBCW `->` joints 0..5) one rather than replacing it. Put a given length in one column or the other, not both. +=== twinspindlekins - mill-turn with two spindles + +XYZBCW -- a head on X Y Z tilts the tool on B, about Y, between a main +spindle turning its part on C and a sub spindle facing it along Z and +turning its own part on W. Declare W `TYPE = ANGULAR` in its `[AXIS_W]` +section; C and W may be `WRAPPED_ROTARY`. Coordinates XYZBCW are required; +A, U and V may be added with the coordinates parameter and map one to one +to their joints. + +Type 0 works in the frame of the part in the main spindle, and orients the +tool with C and B. Type 1 works in the frame of the part in the sub spindle, +which is the main spindle's turned half a turn about X, so its Z too points +out of the face towards the tool, and orients the tool with W and B. Both +are primary: G12.1 selects the spindle, and a program runs the same on +either part. Type 2 is the identity and the machine frame. The rotary +directions are the conventional ones. + +With B at 0 the tool points along -Z and the slides read the gauge line; the +tool length is applied along the tool, as on 5axiskins. The sim config +configs/sim/axis/vismach/twinspindle drills one subroutine's holes into +both parts. + +*twinspindlekins.pivot-length*:: + Distance from the B rotation point to the tool holder gauge line. + +*twinspindlekins.tool-length*:: + Tool length, applied along the tool. Motion hands the module the offset + in effect (G43, G49), so the pin needs no connection. An X and Y of the + offset are applied along the tool's own X and Y. + +*twinspindlekins.spindle-distance*:: + Distance along Z from the main spindle face to the sub spindle face. + == SEE ALSO For additional information, see following subsections of the section 'Advanced Topics' of the LinuxCNC documentation: diff --git a/docs/src/motion/switchkins.adoc b/docs/src/motion/switchkins.adoc index 0a28ae9db0c..c6e7aaa8f43 100644 --- a/docs/src/motion/switchkins.adoc +++ b/docs/src/motion/switchkins.adoc @@ -50,6 +50,7 @@ The following kinematics modules support switchable kinematics: . *xyzab_tdr_kins* (type0:identity type1:tcp) . *xyzacb_trsrn* (type0:identity type1:tcp type2:tool) . *xyzbca_trsrn* (type0:identity type1:tcp type2:tool) +. *twinspindlekins* (type0:main spindle type1:sub spindle type2:identity) Every module listed above uses its own kinematics for type0 and identity kinematics for type1. Each accepts the module string @@ -72,6 +73,9 @@ type0 is then reached without running the failing kinematics again. The 'sparm' setting exchanges type0 and type1, so any G-code or HAL logic that selects a kinematics type by number must match. +twinspindlekins has no 'sparm': its type0 and type1 are both working +kinematics, one per spindle, and type2 is the identity. + Kinematics that solve the forward direction iteratively, genhexkins among them, need a pose to start from. While another type is running they take the estimate the caller supplies, which motion seeds from @@ -466,6 +470,7 @@ configs/sim/axis/vismach/ . . 5axis/table-dual-rotary/xyzab-tdr.ini (xyzab_tdr_kins) . 5axis/table-rotary_spindle-rotary-nutating/xyzacb-trsrn_twp/xyzacb-trsrn.ini (xyzacb_trsrn) . 5axis/table-rotary_spindle-rotary-nutating/xyzbca-trsrn_twp/xyzbca-trsrn.ini (xyzbca_trsrn) +. twinspindle/twinspindle.ini (twinspindlekins) == User kinematics provisions diff --git a/src/Makefile b/src/Makefile index d46373780be..cd63e966b75 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1229,6 +1229,15 @@ obj-m += 5axiskins.o 5axiskins-objs += emc/kinematics/switchkins_main.o 5axiskins-objs += emc/kinematics/switchkins_setup.o 5axiskins-objs += $(USERKFUNCS) + +obj-m += twinspindlekins.o +twinspindlekins-objs := emc/kinematics/twinspindlekins.o +twinspindlekins-objs += libposemath/_posemath.o +twinspindlekins-objs += $(MATHSTUB) +twinspindlekins-objs += emc/kinematics/kins_util.o +twinspindlekins-objs += emc/kinematics/switchkins.o +twinspindlekins-objs += emc/kinematics/switchkins_main.o +twinspindlekins-objs += emc/kinematics/switchkins_setup.o #---------------------------------------------------------------- obj-$(CONFIG_MOTMOD) += motmod.o @@ -1395,6 +1404,7 @@ endif ../rtlib/5axiskins$(MODULE_EXT): $(addprefix objects/rt,$(5axiskins-objs)) ../rtlib/switchkins_core$(MODULE_EXT): $(addprefix objects/rt,$(switchkins_core-objs)) ../rtlib/kins_single_core$(MODULE_EXT): $(addprefix objects/rt,$(kins_single_core-objs)) +../rtlib/twinspindlekins$(MODULE_EXT): $(addprefix objects/rt,$(twinspindlekins-objs)) ../rtlib/maxkins$(MODULE_EXT): $(addprefix objects/rt,$(maxkins-objs)) ../rtlib/rotatekins$(MODULE_EXT): $(addprefix objects/rt,$(rotatekins-objs)) ../rtlib/tripodkins$(MODULE_EXT): $(addprefix objects/rt,$(tripodkins-objs)) diff --git a/src/emc/kinematics/twinspindlekins.c b/src/emc/kinematics/twinspindlekins.c new file mode 100644 index 00000000000..8592f2b2598 --- /dev/null +++ b/src/emc/kinematics/twinspindlekins.c @@ -0,0 +1,278 @@ +/******************************************************************** +* Description: twinspindlekins.c +* kinematics for a mill-turn with a tilting head and two spindles +* +* License: GPL Version 2 +* +* Notes: +* 1) The head carries the tool on X Y Z and tilts it on B, about Y, from +* a pivot pivot-length above the gauge line. With B at 0 the tool +* points along -Z, tool axis +Z, and the slides read the gauge line. +* The pose is the tip plus the tool length along the part's Z, which +* G43 takes off again, so a tilt moves the tip by the length along +* the tool axis less the length along Z the offset stands for. +* 2) The main spindle turns the work about machine Z on C, its face in +* the plane Z 0. The sub spindle faces it from spindle-distance along +* +Z and turns its own work on W, which the INI makes ANGULAR. +* 3) Type 0 works on the part in the main spindle and type 1 on the part +* in the sub spindle, each in that part's own frame: X Y Z of the part +* and B, C or W the orientation. Both are primary: G12.1 picks the +* spindle. Type 2 is the identity and stands in for the machine frame. +* 4) The sub spindle part frame is the main spindle's turned half a turn +* about X: X stays, Y and Z reverse, so Z still points out of the face +* towards the tool. Moved to the other spindle, a program reads the +* same. +* 5) The rotary directions are the conventional ones: C and W turn the +* work the way that turns the tool positively about the part's Z. +* 6) Coordinates XYZBCW are required, A U V may be added with the +* coordinates parameter and map one to one to their joints. +********************************************************************/ + +#define REQUIRED_COORDINATES "XYZBCW" + +#include +#include +#include +#include + +#include + +static const kins_param_desc twin_params[] = { + { "pivot-length", KINS_PARAM_REAL, KINS_IN, 0, { .r = 150.0 } }, + { "tool-length", KINS_PARAM_REAL, KINS_IN, 1, { .r = 0.0 } }, + { "spindle-distance", KINS_PARAM_REAL, KINS_IN, 0, { .r = 500.0 } }, +}; +enum { P_PIVOT_LENGTH, P_TOOL_LENGTH, P_SPINDLE_DISTANCE }; + +#define JX (p->joint_of_axis[0]) +#define JY (p->joint_of_axis[1]) +#define JZ (p->joint_of_axis[2]) +#define JA (p->joint_of_axis[3]) +#define JB (p->joint_of_axis[4]) +#define JC (p->joint_of_axis[5]) +#define JU (p->joint_of_axis[6]) +#define JV (p->joint_of_axis[7]) +#define JW (p->joint_of_axis[8]) + +// the tool tip in the machine frame, from the slides and B (note 1) +static PmCartesian tip_from_joints(const kins_params *p, const double *joints) +{ + const double P = p->geometry[P_PIVOT_LENGTH]; + const double L = P + p->tool.tran.z; + const double b = joints[JB]*TO_RAD; + PmCartesian t; + + t.x = joints[JX] - L*sin(b); + t.y = joints[JY]; + t.z = joints[JZ] + P - L*cos(b); + return t; +} // tip_from_joints() + +// the part frame of each spindle, the machine seen from the part: machine +// = O + R part, with R = Rz(-C) for the main spindle and Rx(180) Rz(-W) for +// the sub spindle (notes 2, 4, 5) +static PmCartesian part_from_machine(const kins_params *p, int sub, + double angle, PmCartesian m) +{ + const double s = sin(angle*TO_RAD), c = cos(angle*TO_RAD); + PmCartesian q, r; + + q = m; + if (sub) { + q.y = -m.y; + q.z = p->geometry[P_SPINDLE_DISTANCE] - m.z; + } + r.x = c*q.x - s*q.y; + r.y = s*q.x + c*q.y; + r.z = q.z; + return r; +} // part_from_machine() + +static PmCartesian machine_from_part(const kins_params *p, int sub, + double angle, PmCartesian r) +{ + const double s = sin(angle*TO_RAD), c = cos(angle*TO_RAD); + PmCartesian q, m; + + q.x = c*r.x + s*r.y; + q.y = -s*r.x + c*r.y; + q.z = r.z; + m = q; + if (sub) { + m.y = -q.y; + m.z = p->geometry[P_SPINDLE_DISTANCE] - q.z; + } + return m; +} // machine_from_part() + +static int twin_forward(const kins_params *p, int sub, const double *joints, + EmcPose *pos) +{ + const double angle = sub ? joints[JW] : joints[JC]; + + pos->tran = part_from_machine(p, sub, angle, tip_from_joints(p, joints)); + pos->tran.z += p->tool.tran.z; + pos->b = joints[JB]; + pos->c = joints[JC]; + pos->w = joints[JW]; + + // optional letters (specify with coordinates module parameter) + pos->a = (JA != -1)? joints[JA] : 0; + pos->u = (JU != -1)? joints[JU] : 0; + pos->v = (JV != -1)? joints[JV] : 0; + + return 0; +} // twin_forward() + +static int twin_inverse(const kins_params *p, int sub, const EmcPose *pos, + double *joints) +{ + const double T = p->tool.tran.z; + const double L = p->geometry[P_PIVOT_LENGTH] + T; + const double b = pos->b*TO_RAD; + PmCartesian tip = pos->tran; + PmCartesian t; + EmcPose P; // computed position + + tip.z -= T; + t = machine_from_part(p, sub, sub ? pos->w : pos->c, tip); + P.tran.x = t.x + L*sin(b); + P.tran.y = t.y; + P.tran.z = t.z - p->geometry[P_PIVOT_LENGTH] + L*cos(b); + P.b = pos->b; + P.c = pos->c; + P.w = pos->w; + + // optional letters (specify with coordinates module parameter) + P.a = (JA != -1)? pos->a : 0; + P.u = (JU != -1)? pos->u : 0; + P.v = (JV != -1)? pos->v : 0; + + return kinsPoseToMappedJoints(p, &P, joints); +} // twin_inverse() + +static int main_forward(const kins_params *p, kins_scratch *s, + const double *joints, EmcPose *pos, + const KINEMATICS_FORWARD_FLAGS *fflags, + KINEMATICS_INVERSE_FLAGS *iflags) +{ + (void)s; (void)fflags; (void)iflags; + return twin_forward(p, 0, joints, pos); +} + +static int main_inverse(const kins_params *p, kins_scratch *s, + const EmcPose *pos, double *joints, + const KINEMATICS_INVERSE_FLAGS *iflags, + KINEMATICS_FORWARD_FLAGS *fflags) +{ + (void)s; (void)iflags; (void)fflags; + return twin_inverse(p, 0, pos, joints); +} + +static int sub_forward(const kins_params *p, kins_scratch *s, + const double *joints, EmcPose *pos, + const KINEMATICS_FORWARD_FLAGS *fflags, + KINEMATICS_INVERSE_FLAGS *iflags) +{ + (void)s; (void)fflags; (void)iflags; + return twin_forward(p, 1, joints, pos); +} + +static int sub_inverse(const kins_params *p, kins_scratch *s, + const EmcPose *pos, double *joints, + const KINEMATICS_INVERSE_FLAGS *iflags, + KINEMATICS_FORWARD_FLAGS *fflags) +{ + (void)s; (void)iflags; (void)fflags; + return twin_inverse(p, 1, pos, joints); +} + +// the tool frame, Ry(B), is the same on both spindles +static int twin_tool_frame(const kins_params *p, const double *joints, + PmRotationMatrix *rot, + const KINEMATICS_FORWARD_FLAGS *fflags) +{ + (void)fflags; + const double sb = sin(joints[JB]*TO_RAD), cb = cos(joints[JB]*TO_RAD); + + rot->x.x = cb; rot->y.x = 0; rot->z.x = sb; + rot->x.y = 0; rot->y.y = 1; rot->z.y = 0; + rot->x.z = -sb; rot->y.z = 0; rot->z.z = cb; + + return 0; +} // twin_tool_frame() + +// the work frames, the R of part_from_machine(), its columns the part axes +static int main_work_frame(const kins_params *p, const double *joints, + PmRotationMatrix *rot, + const KINEMATICS_FORWARD_FLAGS *fflags) +{ + (void)fflags; + const double s = sin(joints[JC]*TO_RAD), c = cos(joints[JC]*TO_RAD); + + rot->x.x = c; rot->y.x = s; rot->z.x = 0; + rot->x.y = -s; rot->y.y = c; rot->z.y = 0; + rot->x.z = 0; rot->y.z = 0; rot->z.z = 1; + + return 0; +} // main_work_frame() + +static int sub_work_frame(const kins_params *p, const double *joints, + PmRotationMatrix *rot, + const KINEMATICS_FORWARD_FLAGS *fflags) +{ + (void)fflags; + const double s = sin(joints[JW]*TO_RAD), c = cos(joints[JW]*TO_RAD); + + rot->x.x = c; rot->y.x = s; rot->z.x = 0; + rot->x.y = s; rot->y.y = -c; rot->z.y = 0; + rot->x.z = 0; rot->y.z = 0; rot->z.z = -1; + + return 0; +} // sub_work_frame() + +// each spindle orients with its own rotary, the table first, and B; the +// joint map gives the same letters, declared so the table reads +static const kins_ops main_ops = { + .forward = main_forward, + .inverse = main_inverse, + .work = main_work_frame, + .tool = twin_tool_frame, + .native = &TOOL_FRAME_SPINDLE, + .primary = 1, + .orient = "CB", +}; + +static const kins_ops sub_ops = { + .forward = sub_forward, + .inverse = sub_inverse, + .work = sub_work_frame, + .tool = twin_tool_frame, + .native = &TOOL_FRAME_SPINDLE, + .primary = 1, + .orient = "WB", +}; + +int switchkinsSetup(kparms* kp, + KS* kset0, KS* kset1, KS* kset2, + KF* kfwd0, KF* kfwd1, KF* kfwd2, + KI* kinv0, KI* kinv1, KI* kinv2 + ) +{ + (void)kset0; (void)kset1; (void)kset2; + (void)kfwd0; (void)kfwd1; (void)kfwd2; + (void)kinv0; (void)kinv1; (void)kinv2; + kp->kinsname = "twinspindlekins"; // !!! must agree with filename + kp->halprefix = "twinspindlekins"; // hal pin names + kp->required_coordinates = REQUIRED_COORDINATES; + kp->allow_duplicates = 1; + kp->max_joints = EMCMOT_MAX_JOINTS; + kp->params = twin_params; + kp->nparams = sizeof(twin_params)/sizeof(twin_params[0]); + + switchkinsRegisterOps(0, &main_ops); + switchkinsRegisterOps(1, &sub_ops); + switchkinsRegisterOps(2, &KINS_IDENTITY_OPS); + + return 0; +} // switchkinsSetup() diff --git a/tests/kins-params/test.sh b/tests/kins-params/test.sh index 7456b518774..a81a5f3aabf 100755 --- a/tests/kins-params/test.sh +++ b/tests/kins-params/test.sh @@ -104,6 +104,19 @@ run "maxkins" \ run "5axiskins coordinates=XYZBCW" "" "joints=6 jnt=10,20,30,15,25,5 orient=4,3 posejoint=3" run "5axiskins coordinates=XYZBCW sparm=identityfirst" "" "joints=6 jnt=10,20,30,15,25,5 orient=4,3 posejoint=3" 1 +# a table and a head, two primaries: one rotary turns the tool, so no +# pair, and that one names the pose +run "twinspindlekins coordinates=XYZBCW" \ + "setp twinspindlekins.pivot-length 120 +setp twinspindlekins.tool-length 30 +setp twinspindlekins.spindle-distance 400" \ + "joints=6 jnt=10,20,30,15,25,35 orient=- posejoint=3" +run "twinspindlekins coordinates=XYZBCW" \ + "setp twinspindlekins.pivot-length 120 +setp twinspindlekins.tool-length 30 +setp twinspindlekins.spindle-distance 400" \ + "joints=6 jnt=10,20,30,15,25,35 orient=- posejoint=3" 1 + run "xyzac-trt-kins coordinates=XYZAC" \ "setp xyzac-trt-kins.y-offset 3 setp xyzac-trt-kins.z-offset 11 @@ -207,6 +220,14 @@ setp xyzbca_trsrn_kins.y-offset 7 setp xyzbca_trsrn_kins.x-rot-axis 300 setp xyzbca_trsrn_kins.z-rot-axis 400" \ "joints=6 jnt=10,20,30,15,25,35 orient=5,3 posejoint=3 tool=4,3,50" 1 +run "twinspindlekins coordinates=XYZBCW" \ + "setp twinspindlekins.pivot-length 120 +setp twinspindlekins.spindle-distance 400" \ + "joints=6 jnt=10,20,30,15,25,35 orient=- posejoint=3 tool=4,3,30" +run "twinspindlekins coordinates=XYZBCW" \ + "setp twinspindlekins.pivot-length 120 +setp twinspindlekins.spindle-distance 400" \ + "joints=6 jnt=10,20,30,15,25,35 orient=- posejoint=3 tool=4,3,30" 1 # polar run "rosekins" "" "joints=3 jnt=10,5,30" diff --git a/tests/twinspindle/README b/tests/twinspindle/README new file mode 100644 index 00000000000..cde0e5d9d5f --- /dev/null +++ b/tests/twinspindle/README @@ -0,0 +1,12 @@ +twinspindlekins: a B tilting head between a main spindle on C and a sub +spindle on W, W ANGULAR, each spindle a primary kinematics type in the +frame of its own part, and an identity type. + +The test checks that each type names its own rotaries on +#<_kins_orient_1> to #<_kins_orient_3> and their head flags, C then B on +the main spindle, W then B on the sub spindle, nothing on the identity; +that G53.2 and G53.3 on the same tilted hole give the spindle angle and a +B on either side of 180 as #<_orient_rot1> and #<_orient_rot2>, and put +the tip on the hole with the tool along its axis, worked out from the +joints; and that a copy of the sim config's demo program drills both +parts through one subroutine and parks. diff --git a/tests/twinspindle/checkresult b/tests/twinspindle/checkresult new file mode 100755 index 00000000000..9d48d3f180e --- /dev/null +++ b/tests/twinspindle/checkresult @@ -0,0 +1,3 @@ +#!/bin/sh +# the test script counts its own failures +grep -q "^Exiting with 0 errors" "$1" diff --git a/tests/twinspindle/sim.hal b/tests/twinspindle/sim.hal new file mode 100644 index 00000000000..e92c60eb526 --- /dev/null +++ b/tests/twinspindle/sim.hal @@ -0,0 +1,16 @@ +loadrt [KINS]KINEMATICS +loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS + +addf motion-command-handler servo-thread +addf motion-controller servo-thread + +net J0 joint.0.motor-pos-cmd => joint.0.motor-pos-fb +net J1 joint.1.motor-pos-cmd => joint.1.motor-pos-fb +net J2 joint.2.motor-pos-cmd => joint.2.motor-pos-fb +net J3 joint.3.motor-pos-cmd => joint.3.motor-pos-fb +net J4 joint.4.motor-pos-cmd => joint.4.motor-pos-fb +net J5 joint.5.motor-pos-cmd => joint.5.motor-pos-fb + +net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in +net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared +net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed diff --git a/tests/twinspindle/test-ui.py b/tests/twinspindle/test-ui.py new file mode 100755 index 00000000000..bea2017dd15 --- /dev/null +++ b/tests/twinspindle/test-ui.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 +# twinspindlekins: two primary types, one per spindle, orienting with +# different rotaries: see README. + +import linuxcnc +import linuxcnc_util +import math +import os +import sys +import time + +JOINTS = 6 +PIVOT = 150.0 # twinspindlekins.pivot-length default +DISTANCE = 500.0 # twinspindlekins.spindle-distance default +TOOL = 50.0 # T1 in tool.tbl +FACE = 60.0 # G54 and G55 Z, the part faces +PROGRAM = os.path.join(os.path.dirname(os.path.abspath(__file__)), + "twin-spindle-holes.ngc") + +c = linuxcnc.command() +s = linuxcnc.stat() +e = linuxcnc.error_channel() + +c.state(linuxcnc.STATE_ESTOP_RESET) +c.state(linuxcnc.STATE_ON) +linuxcnc_util.LinuxCNC(command=c, status=s).home_all() +c.mode(linuxcnc.MODE_MDI) +c.wait_complete() + +errors = 0 + +def error(msg): + global errors + errors += 1 + print("*** ERROR " + msg) + +def drain(): + while True: + m = e.poll() + if not m: + return + print("channel:", m) + if m[0] in (linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR): + error("reported: %s" % m[1]) + +def settled(): + deadline = time.time() + 60 + last = None + while time.time() < deadline: + s.poll() + now = [s.joint_position[i] for i in range(JOINTS)] + if s.inpos and not s.queue and now == last: + return now + last = now + time.sleep(0.01) + error("timed out waiting for the move") + return last + +def mdi(*cmds): + for cmd in cmds: + c.mdi(cmd) + c.wait_complete(60) + return settled() + +def param(name): + drain() + c.mdi("(debug,#<%s>)" % name) + c.wait_complete(30) + deadline = time.time() + 5 + while time.time() < deadline: + m = e.poll() + if not m: + time.sleep(0.01) + continue + if m[0] == linuxcnc.OPERATOR_DISPLAY: + return float(m[1]) + error("#<%s> gave no value" % name) + return None + +def turn(a, b): + # a and b the same angle, whole turns apart + return abs((a - b + 180.0) % 360.0 - 180.0) < 1e-6 + +# the module's maths, written out again: the tip and the tool axis, tip +# towards holder, in the frame of the part on spindle `sub`. The slides +# carry the B axis PIVOT above the gauge line, the tip hangs PIVOT + TOOL +# below it along the tool axis. +def part_pose(j, sub): + L = PIVOT + TOOL + b = math.radians(j[3]) + m = [j[0] - L*math.sin(b), j[1], j[2] + PIVOT - L*math.cos(b)] + u = [math.sin(b), 0.0, math.cos(b)] + if sub: + m = [m[0], -m[1], DISTANCE - m[2]] + u = [u[0], -u[1], -u[2]] + a = math.radians(j[5] if sub else j[4]) + rz = lambda v: [math.cos(a)*v[0] - math.sin(a)*v[1], + math.sin(a)*v[0] + math.cos(a)*v[1], v[2]] + return rz(m), rz(u) + +ORIENT = ("_kins_orient_1", "_kins_orient_2", "_kins_orient_3", + "_kins_orient_1_head", "_kins_orient_2_head", "_kins_orient_3_head") + +mdi("T1 M6", "G43", + "G10 L2 P1 X0 Y0 Z%g C0 W0" % FACE, + "G10 L2 P2 X0 Y0 Z%g C0 W0" % FACE) + +# ---- each type names its own rotaries -------------------------------------- + +for ktype, want, what in ((0, [5, 4, -1, 0, 1, -1], "C then B"), + (1, [8, 4, -1, 0, 1, -1], "W then B"), + (2, [-1] * 6, "nothing")): + mdi("G12.1 P%d" % ktype) + got = [param(n) for n in ORIENT] + if got != want: + error("type %d orients with %s, not %s: table then head" % (ktype, got, what)) + +# ---- the same hole on either spindle --------------------------------------- +# +# A hole 30 out on the face at 60 degrees, tilted 20 degrees outwards. On +# the main spindle C turns it under the head and B leans the tool; on the +# sub spindle, whose part faces the other way, W turns it and B leans the +# tool past 180. + +A, T, R = 60.0, 20.0, 30.0 +n = [math.sin(math.radians(T))*math.cos(math.radians(A)), + math.sin(math.radians(T))*math.sin(math.radians(A)), + math.cos(math.radians(T))] +hole = [R*math.cos(math.radians(A)), R*math.sin(math.radians(A)), 0.0] +PLANE = ("G68.2 P3 Q1 X%.9f Y%.9f Z0 I%.9f J%.9f K0" + % (hole[0], hole[1], -math.sin(math.radians(A)), math.cos(math.radians(A))), + "G68.2 P3 Q2 I%.9f J%.9f K%.9f" % tuple(n)) + +for ktype, offset, joint, b in ((0, "G54", 4, T), (1, "G55", 5, 180.0 - T)): + sub = ktype == 1 + mdi("G13.1", "G53 G0 X300", "G53 G0 Z50 B90") + mdi("G12.1 P%d" % ktype, offset, *PLANE) + mdi("G53.2") + rot1, rot2 = param("_orient_rot1"), param("_orient_rot2") + print("type %d: rot1 %.6f rot2 %.6f" % (ktype, rot1, rot2)) + if not (turn(rot1, A) and abs(rot2 - b) < 1e-6): + error("type %d: G53.2 gave rot1 %s rot2 %s, not %s and %s" % (ktype, rot1, rot2, A, b)) + j = mdi("G53.3 X0 Y0 Z5") + if not (turn(j[joint], A) and abs(j[3] - b) < 1e-6): + error("type %d: G53.3 left joint %d at %s and B at %s" % (ktype, joint, j[joint], j[3])) + tip, axis = part_pose(j, sub) + want = [hole[i] + 5*n[i] + (FACE if i == 2 else 0.0) for i in range(3)] + if max(abs(tip[i] - want[i]) for i in range(3)) > 1e-6: + error("type %d: the tip is at %s in the part, not %s" % (ktype, tip, want)) + if max(abs(axis[i] - n[i]) for i in range(3)) > 1e-9: + error("type %d: the tool points along %s in the part, not %s" % (ktype, axis, n)) + mdi("G69") +drain() + +# ---- the demo program, both spindles, one subroutine ----------------------- + +mdi("G13.1", "G54") +c.mode(linuxcnc.MODE_AUTO) +c.wait_complete() +c.feedrate(100) +c.program_open(PROGRAM) +c.auto(linuxcnc.AUTO_RUN, 0) +started = time.time() + 5 +while time.time() < started: + s.poll() + if s.interp_state != linuxcnc.INTERP_IDLE: + break + time.sleep(0.002) +deadline = time.time() + 300 +while time.time() < deadline: + s.poll() + if s.interp_state == linuxcnc.INTERP_IDLE and s.queue == 0 and s.inpos: + break + time.sleep(0.01) +else: + error("the demo program did not finish") +drain() +j = settled() +if max(abs(j[i] - w) for i, w in ((0, 300.0), (2, 50.0), (3, 90.0))) > 1e-6: + error("the demo program ended at %s, not parked" % (j,)) + +c.state(linuxcnc.STATE_ESTOP) +for f in ("sim.var", "sim.var.bak"): + try: + os.unlink(f) + except OSError: + pass +print("Exiting with %d errors" % errors) +sys.exit(errors != 0) diff --git a/tests/twinspindle/test.ini b/tests/twinspindle/test.ini new file mode 100644 index 00000000000..0648bd7c100 --- /dev/null +++ b/tests/twinspindle/test.ini @@ -0,0 +1,142 @@ +[EMC] +VERSION = 1.1 +DEBUG = 0 + +[DISPLAY] +DISPLAY = ./test-ui.py +MAX_FEED_OVERRIDE = 100 + +[RS274NGC] +RS274NGC_STARTUP_CODE = G17 G21 G40 G49 G54 G80 G90 G94 G97 +PARAMETER_FILE = sim.var + +[KINS] +KINEMATICS = twinspindlekins +JOINTS = 6 + +[HAL] +HALFILE = sim.hal + +[TRAJ] +# the rates are high so the moves are short: the test checks only where +# they end; the feed override runs the drilling of the demo program fast +COORDINATES = XYZBCW +LINEAR_UNITS = mm +ANGULAR_UNITS = degree +DEFAULT_LINEAR_VELOCITY = 50 +MAX_LINEAR_VELOCITY = 4000 +MAX_LINEAR_ACCELERATION = 80000 +DEFAULT_LINEAR_ACCELERATION = 80000 +MAX_ANGULAR_VELOCITY = 7200 + +[EMCMOT] +EMCMOT = motmod +SERVO_PERIOD = 1000000 +COMM_TIMEOUT = 4 + +[TASK] +TASK = milltask +CYCLE_TIME = 0.001 + +[EMCIO] +TOOL_TABLE = tool.tbl + +[AXIS_X] + MIN_LIMIT = -400 + MAX_LIMIT = 500 + MAX_VELOCITY = 4000 +MAX_ACCELERATION = 80000 + +[AXIS_Y] + MIN_LIMIT = -300 + MAX_LIMIT = 300 + MAX_VELOCITY = 4000 +MAX_ACCELERATION = 80000 + +[AXIS_Z] + MIN_LIMIT = -300 + MAX_LIMIT = 800 + MAX_VELOCITY = 4000 +MAX_ACCELERATION = 80000 + +[AXIS_B] + MIN_LIMIT = -30 + MAX_LIMIT = 210 + MAX_VELOCITY = 1800 +MAX_ACCELERATION = 40000 + +# the main spindle +[AXIS_C] + WRAPPED_ROTARY = 1 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + MAX_VELOCITY = 3600 +MAX_ACCELERATION = 72000 + +# the sub spindle: an angle, so ANGULAR, however the letter reads +[AXIS_W] + TYPE = ANGULAR + WRAPPED_ROTARY = 1 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + MAX_VELOCITY = 3600 +MAX_ACCELERATION = 72000 + +# the joints home to the head over the middle, pointing down at the +# spindle line, clear of both parts +[JOINT_0] + TYPE = LINEAR + MAX_VELOCITY = 4000 +MAX_ACCELERATION = 80000 + MIN_LIMIT = -400 + MAX_LIMIT = 500 + HOME = 300 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_1] + TYPE = LINEAR + MAX_VELOCITY = 4000 +MAX_ACCELERATION = 80000 + MIN_LIMIT = -300 + MAX_LIMIT = 300 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_2] + TYPE = LINEAR + MAX_VELOCITY = 4000 +MAX_ACCELERATION = 80000 + MIN_LIMIT = -300 + MAX_LIMIT = 800 + HOME = 50 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_3] + TYPE = ANGULAR + MAX_VELOCITY = 1800 +MAX_ACCELERATION = 40000 + MIN_LIMIT = -30 + MAX_LIMIT = 210 + HOME = 90 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_4] + TYPE = ANGULAR + MAX_VELOCITY = 3600 +MAX_ACCELERATION = 72000 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 + +[JOINT_5] + TYPE = ANGULAR + MAX_VELOCITY = 3600 +MAX_ACCELERATION = 72000 + MIN_LIMIT = -1e9 + MAX_LIMIT = 1e9 + HOME_SEARCH_VEL = 0 + HOME_SEQUENCE = 0 diff --git a/tests/twinspindle/test.sh b/tests/twinspindle/test.sh new file mode 100755 index 00000000000..f494f0fc1fb --- /dev/null +++ b/tests/twinspindle/test.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e +# a failed run leaves the var file behind, and it carries the offsets +rm -f sim.var sim.var.bak +linuxcnc -r test.ini diff --git a/tests/twinspindle/tool.tbl b/tests/twinspindle/tool.tbl new file mode 100644 index 00000000000..569cf6b70b2 --- /dev/null +++ b/tests/twinspindle/tool.tbl @@ -0,0 +1 @@ +T1 P1 Z50 D10 ;drill diff --git a/tests/twinspindle/twin-spindle-holes.ngc b/tests/twinspindle/twin-spindle-holes.ngc new file mode 100644 index 00000000000..941a611c778 --- /dev/null +++ b/tests/twinspindle/twin-spindle-holes.ngc @@ -0,0 +1,67 @@ +; twin-spindle-holes.ngc - one subroutine drills the same ring of tilted +; holes into the part in the main spindle and into the part in the sub +; spindle. +; +; configs/sim/axis/vismach/twinspindle and tests/twinspindle each keep a +; copy of this program: change both, they are the same file. +; +; Kinematics type 0 works on the main spindle's part and orients the tool +; with C and B; type 1 works on the sub spindle's part and orients it with +; W and B. The subroutine names neither: G53.3 turns whatever rotaries the +; type in force orients with, and the report reads them by number, +; #<_kins_orient_1> and #<_kins_orient_2>, with their angles in the same +; order, #<_orient_rot1> and #<_orient_rot2>. Each part's frame has its Z +; out of its own spindle, so both faces are at Z60 and the offsets read +; the same. + +o sub + # = 6 ; holes + # = 30 ; hole circle radius on the face + # = 20 ; tilt of each hole out from the part axis + # = 0 + o101 while [# lt #] + # = [# * 360 / #] + ; the hole's plane: origin on the face, X along the hole circle, + ; Z the hole axis + g68.2 p3 q1 x[#*cos[#]] y[#*sin[#]] z0 i[-sin[#]] j[cos[#]] k0 + g68.2 p3 q2 i[sin[#]*cos[#]] j[sin[#]*sin[#]] k[cos[#]] + g53.2 ; solve the pose, report it + (print, hole #: axis #<_kins_orient_1> to #<_orient_rot1>, axis #<_kins_orient_2> to #<_orient_rot2>) + g53.3 x0 y0 z5 ; orient and go, 5 above the hole + g1 z-10 + g0 z5 + # = [# + 1] + o101 endwhile + g0 z40 + g69 +o endsub + +; from one part to the other in the machine frame, the identity type: +; up, clear of both parts, and the head pointing down +o sub + g13.1 + g53 g0 x300 + g53 g0 z50 b90 +o endsub + +g21 g90 g94 g17 g40 +t1 m6 +g43 +f300 + +g10 l2 p1 x0 y0 z60 c0 w0 ; G54, the main spindle's part +g10 l2 p2 x0 y0 z60 c0 w0 ; G55, the sub spindle's part + +o call +g12.1 p0 ; the main spindle's part +g54 +o call + +o call +g12.1 p1 ; the sub spindle's part +g55 +o call + +o call +g54 +m2