@@ -21,17 +21,18 @@ switched to identity kinematics for control of individual joints
2121after homing.
2222
2323The kinematics type is selected with 'G12.1 P-' and 'G13.1', from a
24- G-code program or by interactive MDI commands. It can also be selected
25- by a motion module HAL pin, which allows the halui provisions for
26- activating MDI commands to be used so that buttons select the
27- kinematics type from hardware controls or a virtual panel (PyVCP,
28- GladeVCP, etc.).
24+ G-code program or by interactive MDI commands. Buttons on a virtual
25+ panel (PyVCP, GladeVCP, etc.) or on hardware controls select a
26+ kinematics type through the halui provisions for activating MDI
27+ commands.
2928
3029Changing the kinematics type requires the interpreter and motion parts
31- of LinuxCNC to be *synchronized*. 'G12.1' and 'G13.1' do this
32- themselves. When the HAL pin is written instead, the G-code must force
33- synchronization, typically with a HAL pin 'read' command (M66 E0 L0)
34- immediately after altering the pin.
30+ of LinuxCNC to be *synchronized*, which 'G12.1' and 'G13.1' do
31+ themselves.
32+
33+ A deprecated HAL pin, 'motion.switchkins-type', selects a kinematics
34+ type as well. It is described under Usage below, because existing
35+ configurations use it.
3536
3637== Switchable Kinematic Modules
3738
@@ -161,7 +162,9 @@ meant to be removed in the future.
161162
162163=== G-code commands
163164
164- 'G12.1 P-' selects a kinstype and 'G13.1' cancels back to kinstype 0:
165+ 'G12.1 P-' selects a kinstype and 'G13.1' cancels back to identity
166+ kinematics. Which kinstype is identity is declared by the module (see
167+ Code Notes), not fixed to a number:
165168
166169[source,ngc]
167170----
@@ -170,16 +173,17 @@ G12.1 P1 ;select kinstype 1
170173...
171174... ;user G-code
172175...
173- G13.1 ;back to kinstype 0
176+ G13.1 ;back to identity kinematics
174177...
175178----
176179
177180These codes ask motion for the kinstype directly and synchronize task and
178181motion themselves, so no HAL connection and no separate sync command are
179182needed. The G-code words and the *motion.switchkins-type* pin are both
180183acted on when they change, so whichever asked most recently is the one in
181- force, and a config can use either or both. *motion.kins-type* reports
182- what is currently selected.
184+ force. *motion.kins-type* reports what is currently selected.
185+
186+ The pin is deprecated, see the warning under HAL Connections.
183187
184188The kinstype in force is readable in G-code as '#<_kins_type>', which lets
185189a subroutine restore whatever its caller had selected:
@@ -194,7 +198,11 @@ G12.1 P#<saved>
194198
195199Selection is not cancelled by the end of a program or by an abort, so
196200that the kinstype continues to match the position readout. A program
197- that should leave the machine in kinstype 0 ends with 'G13.1'.
201+ that should leave the machine in identity kinematics ends with 'G13.1'.
202+
203+ A module that declares no identity kinstype refuses 'G13.1' with an
204+ error and can still be driven by number with 'G12.1'; see Code Notes
205+ for how a module declares its types.
198206
199207See the G-code documentation for 'G12.1' and 'G13.1' for the full
200208description.
@@ -460,7 +468,7 @@ int switchkinsRegister(int ktype, KS kset, KF kfwd, KI kinv);
460468----
461469
462470'ktype' runs from 0 to SWITCHKINS_MAX_TYPES-1 (defined in
463- switchkins .h). A kinstype has to come from one route or the
471+ kinematics .h). A kinstype has to come from one route or the
464472other, so registering one that switchkinsSetup() has already
465473filled in is an error, and so is leaving a gap below the highest
466474kinstype provided. Either mistake fails the module load and says
@@ -469,6 +477,27 @@ which kinstype is at fault.
469477Each kinstype gets its own 'kinstype.is-N' pin, so a module
470478providing the usual three keeps the pin names it always had.
471479
480+ A module should also declare what each kinstype IS, again from within
481+ switchkinsSetup():
482+
483+ ----
484+ int switchkinsDeclare(int ktype, int flags);
485+ ----
486+
487+ with flags from kinematics.h:
488+
489+ . *KINSTYPE_IDENTITY* no transform: the joints are the world
490+ . *KINSTYPE_PRIMARY* the module's working transform
491+
492+ G-code reads these declarations: 'G13.1' cancels to the kinstype
493+ declared KINSTYPE_IDENTITY, whatever its number, so a module whose
494+ identity kinematics is not kinstype 0 still gets a working 'G13.1'.
495+ At most one kinstype may be declared identity, and declaring a
496+ kinstype the module does not provide fails the module load. A module
497+ that declares nothing keeps working exactly as before for 'G12.1 P-',
498+ but 'G13.1' is an error, since the number of the identity kinematics
499+ is then a guess.
500+
472501After calling switchkinsSetup(), rtapi_app_main() checks the
473502supplied parameters, creates a HAL component, and then invokes
474503the setup routine identified for each kinstype.
0 commit comments