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
12 changes: 12 additions & 0 deletions docs/src/getting-started/updating-linuxcnc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 /
Expand Down
10 changes: 8 additions & 2 deletions docs/src/man/man9/kins.9.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion src/emc/kinematics/genhexkins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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() ***************************/

Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
49 changes: 25 additions & 24 deletions src/emc/kinematics/genhexkins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 10 additions & 6 deletions tests/genhexkins-forward/checkresult
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions tests/genhexkins-forward/hexfwdcheck-noaxes.hal
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions tests/genhexkins-forward/hexfwdcheck-screw.hal
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions tests/genhexkins-forward/hexfwdcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++) {
Expand Down
5 changes: 4 additions & 1 deletion tests/genhexkins-forward/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 37 additions & 1 deletion tests/kins-jacobian/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
38 changes: 37 additions & 1 deletion tests/kins-params/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"