Skip to content

tests: round-trip kinematics modules at random points of their range - #4894

Open
Ash-Pera wants to merge 1 commit into
LinuxCNC:masterfrom
Ash-Pera:kins-roundtrip-split
Open

Ash-Pera wants to merge 1 commit into
LinuxCNC:masterfrom
Ash-Pera:kins-roundtrip-split

Conversation

@Ash-Pera

@Ash-Pera Ash-Pera commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Round-trips 21 kinematics modules at 2000 random points of a box in each one's working range, calling them as motion does. For serial machines the inverse, seeded a servo cycle off, must return the joints, not only the pose: a joint a whole turn away, or on another branch, gives the same pose, so a pose round trip like the one that found #4546's fixes cannot see it. Parallel machines and the gantry go the other way: the forward must return the pose. This found the scarakins and three21kins bugs fixed in #4867.

It is a mode of kins-unwrap's walkcheck, and roundcheck is gone; walkcheck also gains a joint count past six, every kinematics type and a tool offset, and a NaN joint now fails its compare. As discussed below, each module keeps its own directory, so runtests -j runs them side by side: 21 of them, each with the shared test.sh, checkresult and skip by symlink, compiling walkcheck for itself. Each case is a hal file there, 40 with the 10 walks. All pass on master under seeds 1 to 25 (add rseed=N to a box's walkcheck line); every pumakins case fails with its unwrap taken out, and every scarakins and three21kins case with #4867 reverted. scripts/runtests tests/kins-unwrap/pumakins runs one module.

Two boxes are held back from where the forward, seeded a cycle off, can land on another pose with the same strut lengths: pentakins below a = 5, and genhexkins with a screw lead below y = 1. genserkins and rosekins follow in their own PRs, with their fixes; userkins and switchkinscomp, the two templates, are left to kins-params.

🤖 Generated with Claude Code

@grandixximo

Copy link
Copy Markdown
Contributor

Thanks, this check is worth having: requiring the joints back, not just the pose, is something none of the existing kins tests do.

I read Bertho's point in #4867 differently, though. I don't think he was asking for the kins-unwrap directory layout to be copied. I think he was asking for one test frame in place of a separate test per bug. This PR adds a fourth checker next to paritycheck, jaccheck and walkcheck, which is the thing he questioned. roundcheck's joints-first flow is a one-step walk from a random point with a nearby seed, which walkcheck already does along a path. Could it be a mode of walkcheck in kins-unwrap now, not later?

Fanning out also costs more than it gains here. Each of the 21 directories runs halcompile --install ../roundcheck.c, and the install is a plain cp into rtlib/. Under runtests -j, one directory can overwrite the .so while another directory's halrun has it loaded. A 2000-point case takes about 0.06 s, so almost all of the runtime is compiling the same file 21 times. One compile followed by a loop over the case files would be faster and would not have the race.

@Ash-Pera

Copy link
Copy Markdown
Contributor Author

Yes, in this PR. roundcheck's joints-first check is walkcheck's step with a different seed (the drawn joints a cycle off, not the walk's previous answer), so roundcheck goes and walkcheck gains a second way to pick points: at random from a box, with a fixed seed. It brings a joint count past six, every kinematics type, the tool offset, and the pose-first flow for the parallel machines and gantry, which has no walk counterpart. Its compare also catches a NaN joint, which walkcheck's > misses.

Layout: one test, one compile, a loop over the case files. They stay hal files, since 18 of the 30 need setp lines or module arguments that walks can't carry, and the 10 walks become hal files too. This undoes Bertho's fan-out from #4867; I'll go ahead unless he'd rather keep it.

On the race: under -j each test runs in bwrap with / read-only and a tmp-overlay of TOPDIR (runtests.in L326, L332), so each install is private. The single compile removes it anyway.

@Ash-Pera
Ash-Pera force-pushed the kins-roundtrip-split branch from 5c17cef to c604b87 Compare November 24, 2026 04:28
@grandixximo

Copy link
Copy Markdown
Contributor

You're right about the race, I missed the tmp-overlay of TOPDIR under -j. Thanks for checking.

The plan sounds good to me: one checker, one compile, hal case files.

Comment thread tests/kins-unwrap/test.sh Resolved
@grandixximo

Copy link
Copy Markdown
Contributor

Also fetch and pull master and rebase, the CI mirror was too slow and was timing out, I improved CI update mirror selection.

@BsAtHome

Copy link
Copy Markdown
Contributor

Being able to run tests in parallel has priority, I guess. Each test is fully isolated as if it is a "copy" of the tree anyway. Having to compile the test-frame several times is compensated by running all of them in parallel. The kernel does a great job at caching, so the actual time it takes is not too bad.

@grandixximo

Copy link
Copy Markdown
Contributor

Fair enough, parallel first. Keeping the single walkcheck with one directory per module works for me, and the ONLY pointer goes away with it.

Most kinematics tests check a module at a few hand-picked points.
kins-unwrap's walkcheck now also checks 21 modules at 2000 points per
case and kinematics type, drawn from a fixed random seed in a box in
each module's working range.

For serial machines it draws joints, takes their pose from the forward,
and calls the inverse with that pose, the forward's flags and joints
1e-3 off, as motion does on the next servo cycle: the walk's check,
seeded a cycle off the joints instead of with the step before.  The
inverse must return the same joints, not another branch or a joint a
whole turn away.  For the parallel machines and the gantry it draws a
pose instead, takes its joints from the inverse, and requires the
forward, seeded 1e-3 off the pose, to return it.

walkcheck now takes a joint count past six and a tool offset, runs
every kinematics type of the module, and fails a NaN joint, which the
old > compare let through.

Each case is now a hal file in its module's directory, the walks
included, since 18 of the 30 box cases need setp lines or module
arguments.  All 40 pass with rseed=1 to 25; the scarakins and
three21kins cases fail with LinuxCNC#4867 reverted, and the pumakins cases with
its unwrap taken out.

genserkins and rosekins are left out until their fixes land.
@Ash-Pera
Ash-Pera force-pushed the kins-roundtrip-split branch from c604b87 to cd7e4de Compare November 25, 2026 01:02
@Ash-Pera

Copy link
Copy Markdown
Contributor Author

Reworked: one directory per module again, each compiling walkcheck, and ONLY is gone. Rebased onto master; all 21 pass in CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants