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
1 change: 0 additions & 1 deletion src/hal/components/Submakefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ obj-m += $(patsubst hal/drivers/%.comp, %.o, $(patsubst hal/components/%.comp, %
# so it has to be defined in this file (which the .mak depends on).
SWITCHKINS_OBJS := emc/kinematics/switchkins.o emc/kinematics/switchkins_setup.o emc/kinematics/kins_util.o
matrixkins-extra-objs := emc/kinematics/kins_util.o emc/kinematics/kins_single.o emc/kinematics/kins_single_module.o
userkins-extra-objs := emc/kinematics/kins_util.o emc/kinematics/kins_single.o
millturn-extra-objs := $(SWITCHKINS_OBJS)
xyzab_tdr_kins-extra-objs := $(SWITCHKINS_OBJS)
xyzacb_trsrn-extra-objs := $(SWITCHKINS_OBJS)
Expand Down
7 changes: 2 additions & 5 deletions src/hal/components/userkins.comp
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ JOINTS=3
# number of joints used in your modified userkins.comp
----

A module built with halcompile takes the shared code from the
kins_single_core module, which the HAL file loads ahead of it:
The module takes the shared code from the kins_single_core module,
which the HAL file loads ahead of it:

----
loadrt kins_single_core
loadrt [KINS]KINEMATICS
----

The userkins built in tree has that code linked in and needs no
kins_single_core.

Note: the manpage for userkins is not updated by `halcompile --install`

To use a different component name, rename the file (example mykins.comp) and
Expand Down
5 changes: 3 additions & 2 deletions tests/kins-jacobian/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ run() {
local hal
case "$1" in "${ONLY:-}"*) ;; *) return 0 ;; esac
hal=$(mktemp --suffix=.hal)
{ printf 'loadrt %s\n' "$1"
{ if [ -n "${CORE:-}" ]; then printf 'loadrt %s\n' "$CORE"; fi
printf 'loadrt %s\n' "$1"
printf '%s\n' "$2"
printf 'loadrt jaccheck %s\n' "$3"
} > "$hal"
Expand All @@ -27,7 +28,7 @@ run() {
run "trivkins coordinates=XYZ" "" "joints=3"
run "trivkins coordinates=XYZY kinstype=BOTH" "" "joints=4 check=inv"
run "trivkins coordinates=XYZABCUVW" "" "joints=9 r1=3 r2=5"
run "userkins" "" "joints=3"
CORE=kins_single_core run "userkins" "" "joints=3"
run "millturn" "" "joints=4"

# linear maps and one rotation
Expand Down
2 changes: 2 additions & 0 deletions tests/kins-params/5axiskins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 4 2
File renamed without changes.
13 changes: 13 additions & 0 deletions tests/kins-params/5axiskins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
. ../lib.sh

# tables and heads, offsets set so no term drops out
run "5axiskins coordinates=XYZBCW" "" "joints=6 jnt=10,20,30,15,25,5 orient=4,3 posejoint=3"
run "5axiskins coordinates=XYZBCW sparm=identityfirst" "" "joints=6 jnt=10,20,30,15,25,5 orient=4,3 posejoint=3" 1

# a tool offset across the tool, a tool held off the spindle axis: its X
# and Y turn with the tool frame the module reports, the same in realtime
# and outside it
run "5axiskins coordinates=XYZBCW" "" "joints=6 jnt=10,20,30,15,25,5 orient=4,3 posejoint=3 tool=4,3,12"
run "5axiskins coordinates=XYZBCW sparm=identityfirst" "" "joints=6 jnt=10,20,30,15,25,5 orient=4,3 posejoint=3 tool=4,3,12" 1
14 changes: 8 additions & 6 deletions tests/kins-params/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import hal

EMC2_HOME = os.environ.get("EMC2_HOME")
# the realtime checker, built under its test's name
CHECKER = os.environ.get("PARITYCHECK", "paritycheck")
# local, the way a GUI holds them under the interpreter it loads: what a
# module needs in scope, the HAL library and an out of tree module's core,
# the loader puts there itself
Expand Down Expand Up @@ -109,9 +111,9 @@ def compare(what, ours, theirs):
if not close(ours, theirs):
fail("%s: loader %.12g, realtime %.12g" % (what, ours, theirs))

rc_fwd = hal.get_value("paritycheck.rc-fwd")
rc_inv = hal.get_value("paritycheck.rc-inv")
rc_jac = hal.get_value("paritycheck.rc-jac")
rc_fwd = hal.get_value(CHECKER + ".rc-fwd")
rc_inv = hal.get_value(CHECKER + ".rc-inv")
rc_jac = hal.get_value(CHECKER + ".rc-jac")

q = Joints(*jnt_in)
qi = Joints(*jnt_in)
Expand All @@ -135,14 +137,14 @@ def compare(what, ours, theirs):

if r_fwd == 0 and rc_fwd == 0:
for n in "xyzabcuvw":
compare("forward %s" % n, getattr(F, n), hal.get_value("paritycheck.fwd-%s" % n))
compare("forward %s" % n, getattr(F, n), hal.get_value(CHECKER + ".fwd-%s" % n))
if r_inv == 0 and rc_inv == 0:
for j in range(joints):
compare("inverse joint %d" % j, qi[j], hal.get_value("paritycheck.inv-%d" % j))
compare("inverse joint %d" % j, qi[j], hal.get_value(CHECKER + ".inv-%d" % j))
if r_jac == 0 and rc_jac == 0:
for j in range(joints):
for a, n in enumerate("xyzabcuvw"):
compare("jacobian [%d][%s]" % (j, n), J[j][a], hal.get_value("paritycheck.jac-%d-%s" % (j, n)))
compare("jacobian [%d][%s]" % (j, n), J[j][a], hal.get_value(CHECKER + ".jac-%d-%s" % (j, n)))

# the caller's tool wins over the module's pin: for a module with a tool
# entry, a length of the caller's must move the inverse, and handing the
Expand Down
6 changes: 0 additions & 6 deletions tests/kins-params/checkresult

This file was deleted.

12 changes: 12 additions & 0 deletions tests/kins-params/checkresult.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# checkresult for each module: every entry agrees, at least $2 entries
# ran, and every tool offset entry, at least $3 of them, turned the
# offset with the tool
r=$1 min=$2 mintool=$3
n=$(grep -c '^=== ' "$r")
tool=$(grep -c '^=== .* tool ' "$r")
[ "$(grep -c 'agrees' "$r")" = "$n" ] \
&& [ "$n" -ge "$min" ] \
&& [ "$(grep -c 'turns the offset across the tool' "$r")" = "$tool" ] \
&& [ "$tool" -ge "$mintool" ] \
&& ! grep -q "FAIL" "$r"
2 changes: 2 additions & 0 deletions tests/kins-params/corexykins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/corexykins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 6 additions & 0 deletions tests/kins-params/corexykins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
. ../lib.sh

# linear maps and one rotation
run "corexykins" "" "joints=9"
2 changes: 2 additions & 0 deletions tests/kins-params/genhexkins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 2 0
4 changes: 4 additions & 0 deletions tests/kins-params/genhexkins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
7 changes: 7 additions & 0 deletions tests/kins-params/genhexkins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
. ../lib.sh

# parallel machines, from a pose the forward can be seeded with
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"
2 changes: 2 additions & 0 deletions tests/kins-params/genserkins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 2 0
4 changes: 4 additions & 0 deletions tests/kins-params/genserkins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
7 changes: 7 additions & 0 deletions tests/kins-params/genserkins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
. ../lib.sh

# arms
run "genserkins" "" "joints=9 jnt=15,20,-35,10,70,20,0,0,0 orient=-"
run "genserkins" "setp genserkins.unrotate-3 1" "joints=9 jnt=15,20,-35,10,70,20,0,0,0 orient=-"
70 changes: 70 additions & 0 deletions tests/kins-params/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Sourced by the test.sh of each module's directory. Each builds the
# realtime checker under its own name, paritycheck_ and the directory,
# so tests running side by side never install over a module another one
# is loading.
KP=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PARITYCHECK=paritycheck_$(basename "$PWD" | tr - _)
export PARITYCHECK
sed "s/paritycheck/$PARITYCHECK/g" "$KP/paritycheck.c" > "$PARITYCHECK.c"
halcompile --install "$PARITYCHECK.c" >/dev/null
rm -f "$PARITYCHECK.c"

# One hal file per module. The checker evaluates the module in realtime
# through the classic entry points and publishes the answers; check.py
# evaluates it through the non-realtime loader, kinsDescribe() and the
# parameter block, and compares. Where they disagree the module keeps
# state its table does not declare.
# ONLY=<module> in the environment runs the entries for that module alone
run() {
local loadrt="$1" setp="$2" parms="$3" ktype="$4"
local module coords sparm joints frompose pose jnt orient posejoint tool rtparms hal tok
case "$loadrt" in "${ONLY:-}"*) ;; *) return 0 ;; esac
module=${loadrt%% *}
coords=""; sparm=""
for tok in $loadrt; do
case "$tok" in
coordinates=*) coords=${tok#coordinates=} ;;
sparm=*) sparm=${tok#sparm=} ;;
esac
done
joints=3; frompose=0; pose="0,0,0,0,0,0,0,0,0"; jnt="10,20,30,40,50,60,70,80,90"
# the two rotaries that orient the tool, "primary,secondary", or "-"
# where the machine has no such pair and "no-frame" where the module
# reports no tool frame at all, which most of the tree still does
orient="no-frame"
# the rotary whose sign G53.1 P names, the same three ways; where the
# entry gives none, what it gives for the pair
posejoint=""
# a tool offset x,y,z both sides evaluate under, as motion hands it over
tool="-"
for tok in $parms; do
case "$tok" in
joints=*) joints=${tok#joints=} ;;
frompose=*) frompose=${tok#frompose=} ;;
pose=*) pose=${tok#pose=} ;;
jnt=*) jnt=${tok#jnt=} ;;
orient=*) orient=${tok#orient=} ;;
posejoint=*) posejoint=${tok#posejoint=} ;;
tool=*) tool=${tok#tool=} ;;
esac
done
[ -n "$posejoint" ] || posejoint=$orient
# what the module under test is loaded with: everything but our own words
rtparms=$(printf ' %s ' "$parms" | sed 's/ orient=[^ ]*//g; s/ posejoint=[^ ]*//g')
hal=$(mktemp --suffix=.hal)
{ if [ -n "${CORE:-}" ]; then printf 'loadrt %s\n' "$CORE"; fi
printf 'loadrt %s\n' "$loadrt"
printf '%s\n' "$setp"
printf 'loadrt %s %s ktype=%s\n' "$PARITYCHECK" "$rtparms" "${ktype:-0}"
# halcmd keeps quotes, so an absent value travels as a dash
printf 'loadusr -w python3 %s/check.py %s %s %s %s %s %s %s %s %s %s %s\n' \
"$KP" "$module" "$joints" "${coords:--}" "${ktype:-0}" "$frompose" "$pose" "$jnt" "${sparm:--}" "$orient" "$posejoint" "$tool"
} > "$hal"
if [ "$tool" = "-" ]; then
echo "=== $loadrt type ${ktype:-0}"
else
echo "=== $loadrt type ${ktype:-0} tool $tool"
fi
halrun -f "$hal"
rm -f "$hal"
}
2 changes: 2 additions & 0 deletions tests/kins-params/lineardeltakins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/lineardeltakins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 6 additions & 0 deletions tests/kins-params/lineardeltakins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
. ../lib.sh

# parallel machines, from a pose the forward can be seeded with
run "lineardeltakins" "" "joints=9 frompose=1 pose=20,30,-200"
2 changes: 2 additions & 0 deletions tests/kins-params/matrixkins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/matrixkins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
14 changes: 14 additions & 0 deletions tests/kins-params/matrixkins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e
. ../lib.sh

# linear maps and one rotation
run "matrixkins" \
"setp matrixkins.C_xy 0.02
setp matrixkins.C_xz -0.01
setp matrixkins.C_yx 0.03
setp matrixkins.C_yz 0.015
setp matrixkins.C_zx -0.02
setp matrixkins.C_zy 0.01
setp matrixkins.C_zz 1.001" \
"joints=9"
2 changes: 2 additions & 0 deletions tests/kins-params/maxkins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/maxkins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
8 changes: 8 additions & 0 deletions tests/kins-params/maxkins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
. ../lib.sh

# tables and heads, offsets set so no term drops out
run "maxkins" \
"setp maxkins.pivot-length 100" \
"joints=9 jnt=10,20,30,0,15,25,7,0,3 orient=- posejoint=4"
2 changes: 2 additions & 0 deletions tests/kins-params/millturn/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 2 0
4 changes: 4 additions & 0 deletions tests/kins-params/millturn/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
7 changes: 7 additions & 0 deletions tests/kins-params/millturn/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
. ../lib.sh

# identity, a gantry included
run "millturn" "" "joints=4 jnt=10,20,30,40 orient=-"
run "millturn" "" "joints=4 jnt=10,20,30,40" 1
2 changes: 2 additions & 0 deletions tests/kins-params/pentakins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/pentakins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 6 additions & 0 deletions tests/kins-params/pentakins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
. ../lib.sh

# parallel machines, from a pose the forward can be seeded with
run "pentakins" "" "joints=5 frompose=1 pose=10,20,0,5,-7"
2 changes: 2 additions & 0 deletions tests/kins-params/pumakins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/pumakins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 6 additions & 0 deletions tests/kins-params/pumakins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
. ../lib.sh

# arms
run "pumakins" "setp pumakins.D6 50" "joints=6 jnt=15,20,-35,10,70,20 orient=-"
2 changes: 2 additions & 0 deletions tests/kins-params/rosekins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/rosekins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 6 additions & 0 deletions tests/kins-params/rosekins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
. ../lib.sh

# polar
run "rosekins" "" "joints=3 jnt=10,5,30"
2 changes: 2 additions & 0 deletions tests/kins-params/rotarydeltakins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/rotarydeltakins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 6 additions & 0 deletions tests/kins-params/rotarydeltakins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
. ../lib.sh

# parallel machines, from a pose the forward can be seeded with
run "rotarydeltakins" "" "joints=9 frompose=1 pose=0,0,-12"
2 changes: 2 additions & 0 deletions tests/kins-params/rotatekins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/rotatekins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 6 additions & 0 deletions tests/kins-params/rotatekins/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e
. ../lib.sh

# linear maps and one rotation
run "rotatekins" "" "joints=9"
2 changes: 2 additions & 0 deletions tests/kins-params/scarakins/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec "$(dirname "$0")/../checkresult.sh" "$1" 1 0
4 changes: 4 additions & 0 deletions tests/kins-params/scarakins/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Builds a realtime component with halcompile, which needs the build
# tools present. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
Loading