Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ o210 else
o210 endif
g68.2 p1 j[90-#<b>] k#<c> ; plane Z is the sphere radius at b, c
g53.2 ; solve the orientation, stay put
g0 x0 y0 z[#<r>+#<rdelta>] b#<_orient_b> c#<_orient_c> ; one TCP turn and travel
g0 x0 y0 z[#<r>+#<rdelta>] b#<_orient_rot2> c#<_orient_rot1> ; one TCP turn and travel, C orients first
g1 z[#<r>+#<drilldepth>]
g0 z[#<r>+#<rdelta>]
#<cct> = [#<cct>+1]
Expand Down
26 changes: 18 additions & 8 deletions docs/src/gcode/g-code.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,10 @@ The H word, the offset itself and the parameters it lands in are
'G43''s. Which kinematics is the working one is declared by the module
(KINSTYPE_PRIMARY, see the <<cha:switchable-kinematics,Switchable
Kinematics>> chapter), the number is not the answer; a module that
declares none rejects 'G43.4' at read time.
declares none rejects 'G43.4' at read time. A module with one working
kinematics per tool head declares each one primary: 'G43.4' stays on the
one selected with 'G12.1' and, from any other kinematics, switches to the
lowest numbered.

The switch is a queue synchronisation point like
'<<gcode:g12.1-g13.1,G12.1>>': when 'G43.4' or 'G49' changes the
Expand Down Expand Up @@ -1927,8 +1930,10 @@ a rotary swings the long way round only where the short way runs out of travel.
rotary, the tool vertical on a mill, one joint no longer matters to the
direction and it stays where it is.

The pose the interpreter finds goes into the move as ordinary rotary
words, in program coordinates, so the rotary offsets of the coordinate
The pose the interpreter finds goes into the move as ordinary words of
the two axes the kinematics type orients the tool with, the ones
'#<_kins_orient_1>' and '#<_kins_orient_2>' name (A B C for a type that
orients with three angles, a robot's wrist), in program coordinates, so the rotary offsets of the coordinate
system apply, and the move interpolates like any other move with rotary
words: the rotaries turn together with the linear axes between the
poses of consecutive lines. The vector itself is not interpolated
Expand All @@ -1942,7 +1947,8 @@ offset and undoes the kinematics switch, as after 'G43.4'.

It is an error if:

* 'I J K' are given together with a rotary word on the same line,
* 'I J K' are given together with a word of an orienting axis on the same line,
* the kinematics type orients the tool with an axis that is not rotary,
* the vector is zero,
* the kinematics selected is the identity one, or the module supplies
no tool frame or cannot be evaluated by the interpreter,
Expand Down Expand Up @@ -2055,10 +2061,14 @@ differ in what happens then:
* 'G53.3' moves the rotaries and takes the tool to 'X Y Z', given in the
plane, in one point-to-point move. A word left out keeps the present value.
* 'G53.2' moves nothing. It only publishes the solved pose on the named
parameters '#<_orient_x>', '#<_orient_y>', '#<_orient_z>', '#<_orient_a>',
'#<_orient_b>' and '#<_orient_c>', and on the numbered parameters
'#5071' to '#5079' ('X Y Z A B C U V W'), in program units in the plane,
and sets '#<_orient_valid>' and '#5080' to 1. The program can then reach
parameters '#<_orient_x>', '#<_orient_y>', '#<_orient_z>',
'#<_orient_rot1>', '#<_orient_rot2>' and '#<_orient_rot3>', and on the
numbered parameters '#5071' to '#5076' in the same order, in program
units in the plane, and sets '#<_orient_valid>' and '#5080' to 1. The
rotaries come in the order the kinematics orients the tool with, the
axes '#<_kins_orient_1>' to '#<_kins_orient_3>' name, so a program reads
the angles the same way whatever letters the machine gives them;
'#<_orient_rot3>' is 0 on a machine that orients with two rotaries. The program can then reach
the pose with a move of its own making, for instance a single 'G0' that
names 'X Y Z' and the rotary words together, so the turn and the travel
are one Cartesian move under the TCP kinematics. This is what Heidenhain
Expand Down
37 changes: 30 additions & 7 deletions docs/src/gcode/overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@ example '##2' means the value of the parameter whose index is the
which the G38 took place. Volatile.
* '5070' - <<gcode:g38,G38>> probe result: 1 if success, 0 if probe
failed to close. Used with G38.3 and G38.5. Volatile.
* '5071-5079' - Pose last solved by <<gcode:g53.1,G53.2>> for X, Y, Z, A,
B, C, U, V & W, in program units in the tilted work plane. Same values
as `#<_orient_x>` and kin. Read-only, volatile.
* '5071-5076' - Pose last solved by <<gcode:g53.1,G53.2>> for X, Y, Z
and the first, second and third orienting rotary, in program units in
the tilted work plane. Same values as `#<_orient_x>` and kin. Read-only,
volatile.
* '5077-5079' - Written 0 by 'G53.2'. Read-only, volatile.
* '5080' - 'G53.2' result: 1 once a 'G53.2' has solved a pose, 0 before.
Same as `#<_orient_valid>`. Read-only, volatile.
* '5081-5089' - Tool length offset currently applied to motion for X, Y,
Expand Down Expand Up @@ -513,11 +515,32 @@ can be added easily without changes to the source code.
'P' number of the last 'G12.1', or 0 after 'G13.1' or when no kinematics
has been selected. See <<gcode:g12.1-g13.1,G12.1, G13.1>>.

* '#<_kins_orient_1>', '#<_kins_orient_2>', '#<_kins_orient_3>' - The
axes the kinematics type in force orients the tool with, as axis numbers,
0 for X to 8 for W: the first rotation, the one whose axis stays put, then
the second. A head and a table give the table first. The type's module
declares the letters, or they are those its joint map gives the joints
that turn. '#<_kins_orient_3>' is -1 on those. A type with three
rotaries, a table and a two axis head say, gives all three, the tables
first; a robot arm, whose joints all turn the tool, reads 3, 4 and 5, the
A B C of its pose. All three are -1 where the type orients otherwise, the identity
type among them, or the interpreter cannot evaluate the kinematics. An axis
named here must be 'ANGULAR' in the INI file; the interpreter refuses a
module whose type orients with a 'LINEAR' axis when it first loads it.

* '#<_kins_orient_1_head>', '#<_kins_orient_2_head>',
'#<_kins_orient_3_head>' - 1 where that axis turns the head, 0 where it
turns the table, -1 as above.

* '#<_orient_valid>', '#<_orient_x>', '#<_orient_y>', '#<_orient_z>',
'#<_orient_a>', '#<_orient_b>', '#<_orient_c>' - The pose 'G53.2' last
solved, in program units in the tilted work plane. '#<_orient_valid>' is
1 once a 'G53.2' has run; reading the others before that is an error. The
same values are on the numbered parameters '#5071' to '#5080'. See
'#<_orient_rot1>', '#<_orient_rot2>', '#<_orient_rot3>' - The pose 'G53.2'
last solved, in program units in the tilted work plane: X Y Z, then the
angles of the axes '#<_kins_orient_1>' to '#<_kins_orient_3>' name, in
that order, 0 for a third the machine does not have. This is how Fanuc
and Siemens number the rotaries of a five axis machine, first and second,
whatever their letters. '#<_orient_valid>' is 1 once a 'G53.2' has run;
reading the others before that is an error. The same values are on the
numbered parameters '#5071' to '#5076' and '#5080'. See
<<gcode:g53.1,G53.1, G53.2, G53.3, G53.6>>.

* '#<_plane>' - returns the value designating the current plane:
Expand Down
16 changes: 13 additions & 3 deletions docs/src/motion/kinematics-conventions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,22 @@ the optional work and tool frames with the native rotation that relates the
tool frame to the convention, and the optional Jacobian. A type whose forward
iterates from the pose it is handed says so, and the shared code seeds it with
the last answer after a switch. A type also says what it IS: `identity` marks
the no-transform type, joints are axes; `primary` the working transform
`G43.4` and `G43.5` switch to; `machine` the machine frame type `G13.1` and
the no-transform type, joints are axes; `primary` a working transform
`G43.4` and `G43.5` switch to, which a module with one per tool head sets
on each, `G12.1` choosing the head; `machine` the machine frame type `G13.1` and
`G49` cancel to and `G53.5` moves in, which a module leaves unset when its
identity type is that frame and sets on its working transform when that
reports the flange with no tool, as the robot modules do (see the Switchable
Kinematics chapter). A module with
Kinematics chapter). A type may also name the axis letters that orient
the tool, first rotation then second, in `orient`: "AC" for instance, or three
letters, tables first, for a type with three rotaries. Left out, they are the
letters the joint map gives the joints that turn the frames, which is right
for a module whose forward puts each joint in its own letter; a module that
writes an orienting joint into another letter declares them. A robot arm, all
of whose joints turn the tool, orients with the A B C of its pose. `G43.5`
writes its solution into these letters, the interpreter reads them back as
`#<_kins_orient_1>` to `#<_kins_orient_3>`, and `G53.2` publishes the angles
it solves in the same order as `#<_orient_rot1>` to `#<_orient_rot3>`. A module with
several types has one geometry table and one ops table per type, registered
with `switchkinsRegisterOps()`; a module with one type describes itself in a
`kins_module` and links `kins_single.c`.
Expand Down
10 changes: 7 additions & 3 deletions docs/src/motion/switchkins.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,11 @@ are not in the conventional order still gets working spellings. With
`MACHINE_MOVES_IN_MACHINE_FRAME` set in the `[RS274NGC]` section of the
INI file, 'G53', 'G28' and 'G30' move in the machine frame kinstype's
world too whenever another kinstype is in force; the five axis sims set
it. The
it. A
machine with two tool heads, a saw blade and a waterjet say, declares
one primary kinstype per head and selects the head with 'G12.1 P-':
'G43.4' stays on the kinstype in force when it is primary, and from any
other switches to the lowest numbered primary. The
machine frame kinstype is the machine with the tool left out, XYZ the
pivot or the flange in machine coordinates and the rotary letters the
orientation as that kinstype reports it; on a machine whose slides line
Expand All @@ -650,8 +654,8 @@ composite Y on a mill-turn, declares its machine frame kinstype
separately and keeps KINSTYPE_IDENTITY for a kinstype whose joints
really are the axes, since motion and the planner skip the maths on that
flag alone. At most one
kinstype may be declared identity, at most one primary and at most one
machine frame, and declaring a kinstype the module does not provide
kinstype may be declared identity and at most one machine frame, any
number primary, and declaring a kinstype the module does not provide
fails the module load. A module that declares nothing keeps working
exactly as before for 'G12.1 P-' and 'G49', but 'G13.1' and 'G43.4'
are an error, since the numbers of the identity and primary kinematics
Expand Down
17 changes: 17 additions & 0 deletions include/kinematics_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,23 @@ int kinematicsUserOrientJoints(KinematicsUserContext* ctx, const double* seed,
int kinematicsUserPoseJoint(KinematicsUserContext* ctx, const double* seed,
int* joint);

/**
* The axes that orient the tool on the active type, as axis numbers, 0 X
* to 8 W: the first rotation then the second, and whether each turns the
* head (1) or the table (0). Two heads or two tables are ordered as
* kinematicsUserOrientJoints() orders them, the one whose axis stays put
* first; a table and a head, the table first. The letters are the type's
* declared orient, else those the joint map gives the joints. Three
* rotaries come tables first, each group in joint order. A type whose
* tool is turned by more than three joints and no table, a robot arm,
* orients with the A B C of its pose, all three head. Returns how many
* axes, 2 or 3, the unused entries -1; or -1 with every entry -1 where the
* type turns other rotaries between tool and work, or a letter cannot be
* found.
*/
int kinematicsUserOrientAxes(KinematicsUserContext* ctx, const double* seed,
int axes[3], int head[3]);

/**
* kinematicsUserInitSparm() from the value of [KINS] KINEMATICS as the
* HAL file hands it to loadrt: the module name first, then any of
Expand Down
19 changes: 13 additions & 6 deletions include/kins_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,23 @@ typedef int (*kins_jacobian_fn)(const kins_params *p, const double *joint,
forward starts from the pose it is handed, so the shared code seeds it
with the last answer after a switch. identity says joints are axes, which
a consumer may use to skip the maths altogether. primary says this is
the module's working transform, the type G43.4 switches to. machine says
a working transform, the type G43.4 switches to; a module with one per
tool head flags each, G12.1 choosing the head. machine says
this is the machine frame type, the tool left out, the pivot or the flange
in machine coordinates, which G13.1 and G49 select and G53.5 moves in; a
module that leaves it unset on every type has its identity type stand in.
A machine frame type does not read the tool offset in the parameter block,
so a working transform that leaves the tool out anyway, a robot's flange,
carries primary and machine both. slides says the joints are the
machine's slides and rotaries, each in the letter the joint map gives
it, so that the carriage is the joints read through the map: the
machine frame of a module with one type, which has no machine frame
type to name. */
carries primary and machine both. orient names the axis letters that
orient the tool, first rotation then second, "AC" for instance, or three,
tables first, on a type with three rotaries; left
NULL they are the letters the joint map gives the joints that turn the
frames, which is right for a module whose forward puts each joint in its
own letter, and a module that puts one elsewhere declares them.
slides says the joints are the machine's slides and rotaries, each in
the letter the joint map gives it, so that the carriage is the joints
read through the map: the machine frame of a module with one type,
which has no machine frame type to name. */
typedef struct kins_ops {
kins_forward_fn forward;
kins_inverse_fn inverse;
Expand All @@ -362,6 +368,7 @@ typedef struct kins_ops {
int identity; /* joints are axes */
int primary; /* the working transform */
int machine; /* the machine frame */
const char *orient; /* orienting letters, NULL: from the joint map */
int slides; /* joints are the slides, letters by the map */
} kins_ops;

Expand Down
6 changes: 4 additions & 2 deletions lib/python/qtvcp/lib/mdi_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,10 @@ def gcode_descriptions(gcode):
G53.2 <P-> <Q->

Solves the same pose as G53.1 and moves nothing.
The pose is published on #<_orient_x> to
#<_orient_c> and on #5071 to #5079, in program
The pose is published on #<_orient_x> #<_orient_y>
#<_orient_z> and the rotaries in the order the
kinematics orients with, #<_orient_rot1> to
#<_orient_rot3>, and on #5071 to #5076, in program
units in the plane, with #<_orient_valid> (#5080)
set to 1, so the program can reach it with a move
of its own, for instance a single G0 naming X Y Z
Expand Down
76 changes: 61 additions & 15 deletions src/emc/kinematics/genserfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,65 @@ int compute_jinv(const genser_matrix * Jfwd, genser_matrix * Jinv)
return GENSER_OK;
}

/* What compute_jfwd() gives, straight from the DH frames in the base
frame: joint i moves along or turns about z_i, the axis of frame i
through its origin o_i, so the last frame's origin moves z_i or
z_i x (o_n - o_i) and turns 0 or z_i. The planner asks for many
Jacobians along each move, and this one skips the quaternions. */
static void genser_jfwd_frames(const genser_struct *genser, const double *jest,
genser_matrix *Jfwd)
{
double R[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
double o[3] = {0.0, 0.0, 0.0};
double z[GENSER_MAX_JOINTS][3], oi[GENSER_MAX_JOINTS][3];
const int n = genser->link_num;

for (int i = 0; i < n; i++) {
const genser_link *link = &genser->links[i];
const int prismatic = GENSER_QUANTITY_LENGTH == link->quantity;
const double th = prismatic ? link->dh.theta : jest[i];
const double d = prismatic ? jest[i] : link->dh.d;
const double sal = sin(link->dh.alpha), cal = cos(link->dh.alpha);
const double sth = sin(th), cth = cos(th);
// as link_pose_build(): Rx(alpha) Tx(a) Rz(theta) Tz(d)
const double L[3][3] = {{cth, -sth, 0.0},
{sth * cal, cth * cal, -sal},
{sth * sal, cth * sal, cal}};
const double t[3] = {link->dh.a, -sal * d, cal * d};
double N[3][3];

for (int r = 0; r < 3; r++) {
o[r] += R[r][0] * t[0] + R[r][1] * t[1] + R[r][2] * t[2];
}
for (int r = 0; r < 3; r++) {
for (int c = 0; c < 3; c++) {
N[r][c] = R[r][0] * L[0][c] + R[r][1] * L[1][c] + R[r][2] * L[2][c];
}
}
memcpy(R, N, sizeof(R));
for (int r = 0; r < 3; r++) {
z[i][r] = R[r][2];
oi[i][r] = o[r];
}
}
for (int i = 0; i < n; i++) {
const double v[3] = {o[0] - oi[i][0], o[1] - oi[i][1], o[2] - oi[i][2]};
if (GENSER_QUANTITY_LENGTH == genser->links[i].quantity) {
for (int r = 0; r < 3; r++) {
Jfwd->el[r][i] = z[i][r];
Jfwd->el[3 + r][i] = 0.0;
}
continue;
}
Jfwd->el[0][i] = z[i][1] * v[2] - z[i][2] * v[1];
Jfwd->el[1][i] = z[i][2] * v[0] - z[i][0] * v[2];
Jfwd->el[2][i] = z[i][0] * v[1] - z[i][1] * v[0];
for (int r = 0; r < 3; r++) {
Jfwd->el[3 + r][i] = z[i][r];
}
}
}

/* The Jacobian in the terms of kinematics.h: joints in degrees per pose
word in EmcPose units, the derivative of genser_inverse().

Expand All @@ -529,8 +588,6 @@ static int genser_jacobian(const kins_params *p, const double *joint,
genser_struct genser_stg;
genser_struct *genser = &genser_stg;
genser_matrix Jfwd, Jinv;
PmPose T_L_0;
genser_link linkout[GENSER_MAX_JOINTS] = {};
double jest[GENSER_MAX_JOINTS];
double E[3][3];
double sb, cb, sc, cc;
Expand All @@ -552,12 +609,7 @@ static int genser_jacobian(const kins_params *p, const double *joint,
matrix_init(&Jfwd, 6, genser->link_num);
matrix_init(&Jinv, genser->link_num, 6);

for (link = 0; link < genser->link_num; link++) {
link_joint_set(&genser->links[link], jest[link], &linkout[link]);
}
retval = compute_jfwd(linkout, genser->link_num, &Jfwd, &T_L_0);
if (GENSER_OK != retval)
return -1;
genser_jfwd_frames(genser, jest, &Jfwd);
retval = compute_jinv(&Jfwd, &Jinv);
if (GENSER_OK != retval)
return -1; // singular: no finite joint rate follows the pose
Expand Down Expand Up @@ -691,7 +743,6 @@ static int genser_inverse(const kins_params *p, kins_scratch *s,
genser_struct genser_stg;
genser_struct *genser = &genser_stg;
genser_matrix Jfwd, Jinv;
PmPose T_L_0;
double dvw[6];
double jest[GENSER_MAX_JOINTS];
double dj[GENSER_MAX_JOINTS];
Expand Down Expand Up @@ -736,12 +787,7 @@ static int genser_inverse(const kins_params *p, kins_scratch *s,
for (link = 0; link < genser->link_num; link++) {
link_joint_set(&genser->links[link], jest[link], &linkout[link]);
}
retval = compute_jfwd(linkout, genser->link_num, &Jfwd, &T_L_0);
if (GENSER_OK != retval) {
rtapi_print("ERR kI - compute_jfwd (joints: %f %f %f %f %f %f), (iterations=%d)\n",
joints[0],joints[1],joints[2],joints[3],joints[4],joints[5], genser->iterations);
return retval;
}
genser_jfwd_frames(genser, jest, &Jfwd);
retval = compute_jinv(&Jfwd, &Jinv);
if (GENSER_OK != retval) {
rtapi_print("ERR kI - compute_jinv (joints: %f %f %f %f %f %f), (iterations=%d)\n",
Expand Down
Loading
Loading