Repository navigation
genserkins: use posemath, remove gomath - #4676
Open
grandixximo wants to merge 4 commits into
Open
grandixximo wants to merge 4 commits into
grandixximo wants to merge 4 commits into
Conversation
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.
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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.