Skip to content

Commit af74175

Browse files
committed
kinematics: offer identityfirst in the remaining switchkins modules
xyzac-trt-kins, xyzbc-trt-kins and 5axiskins accept the module string parameter sparm=identityfirst, which makes switchkins-type 0 identity kinematics and switchkins-type 1 the module's own. genserkins, pumakins, scarakins, three21kins and genhexkins did not, so those machines always start in the kinematics that can fail. A failing model kinematics is exactly where a machine needs identity kinematics: motion reports the error and disables the machine, and the operator needs a mode that solves at the current pose to move clear. motion.switchkins-type rests at zero and the shipped configs drive it from motion.analog-out-03, which is also zero until an M68 runs, so type 0 is both the type a machine starts in and the type it falls back to.
1 parent 27d256a commit af74175

6 files changed

Lines changed: 119 additions & 46 deletions

File tree

docs/src/motion/switchkins.adoc

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ The following kinematics modules support switchable kinematics:
4545
. *scarakins* (type0:scarakins type1:identity)
4646
. *5axiskins* (type0:5axiskins type1:identity) (bridgemill)
4747

48-
The xyz[ab]c-trt-kins modules by default use type0==xyz[ab]c-trt-kins
49-
for backwards compatibility. The provided sim configs alter the
50-
type0/type1 convention by forcing type0==identity kinematics using the
51-
module string parameter 'sparm' with an INI file setting like:
48+
Every module listed above uses its own kinematics for type0 and
49+
identity kinematics for type1. Each accepts the module string
50+
parameter 'sparm' to swap the two, so that the machine starts in
51+
identity kinematics and the module kinematics are selected on demand:
5252

5353
[source,ini]
5454
----
@@ -57,6 +57,20 @@ KINEMATICS = xyzac-trt-kins sparm=identityfirst
5757
# ...
5858
----
5959

60+
Starting in identity kinematics leaves a way out of poses the module
61+
kinematics cannot solve. A module kinematics failure (near a
62+
singularity, for instance) reports an error and disables the machine;
63+
type0 is then reached without running the failing kinematics again.
64+
65+
[NOTE]
66+
The 'sparm' setting exchanges type0 and type1, so any G-code or HAL
67+
logic that selects a kinematics type by number must match.
68+
69+
Kinematics that solve the forward direction iteratively, genhexkins
70+
among them, need a pose to start from. While another type is running
71+
they take the estimate the caller supplies, which motion seeds from
72+
the '[TRAJ]HOME' world home, so they are ready to be switched to.
73+
6074
=== Identity letter assignments
6175

6276
When using an *identity* kinematics type, the module parameter

