Skip to content

genserkins: use posemath, remove gomath - #4676

Open
grandixximo wants to merge 4 commits into
LinuxCNC:masterfrom
grandixximo:posemath-consolidate
Open

grandixximo wants to merge 4 commits into
LinuxCNC:masterfrom
grandixximo:posemath-consolidate

Conversation

@grandixximo

Copy link
Copy Markdown
Contributor

gomath came in with genserkins in 2009, adapted from Fred Proctor's code, with a TODO in its header: "find the new functions, add them to posemath, convert the rest". genserkins was its only user. This does that conversion and removes gomath.

  • genserkins: use posemath instead of gomath. The pose, quaternion and RPY work goes through posemath. What posemath has no counterpart for stays in genserfuncs.c as static functions: the Jacobian's small matrices and their LU inverse, the Denavit-Hartenberg link pose, and the quaternion to rotation vector conversion (pmQuatRotConvert() zeroes a rotation under 1e-6, and the inverse iterates to 1e-7). The thresholds are gomath's double ones, so the results do not move.
  • libposemath: remove gomath. gomath.c, gomath.h and gotypes.h, about 4800 lines. The headers were never exported, so no module outside the tree could include them.
  • posemath: take the parallel checks over from blendmath. pmCartCartParallel() and pmCartCartAntiParallel() are plain vector helpers, so they move into posemath with the other PmCartesian functions.
  • tests: check the posemath parallel tests as a realtime component. tests/blendmath compiled blendmath.c with -DULAPI, which fails on GCC 14 since tp: make helix curvature independent of arc subdivision #4643 added EXPORT_SYMBOL there, the same failure as tests/tool-frame in Test tests/tool-frame fails locally #4670. It becomes tests/posemath-parallel, a component loaded after tpmod, which exports the two functions.

Fixes #389: genser now uses posemath's RPY conversion, which handles a pitch of minus a quarter turn. With the default geometry and the wrist at -90, gomath reported A -54.7, C -54.7 and the inverse came back with other joints; it now reports A -180, B -90, C 0 and the inverse returns the joints it was given. This supersedes the gomath part of #4623, where @Rimas2200 found and fixed the same branch. The ZYX half of that fix still applies to posemath's pmMatZyxConvert(), which nothing calls today; I left it to #4623.

Testing: I compared genserkins before and after over a grid of 592 joint sets plus the poles. The forward agrees to 1e-12, and the inverse returns the same joints and the same result everywhere except with the wrist exactly straight, where its Jacobian is singular and the iteration can settle on another of the equivalent wrist solutions. The full test suite passes apart from tests/tool-frame, which #4673 fixes.

@BsAtHome this is the consolidation from the #4673 discussion. One choice I am not sure of: tpmod exports the two posemath functions only so the test can reach them. posemath as a module of its own would be the cleaner shape, but every module that links it would then need it loaded first, so I left that out of this PR.

genserkins was the only user of gomath. The pose, quaternion and RPY work now goes through posemath, which has the same routines. What posemath has no counterpart for stays with genser as static functions in genserfuncs.c: the small matrices of the Jacobian and their LU inverse, the Denavit-Hartenberg link pose, and the quaternion to rotation vector conversion, since pmQuatRotConvert() zeroes a rotation under 1e-6 and the inverse iterates to 1e-7.

pmPosePoseMult() writes the result's translation before it reads the first operand's, so products whose result is an operand go through a copy.

The thresholds are gomath's double ones, 1e-7, so the results do not move: over a grid of 592 poses the forward agrees to 1e-12, and the inverse returns the same joints and the same result at every pose except those with the wrist exactly straight, where its Jacobian is singular and the iteration may settle on another of the equivalent wrist solutions.

At a pitch of minus a quarter turn the RPY conversion now takes the branch posemath has for it; gomath tested plus a quarter turn twice (LinuxCNC#389).

genser_kin_jac_inv() and genser_kin_jac_fwd() had no callers and go, with the declarations of functions genserkins.h named but nothing defined.
With genserkins on posemath nothing uses gomath. Its headers were never exported, so no module outside the tree could include them.
pmCartCartParallel() and pmCartCartAntiParallel() are vector helpers with nothing of the planner in them, so they go with the rest of the PmCartesian functions. The debug JSON output they wrote goes with the move, since posemath has no planner debug output.
tests/blendmath compiled blendmath.c into a userspace program with -DULAPI. Since blendmath.c exports pmCircleEffectiveMinRadius() (LinuxCNC#4643), EXPORT_SYMBOL is undefined there, which GCC 13 lets through as an implicit int and GCC 14 rejects. The two functions it checks are posemath's now, so it becomes tests/posemath-parallel: a component loaded after tpmod, which exports them, the way tests/kins-jacobian checks the kinematics modules. A failed check fails the load. The checks themselves are unchanged.
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.

gomath.c error

1 participant