diff --git a/docs/src/getting-started/updating-linuxcnc.adoc b/docs/src/getting-started/updating-linuxcnc.adoc index 459d35a151f..26a8404a173 100644 --- a/docs/src/getting-started/updating-linuxcnc.adoc +++ b/docs/src/getting-started/updating-linuxcnc.adoc @@ -356,6 +356,18 @@ quantity. Otherwise, any negative values would become very large numbers. Any configuration using it needs to update the HAL type. +genhexkins: the joint axes *genhexkins.base-n._N_.x/y/z* and +*genhexkins.platform-n._N_.x/y/z* now default to 0. They are used only +with *genhexkins.screw-lead* set, and a strut with an axis left at 0 gets +no length correction; genhexkins says so once. A configuration with a +screw lead that relied on the old defaults can set them back: + +* *base-n*: struts 0 and 5 (0.707107, 0, 0.707107), strut 1 + (0, -0.707107, 0.707107), struts 2 and 3 (-0.707107, 0, 0.707107), + strut 4 (0, 0.707107, 0.707107) +* *platform-n*: struts 0 and 5 (-1, 0, 0), struts 1 and 2 + (0.866025, 0.5, 0), struts 3 and 4 (0.866025, -0.5, 0) + == Preview renderer now requires OpenGL 3.3 core The G-code preview shared by AXIS, the GTK screens (Gremlin / gmoccapy / diff --git a/docs/src/man/man9/kins.9.adoc b/docs/src/man/man9/kins.9.adoc index 4b48ec336a7..e3f940ab3c2 100644 --- a/docs/src/man/man9/kins.9.adoc +++ b/docs/src/man/man9/kins.9.adoc @@ -180,11 +180,17 @@ documentation for more info) **genhexkins.platform-n.**_N_**.z**:: Parameters describing unit vectors of __N__th joint's axis. Used to calculate strut length correction for cardanic joints and non-captive - actuators. + actuators. Default 0: with a screw lead, set both axes of every strut. A + strut with an axis left at 0 gets no correction, and genhexkins says so + once. **genhexkins.screw-lead**:: Lead of strut actuator screw, positive for the right-handed thread. - Default is 0 (strut length correction disabled). + Default is 0 (strut length correction disabled). The correction is the + lead times the twist of a strut's platform joint axis from its base joint + axis, about the strut, in turns. It holds while each strut's twist stays + within a quarter turn; past that it folds back, and runs against the + twist. **genhexkins.correction.**_N_:: Current values of strut length correction for non-captive actuators diff --git a/src/emc/kinematics/genhexkins.c b/src/emc/kinematics/genhexkins.c index d8036dcaed3..9d90f6a8c4c 100644 --- a/src/emc/kinematics/genhexkins.c +++ b/src/emc/kinematics/genhexkins.c @@ -63,7 +63,10 @@ in platform CS. genhexkins.screw-lead - lead of strut actuator screw, positive for right-hand thread. Default is 0 (strut length - correction disabled). + correction disabled). The correction holds + while each strut's twist stays within a quarter + turn. The axes default to 0: with a lead, set + both of each strut's, or it gets no correction. genhexkins.correction.N - pins showing current values of strut length correction. @@ -211,6 +214,7 @@ static const kins_param_desc genhex_params[P_COUNT] = { // the most iterations a converged solution has taken this session, kept // in the caller's scratch so each caller reports its own #define MAX_ITER_SEEN(s) ((s)->aux[0]) +#define AXES_WARNED(s) ((s)->aux[1]) /******************************* MatInvert() ***************************/ @@ -348,6 +352,26 @@ static void geometry_of(const kins_params *p, genhex_geometry *g) { g->screw_lead = p->geometry[P_SCREW_LEAD]; } // geometry_of() +/* A strut with a joint axis left at 0 gets no correction; with a lead set, + say so once per caller. */ +static void warn_unset_axes(const genhex_geometry *g, kins_scratch *s) +{ + int i; + + if (g->screw_lead == 0.0 || AXES_WARNED(s)) { return; } + for (i = 0; i < NUM_STRUTS; i++) { + if ((g->nb1[i].x == 0.0 && g->nb1[i].y == 0.0 && g->nb1[i].z == 0.0) || + (g->na0[i].x == 0.0 && g->na0[i].y == 0.0 && g->na0[i].z == 0.0)) { + rtapi_print_msg(RTAPI_MSG_ERR, + "genhexkins: screw-lead is set, but strut %d has a joint axis at 0, " + "so its length is not corrected; set genhexkins.base-n.%d and " + "genhexkins.platform-n.%d\n", i, i, i); + AXES_WARNED(s) = 1; + return; + } + } +} + /* Strut i's joint axes across the strut u: nb2 = nb1 x u at the base, and na2 = na1 x u at the platform, with na1 = R na0. The twist of na2 from nb2 about u has s as its sine and c as its cosine, times both lengths. */ @@ -457,6 +481,7 @@ static int genhex_forward(const kins_params *p, kins_scratch *s, unsigned iteration = 0; geometry_of(p, &g); + warn_unset_axes(&g, s); /* abort on obvious problems, like joints <= 0 */ /* FIXME-- should check against triangle inequality, so that joints @@ -651,6 +676,7 @@ static int genhex_inverse(const kins_params *p, kins_scratch *s, double InvKinStrutLength, corr; geometry_of(p, &g); + warn_unset_axes(&g, s); /* define Rotation Matrix */ rpy.r = pos->a * PM_PI / 180.0; diff --git a/src/emc/kinematics/genhexkins.h b/src/emc/kinematics/genhexkins.h index 60b48f7ec54..10ae6d8618e 100644 --- a/src/emc/kinematics/genhexkins.h +++ b/src/emc/kinematics/genhexkins.h @@ -72,55 +72,56 @@ #define DEFAULT_PLATFORM_4_Z 0.000 #define DEFAULT_PLATFORM_5_Z 0.000 -/* Default unit vectors of base joints axes in world coordinates */ +/* Default unit vectors of base joints axes in world coordinates: none, so a + screw lead needs them set */ -#define DEFAULT_BASE_0_NX 0.707107 +#define DEFAULT_BASE_0_NX 0.0 #define DEFAULT_BASE_0_NY 0.0 -#define DEFAULT_BASE_0_NZ 0.707107 +#define DEFAULT_BASE_0_NZ 0.0 #define DEFAULT_BASE_1_NX 0.0 -#define DEFAULT_BASE_1_NY -0.707107 -#define DEFAULT_BASE_1_NZ 0.707107 +#define DEFAULT_BASE_1_NY 0.0 +#define DEFAULT_BASE_1_NZ 0.0 -#define DEFAULT_BASE_2_NX -0.707107 +#define DEFAULT_BASE_2_NX 0.0 #define DEFAULT_BASE_2_NY 0.0 -#define DEFAULT_BASE_2_NZ 0.707107 +#define DEFAULT_BASE_2_NZ 0.0 -#define DEFAULT_BASE_3_NX -0.707107 +#define DEFAULT_BASE_3_NX 0.0 #define DEFAULT_BASE_3_NY 0.0 -#define DEFAULT_BASE_3_NZ 0.707107 +#define DEFAULT_BASE_3_NZ 0.0 #define DEFAULT_BASE_4_NX 0.0 -#define DEFAULT_BASE_4_NY 0.707107 -#define DEFAULT_BASE_4_NZ 0.707107 +#define DEFAULT_BASE_4_NY 0.0 +#define DEFAULT_BASE_4_NZ 0.0 -#define DEFAULT_BASE_5_NX 0.707107 +#define DEFAULT_BASE_5_NX 0.0 #define DEFAULT_BASE_5_NY 0.0 -#define DEFAULT_BASE_5_NZ 0.707107 +#define DEFAULT_BASE_5_NZ 0.0 -/* Default unit vectors of platform joints axes in platform coordinates */ +/* Default unit vectors of platform joints axes in platform coordinates: none */ -#define DEFAULT_PLATFORM_0_NX -1.0 +#define DEFAULT_PLATFORM_0_NX 0.0 #define DEFAULT_PLATFORM_0_NY 0.0 #define DEFAULT_PLATFORM_0_NZ 0.0 -#define DEFAULT_PLATFORM_1_NX 0.866025 -#define DEFAULT_PLATFORM_1_NY 0.5 +#define DEFAULT_PLATFORM_1_NX 0.0 +#define DEFAULT_PLATFORM_1_NY 0.0 #define DEFAULT_PLATFORM_1_NZ 0.0 -#define DEFAULT_PLATFORM_2_NX 0.866025 -#define DEFAULT_PLATFORM_2_NY 0.5 +#define DEFAULT_PLATFORM_2_NX 0.0 +#define DEFAULT_PLATFORM_2_NY 0.0 #define DEFAULT_PLATFORM_2_NZ 0.0 -#define DEFAULT_PLATFORM_3_NX 0.866025 -#define DEFAULT_PLATFORM_3_NY -0.5 +#define DEFAULT_PLATFORM_3_NX 0.0 +#define DEFAULT_PLATFORM_3_NY 0.0 #define DEFAULT_PLATFORM_3_NZ 0.0 -#define DEFAULT_PLATFORM_4_NX 0.866025 -#define DEFAULT_PLATFORM_4_NY -0.5 +#define DEFAULT_PLATFORM_4_NX 0.0 +#define DEFAULT_PLATFORM_4_NY 0.0 #define DEFAULT_PLATFORM_4_NZ 0.0 -#define DEFAULT_PLATFORM_5_NX -1.0 +#define DEFAULT_PLATFORM_5_NX 0.0 #define DEFAULT_PLATFORM_5_NY 0.0 #define DEFAULT_PLATFORM_5_NZ 0.0 diff --git a/tests/genhexkins-forward/checkresult b/tests/genhexkins-forward/checkresult index 77c052983b8..1299676b3a6 100755 --- a/tests/genhexkins-forward/checkresult +++ b/tests/genhexkins-forward/checkresult @@ -1,9 +1,13 @@ #!/bin/sh -# both runs converged, with no screw lead and with one, and in each the -# forward that set last-iterations took more than one; and the -# correction folds at a quarter turn (unfolded it is 1.885) -[ "$(grep -c "converged within the limit" "$1")" = 2 ] && ! grep -q "FAIL" "$1" && +# all three runs converged: no screw lead, a lead with axes, a lead without; +# in the first two the forward that set last-iterations took more than one, +# and the correction folds at a quarter turn (unfolded it is 1.885); without +# axes all six corrections are 0, and genhexkins said so once +[ "$(grep -c "converged within the limit" "$1")" = 3 ] && ! grep -q "FAIL" "$1" && [ "$(awk '$NF == "genhexkins.last-iterations" { print $4 }' "$1" | grep -cvxE '(0x)?0*[01]')" = 2 ] && - awk '$NF == "genhexkins.correction.5" { ok = $4 > 0.61473 && $4 < 0.61475 } - END { exit !ok }' "$1" + [ "$(grep -c "genhexkins: screw-lead is set" "$1")" = 1 ] && + awk '/^=== lead, no axes/ { noaxes = 1; next } + !noaxes && $NF == "genhexkins.correction.5" { fold = $4 > 0.61473 && $4 < 0.61475 } + noaxes && $NF ~ /^genhexkins\.correction\.[0-5]$/ { n++; if ($4 + 0 != 0) bad = 1 } + END { exit !(fold && n == 6 && !bad) }' "$1" diff --git a/tests/genhexkins-forward/hexfwdcheck-noaxes.hal b/tests/genhexkins-forward/hexfwdcheck-noaxes.hal new file mode 100644 index 00000000000..1770bb79515 --- /dev/null +++ b/tests/genhexkins-forward/hexfwdcheck-noaxes.hal @@ -0,0 +1,6 @@ +loadrt genhexkins +# a screw lead with the joint axes left at 0: no correction, and said once +setp genhexkins.screw-lead 5 +setp genhexkins.limit-iterations 8 +loadrt hexfwdcheck +show pin genhexkins.correction diff --git a/tests/genhexkins-forward/hexfwdcheck-screw.hal b/tests/genhexkins-forward/hexfwdcheck-screw.hal index bb23287d0fd..482c9d26774 100644 --- a/tests/genhexkins-forward/hexfwdcheck-screw.hal +++ b/tests/genhexkins-forward/hexfwdcheck-screw.hal @@ -1,6 +1,43 @@ loadrt genhexkins # the same with a screw lead setp genhexkins.screw-lead 5 +# axes with four struts past a quarter turn at home, where the correction folds back +setp genhexkins.base-n.0.x 0.707107 +setp genhexkins.base-n.0.y 0.0 +setp genhexkins.base-n.0.z 0.707107 +setp genhexkins.base-n.1.x 0.0 +setp genhexkins.base-n.1.y -0.707107 +setp genhexkins.base-n.1.z 0.707107 +setp genhexkins.base-n.2.x -0.707107 +setp genhexkins.base-n.2.y 0.0 +setp genhexkins.base-n.2.z 0.707107 +setp genhexkins.base-n.3.x -0.707107 +setp genhexkins.base-n.3.y 0.0 +setp genhexkins.base-n.3.z 0.707107 +setp genhexkins.base-n.4.x 0.0 +setp genhexkins.base-n.4.y 0.707107 +setp genhexkins.base-n.4.z 0.707107 +setp genhexkins.base-n.5.x 0.707107 +setp genhexkins.base-n.5.y 0.0 +setp genhexkins.base-n.5.z 0.707107 +setp genhexkins.platform-n.0.x -1.0 +setp genhexkins.platform-n.0.y 0.0 +setp genhexkins.platform-n.0.z 0.0 +setp genhexkins.platform-n.1.x 0.866025 +setp genhexkins.platform-n.1.y 0.5 +setp genhexkins.platform-n.1.z 0.0 +setp genhexkins.platform-n.2.x 0.866025 +setp genhexkins.platform-n.2.y 0.5 +setp genhexkins.platform-n.2.z 0.0 +setp genhexkins.platform-n.3.x 0.866025 +setp genhexkins.platform-n.3.y -0.5 +setp genhexkins.platform-n.3.z 0.0 +setp genhexkins.platform-n.4.x 0.866025 +setp genhexkins.platform-n.4.y -0.5 +setp genhexkins.platform-n.4.z 0.0 +setp genhexkins.platform-n.5.x -1.0 +setp genhexkins.platform-n.5.y 0.0 +setp genhexkins.platform-n.5.z 0.0 setp genhexkins.limit-iterations 8 loadrt hexfwdcheck show pin genhexkins.last-iterations diff --git a/tests/genhexkins-forward/hexfwdcheck.c b/tests/genhexkins-forward/hexfwdcheck.c index 65a3dca21ac..8083c5368cd 100644 --- a/tests/genhexkins-forward/hexfwdcheck.c +++ b/tests/genhexkins-forward/hexfwdcheck.c @@ -3,8 +3,9 @@ * * Loaded after genhexkins, so kinematicsForward() and kinematicsInverse() * resolve to it; the hal files set genhexkins.limit-iterations to 8, one - * with no screw lead and one with a lead of 5. A failed check fails the - * load, and a failed load fails the test. + * with no screw lead, one with a lead of 5 and joint axes, and one with the + * lead and no axes. A failed check fails the load, and a failed load fails + * the test. * * Motion runs the forward on the joint feedback every servo cycle, seeded * with the pose of the cycle before. The iteration stepped roll, pitch @@ -155,8 +156,8 @@ static void check_singular(void) } } -/* with y here strut 2, counting from 0, has its twist at a quarter turn in - the default geometry; step across it by 1e-11 */ +/* with y here strut 2, counting from 0, has its twist at a quarter turn with + the axes hexfwdcheck-screw.hal sets; step across it by 1e-11 */ static void check_corner(void) { for (int k = -1024; k <= 1024; k++) { diff --git a/tests/genhexkins-forward/test.sh b/tests/genhexkins-forward/test.sh index b4fe798b9bd..83d082e5483 100755 --- a/tests/genhexkins-forward/test.sh +++ b/tests/genhexkins-forward/test.sh @@ -3,8 +3,11 @@ set -e halcompile --install hexfwdcheck.c >/dev/null -# both run, so a failure in one does not hide the other +# all run, so a failure in one does not hide the others status=0 halrun -f hexfwdcheck.hal || status=1 halrun -f hexfwdcheck-screw.hal || status=1 +# genhexkins writes its message to stderr; checkresult reads stdout +echo "=== lead, no axes" +halrun -f hexfwdcheck-noaxes.hal 2>&1 || status=1 exit $status diff --git a/tests/kins-jacobian/test.sh b/tests/kins-jacobian/test.sh index 7b7a4b49be8..e8101a00c90 100755 --- a/tests/kins-jacobian/test.sh +++ b/tests/kins-jacobian/test.sh @@ -165,6 +165,42 @@ run "genhexkins" \ "setp genhexkins.screw-lead 0" \ "joints=6 r1=3 r2=4 r3=5 frompose=1 base=2,3,20 angles=0,5,-7,10 tolexp=3 types=1" run "genhexkins" \ - "setp genhexkins.screw-lead 5" \ + "setp genhexkins.screw-lead 5 +setp genhexkins.base-n.0.x 0.707107 +setp genhexkins.base-n.0.y 0.0 +setp genhexkins.base-n.0.z 0.707107 +setp genhexkins.base-n.1.x 0.0 +setp genhexkins.base-n.1.y -0.707107 +setp genhexkins.base-n.1.z 0.707107 +setp genhexkins.base-n.2.x -0.707107 +setp genhexkins.base-n.2.y 0.0 +setp genhexkins.base-n.2.z 0.707107 +setp genhexkins.base-n.3.x -0.707107 +setp genhexkins.base-n.3.y 0.0 +setp genhexkins.base-n.3.z 0.707107 +setp genhexkins.base-n.4.x 0.0 +setp genhexkins.base-n.4.y 0.707107 +setp genhexkins.base-n.4.z 0.707107 +setp genhexkins.base-n.5.x 0.707107 +setp genhexkins.base-n.5.y 0.0 +setp genhexkins.base-n.5.z 0.707107 +setp genhexkins.platform-n.0.x -1.0 +setp genhexkins.platform-n.0.y 0.0 +setp genhexkins.platform-n.0.z 0.0 +setp genhexkins.platform-n.1.x 0.866025 +setp genhexkins.platform-n.1.y 0.5 +setp genhexkins.platform-n.1.z 0.0 +setp genhexkins.platform-n.2.x 0.866025 +setp genhexkins.platform-n.2.y 0.5 +setp genhexkins.platform-n.2.z 0.0 +setp genhexkins.platform-n.3.x 0.866025 +setp genhexkins.platform-n.3.y -0.5 +setp genhexkins.platform-n.3.z 0.0 +setp genhexkins.platform-n.4.x 0.866025 +setp genhexkins.platform-n.4.y -0.5 +setp genhexkins.platform-n.4.z 0.0 +setp genhexkins.platform-n.5.x -1.0 +setp genhexkins.platform-n.5.y 0.0 +setp genhexkins.platform-n.5.z 0.0" \ "joints=6 r1=3 r2=4 r3=5 frompose=1 base=2,3,20 angles=0,5,-7,10 tolexp=3 types=1" run "pentakins" "" "joints=5 r1=3 r2=4 frompose=1 base=10,20,0 angles=0,5,-7,10 tolexp=3" diff --git a/tests/kins-params/test.sh b/tests/kins-params/test.sh index 7456b518774..f857db3ea33 100755 --- a/tests/kins-params/test.sh +++ b/tests/kins-params/test.sh @@ -228,5 +228,41 @@ setp tripodkins.Cy 2" \ run "lineardeltakins" "" "joints=9 frompose=1 pose=20,30,-200" run "rotarydeltakins" "" "joints=9 frompose=1 pose=0,0,-12" run "genhexkins" "setp genhexkins.screw-lead 0" "joints=6 frompose=1 pose=2,3,20,0,5,-7" -run "genhexkins" "setp genhexkins.screw-lead 5" "joints=6 frompose=1 pose=2,3,20,0,5,-7" +run "genhexkins" "setp genhexkins.screw-lead 5 +setp genhexkins.base-n.0.x 0.707107 +setp genhexkins.base-n.0.y 0.0 +setp genhexkins.base-n.0.z 0.707107 +setp genhexkins.base-n.1.x 0.0 +setp genhexkins.base-n.1.y -0.707107 +setp genhexkins.base-n.1.z 0.707107 +setp genhexkins.base-n.2.x -0.707107 +setp genhexkins.base-n.2.y 0.0 +setp genhexkins.base-n.2.z 0.707107 +setp genhexkins.base-n.3.x -0.707107 +setp genhexkins.base-n.3.y 0.0 +setp genhexkins.base-n.3.z 0.707107 +setp genhexkins.base-n.4.x 0.0 +setp genhexkins.base-n.4.y 0.707107 +setp genhexkins.base-n.4.z 0.707107 +setp genhexkins.base-n.5.x 0.707107 +setp genhexkins.base-n.5.y 0.0 +setp genhexkins.base-n.5.z 0.707107 +setp genhexkins.platform-n.0.x -1.0 +setp genhexkins.platform-n.0.y 0.0 +setp genhexkins.platform-n.0.z 0.0 +setp genhexkins.platform-n.1.x 0.866025 +setp genhexkins.platform-n.1.y 0.5 +setp genhexkins.platform-n.1.z 0.0 +setp genhexkins.platform-n.2.x 0.866025 +setp genhexkins.platform-n.2.y 0.5 +setp genhexkins.platform-n.2.z 0.0 +setp genhexkins.platform-n.3.x 0.866025 +setp genhexkins.platform-n.3.y -0.5 +setp genhexkins.platform-n.3.z 0.0 +setp genhexkins.platform-n.4.x 0.866025 +setp genhexkins.platform-n.4.y -0.5 +setp genhexkins.platform-n.4.z 0.0 +setp genhexkins.platform-n.5.x -1.0 +setp genhexkins.platform-n.5.y 0.0 +setp genhexkins.platform-n.5.z 0.0" "joints=6 frompose=1 pose=2,3,20,0,5,-7" run "pentakins" "" "joints=5 frompose=1 pose=10,20,0,5,-7"