Skip to content

Commit fda11fe

Browse files
committed
docs: G12.1 and G13.1 select the kinematics from G-code
The G-code reference gains G12.1 and G13.1, the switchkins chapter describes the type declaration (switchkinsDeclare with KINSTYPE_IDENTITY and KINSTYPE_PRIMARY, G13.1 resolving identity from it) and leads with the deprecation notice for motion.switchkins-type instead of offering the pin as an equal way to switch. The motion man page follows.
1 parent 6d962a4 commit fda11fe

2 files changed

Lines changed: 67 additions & 26 deletions

File tree

‎docs/src/gcode/g-code.adoc‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -944,21 +944,31 @@ G13.1
944944
----
945945

946946
'G12.1' selects one of the kinematics provided by a switchable kinematics
947-
module, and 'G13.1' cancels back to kinematics 0. The 'P' word is the
948-
kinematics number, the same number that the `motion.switchkins-type` pin
949-
takes, so 'G13.1' and `G12.1 P0` do the same thing. A config may select
950-
the kinematics from G-code, from that pin, or from both: each is acted on
951-
when it changes, so the most recent request is the one in force.
947+
module; the 'P' word is the kinematics number. 'G13.1' cancels back to
948+
identity kinematics, where joints and coordinates are the same thing.
949+
Which number that is is declared by the module itself, so 'G13.1' means
950+
the same kinematics whatever order a module lists its types in.
951+
952+
[WARNING]
953+
Deprecation notice: selecting the kinematics by writing the
954+
`motion.switchkins-type` HAL pin is deprecated. It takes the same
955+
numbering and still works, but it does not tell the interpreter that
956+
anything changed, so a program is read, its limits checked and its path
957+
looked ahead in whatever kinematics the interpreter last knew about,
958+
which need not be the one that runs it. Use 'G12.1' and 'G13.1'.
952959

953960
Both codes are queue synchronisation points. The interpreter waits for
954961
queued motion to finish before the kinematics changes, so no move is ever
955962
planned in one kinematics and executed in another. Because of that, both
956963
codes stop any blending that was in progress, in the same way 'G4' does.
957964

958-
The kinematics module decides what each number means. See the
959-
`switchkins` section of the kins(9) man page for the modules that support
960-
switching and the order in which they list their kinematics. A machine
961-
whose kinematics module is not switchable rejects the change.
965+
The kinematics module decides what each number means, and declares
966+
which one is identity. See the `switchkins` section of the kins(9) man
967+
page for the modules that support switching and the order in which they
968+
list their kinematics. A machine whose kinematics module is not
969+
switchable rejects the change, and 'G13.1' is an error on a switchable
970+
module that declares no identity kinematics; such a module can still be
971+
driven by number with 'G12.1'.
962972

963973
Selecting a kinematics does not move the machine. It changes how joint
964974
positions and coordinate positions map onto each other, so the position
@@ -979,21 +989,23 @@ G12.1 P#<saved> (put back whatever the caller was using)
979989
Nothing cancels the selection on its own. It survives the end of the
980990
program and an abort, so that the kinematics keeps matching what the
981991
position readout shows. End a program with 'G13.1' if it should leave the
982-
machine in kinematics 0.
992+
machine in identity kinematics.
983993

984994
.G12.1, G13.1 Example
985995
[source,ngc]
986996
----
987997
G12.1 P1 (switch to kinematics 1)
988998
G0 X0 Y0
989-
G13.1 (back to kinematics 0)
999+
G13.1 (back to identity kinematics)
9901000
----
9911001

9921002
It is an error if:
9931003

9941004
* 'G12.1' is used without a 'P' word.
9951005
* The 'P' word is negative.
1006+
* The 'P' word names a kinematics the module does not provide.
9961007
* A 'P' word is used with 'G13.1'.
1008+
* 'G13.1' is used and the module declares no identity kinematics.
9971009

9981010
[[gcode:g17-g19.1]]
9991011
== G17 - G19.1 Plane Select(((G17 - G19.1 Plane Select)))

‎docs/src/motion/switchkins.adoc‎

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ switched to identity kinematics for control of individual joints
2121
after homing.
2222

2323
The 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

3029
Changing 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

177180
These codes ask motion for the kinstype directly and synchronize task and
178181
motion themselves, so no HAL connection and no separate sync command are
179182
needed. The G-code words and the *motion.switchkins-type* pin are both
180183
acted 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

184188
The kinstype in force is readable in G-code as '#<_kins_type>', which lets
185189
a subroutine restore whatever its caller had selected:
@@ -194,7 +198,11 @@ G12.1 P#<saved>
194198

195199
Selection is not cancelled by the end of a program or by an abort, so
196200
that 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

199207
See the G-code documentation for 'G12.1' and 'G13.1' for the full
200208
description.
@@ -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
464472
other, so registering one that switchkinsSetup() has already
465473
filled in is an error, and so is leaving a gap below the highest
466474
kinstype provided. Either mistake fails the module load and says
@@ -469,6 +477,27 @@ which kinstype is at fault.
469477
Each kinstype gets its own 'kinstype.is-N' pin, so a module
470478
providing 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+
472501
After calling switchkinsSetup(), rtapi_app_main() checks the
473502
supplied parameters, creates a HAL component, and then invokes
474503
the setup routine identified for each kinstype.

0 commit comments

Comments
 (0)