src/emc/kinematics/genhexkins.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -693,18 +693,31 @@ int switchkinsSetup(kparms* kp,
693693
kp->required_coordinates = "xyzabc";
694694
kp->max_joints = strlen(kp->required_coordinates);
695695
kp->allow_duplicates = 0;
696-
kp->fwd_iterates_mask = 0x1; //genhexkins switchkins_type==0
697-
kp->gui_kinstype = 0; //vismach gui for switchkins_type==0
698-
699-
// switchkins_type==0 is startup default
700-
// kins with iterative forward algorithm should be switchkins_type==0
701-
*kset0 = genhexKinematicsSetup;
702-
*kfwd0 = genhexKinematicsForward;
703-
*kinv0 = genhexKinematicsInverse;
704-
705-
*kset1 = identityKinematicsSetup;
706-
*kfwd1 = identityKinematicsForward;
707-
*kinv1 = identityKinematicsInverse;
696+
if (kp->sparm && strstr(kp->sparm,"identityfirst")) {
697+
rtapi_print("\n!!! switchkins-type 0 is IDENTITY\n");
698+
kp->fwd_iterates_mask = 0x2; //genhexkins switchkins_type==1
699+
kp->gui_kinstype = 1; //vismach gui for switchkins_type==1
700+
701+
*kset0 = identityKinematicsSetup;
702+
*kfwd0 = identityKinematicsForward;
703+
*kinv0 = identityKinematicsInverse;
704+
705+
*kset1 = genhexKinematicsSetup;
706+
*kfwd1 = genhexKinematicsForward;
707+
*kinv1 = genhexKinematicsInverse;
708+
} else {
709+
rtapi_print("\n!!! switchkins-type 0 is %s\n",kp->kinsname);
710+
kp->fwd_iterates_mask = 0x1; //genhexkins switchkins_type==0
711+
kp->gui_kinstype = 0; //vismach gui for switchkins_type==0
712+
713+
*kset0 = genhexKinematicsSetup;
714+
*kfwd0 = genhexKinematicsForward;
715+
*kinv0 = genhexKinematicsInverse;
716+
717+
*kset1 = identityKinematicsSetup;
718+
*kfwd1 = identityKinematicsForward;
719+
*kinv1 = identityKinematicsInverse;
720+
}
708721

709722
*kset2 = userkKinematicsSetup;
710723
*kfwd2 = userkKinematicsForward;

src/emc/kinematics/genserkins.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,25 @@ int switchkinsSetup(kparms* kp,
6363
kp->max_joints = strlen(kp->required_coordinates);
6464
kp->allow_duplicates = 0;
6565

66-
*kset0 = genserKinematicsSetup;
67-
*kfwd0 = genserKinematicsForward;
68-
*kinv0 = genserKinematicsInverse;
69-
70-
*kset1 = identityKinematicsSetup;
71-
*kfwd1 = identityKinematicsForward;
72-
*kinv1 = identityKinematicsInverse;
66+
if (kp->sparm && strstr(kp->sparm,"identityfirst")) {
67+
rtapi_print("\n!!! switchkins-type 0 is IDENTITY\n");
68+
*kset0 = identityKinematicsSetup;
69+
*kfwd0 = identityKinematicsForward;
70+
*kinv0 = identityKinematicsInverse;
71+
72+
*kset1 = genserKinematicsSetup;
73+
*kfwd1 = genserKinematicsForward;
74+
*kinv1 = genserKinematicsInverse;
75+
} else {
76+
rtapi_print("\n!!! switchkins-type 0 is %s\n",kp->kinsname);
77+
*kset0 = genserKinematicsSetup;
78+
*kfwd0 = genserKinematicsForward;
79+
*kinv0 = genserKinematicsInverse;
80+
81+
*kset1 = identityKinematicsSetup;
82+
*kfwd1 = identityKinematicsForward;
83+
*kinv1 = identityKinematicsInverse;
84+
}
7385

7486
*kset2 = userkKinematicsSetup;
7587
*kfwd2 = userkKinematicsForward;

src/emc/kinematics/pumakins.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,25 @@ int switchkinsSetup(kparms* kp,
367367
kp->allow_duplicates = 0;
368368
kp->max_joints = strlen(kp->required_coordinates);
369369

370-
rtapi_print("\n!!! switchkins-type 0 is %s\n",kp->kinsname);
371-
*kset0 = pumaKinematicsSetup;
372-
*kfwd0 = pumaKinematicsForward;
373-
*kinv0 = pumaKinematicsInverse;
374-
375-
*kset1 = identityKinematicsSetup;
376-
*kfwd1 = identityKinematicsForward;
377-
*kinv1 = identityKinematicsInverse;
370+
if (kp->sparm && strstr(kp->sparm,"identityfirst")) {
371+
rtapi_print("\n!!! switchkins-type 0 is IDENTITY\n");
372+
*kset0 = identityKinematicsSetup;
373+
*kfwd0 = identityKinematicsForward;
374+
*kinv0 = identityKinematicsInverse;
375+
376+
*kset1 = pumaKinematicsSetup;
377+
*kfwd1 = pumaKinematicsForward;
378+
*kinv1 = pumaKinematicsInverse;
379+
} else {
380+
rtapi_print("\n!!! switchkins-type 0 is %s\n",kp->kinsname);
381+
*kset0 = pumaKinematicsSetup;
382+
*kfwd0 = pumaKinematicsForward;
383+
*kinv0 = pumaKinematicsInverse;
384+
385+
*kset1 = identityKinematicsSetup;
386+
*kfwd1 = identityKinematicsForward;
387+
*kinv1 = identityKinematicsInverse;
388+
}
378389

379390
*kset2 = userkKinematicsSetup;
380391
*kfwd2 = userkKinematicsForward;

src/emc/kinematics/scarakins.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,25 @@ int switchkinsSetup(kparms* kp,
221221
kp->allow_duplicates = 0;
222222
kp->max_joints = strlen(kp->required_coordinates);
223223

224-
rtapi_print("\n!!! switchkins-type 0 is %s\n",kp->kinsname);
225-
*kset0 = scaraKinematicsSetup;
226-
*kfwd0 = scaraKinematicsForward;
227-
*kinv0 = scaraKinematicsInverse;
228-
229-
*kset1 = identityKinematicsSetup;
230-
*kfwd1 = identityKinematicsForward;
231-
*kinv1 = identityKinematicsInverse;
224+
if (kp->sparm && strstr(kp->sparm,"identityfirst")) {
225+
rtapi_print("\n!!! switchkins-type 0 is IDENTITY\n");
226+
*kset0 = identityKinematicsSetup;
227+
*kfwd0 = identityKinematicsForward;
228+
*kinv0 = identityKinematicsInverse;
229+
230+
*kset1 = scaraKinematicsSetup;
231+
*kfwd1 = scaraKinematicsForward;
232+
*kinv1 = scaraKinematicsInverse;
233+
} else {
234+
rtapi_print("\n!!! switchkins-type 0 is %s\n",kp->kinsname);
235+
*kset0 = scaraKinematicsSetup;
236+
*kfwd0 = scaraKinematicsForward;
237+
*kinv0 = scaraKinematicsInverse;
238+
239+
*kset1 = identityKinematicsSetup;
240+
*kfwd1 = identityKinematicsForward;
241+
*kinv1 = identityKinematicsInverse;
242+
}
232243

233244
*kset2 = userkKinematicsSetup;
234245
*kfwd2 = userkKinematicsForward;

src/emc/kinematics/three21kins.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,25 @@ int switchkinsSetup(kparms* kp,
377377
kp->allow_duplicates = 0;
378378
kp->max_joints = strlen(kp->required_coordinates);
379379

380-
*kset0 = three21KinematicsSetup;
381-
*kfwd0 = three21KinematicsForward;
382-
*kinv0 = three21KinematicsInverse;
383-
384-
*kset1 = identityKinematicsSetup;
385-
*kfwd1 = identityKinematicsForward;
386-
*kinv1 = identityKinematicsInverse;
380+
if (kp->sparm && strstr(kp->sparm,"identityfirst")) {
381+
rtapi_print("\n!!! switchkins-type 0 is IDENTITY\n");
382+
*kset0 = identityKinematicsSetup;
383+
*kfwd0 = identityKinematicsForward;
384+
*kinv0 = identityKinematicsInverse;
385+
386+
*kset1 = three21KinematicsSetup;
387+
*kfwd1 = three21KinematicsForward;
388+
*kinv1 = three21KinematicsInverse;
389+
} else {
390+
rtapi_print("\n!!! switchkins-type 0 is %s\n",kp->kinsname);
391+
*kset0 = three21KinematicsSetup;
392+
*kfwd0 = three21KinematicsForward;
393+
*kinv0 = three21KinematicsInverse;
394+
395+
*kset1 = identityKinematicsSetup;
396+
*kfwd1 = identityKinematicsForward;
397+
*kinv1 = identityKinematicsInverse;
398+
}
387399

388400
*kset2 = userkKinematicsSetup;
389401
*kfwd2 = userkKinematicsForward;

0 commit comments

Comments
 (0)