switchkins: allow starting in identity kinematics - #4482
Open
grandixximo wants to merge 3 commits into
Open
Conversation
grandixximo
force-pushed
the
switchkins-identityfirst
branch
from
August 28, 2026 08:33
eb297a8 to
af74175
Compare
A type with iterative forward kinematics restarts from the pose it last produced. That pose only accumulates while the type is running, so a type that has never run has nothing to start from. With identity kinematics selected first, genhexkins reported the hexapod platform at the origin instead of the place it is at, and switching to it adopted that position. Track whether a stored pose exists. Without one, start from the estimate the caller supplies, which motion seeds from the [TRAJ]HOME world home, and keep the result only when the solve succeeds. A gui type that cannot solve no longer fails the running type either. Those pins drive a vismach display, and a stale reading there is not a reason to report that the kinematics motion is running have failed.
handle_kinematicsSwitch() ran the forward kinematics of the new type straight into carte_pos_cmd and ignored the result. A type whose forward kinematics fail at the current pose therefore left whatever the failed solver had written in carte_pos_cmd, and tpSetPos() made that the machine's idea of where it is. The next move ran from a position the machine is not at. Solve into a local pose and commit it only on success, otherwise report the failure and set the motion error flag.
xyzac-trt-kins, xyzbc-trt-kins and 5axiskins accept the module string parameter sparm=identityfirst, which makes switchkins-type 0 identity kinematics and switchkins-type 1 the module's own. genserkins, pumakins, scarakins, three21kins and genhexkins did not, so those machines always start in the kinematics that can fail. A failing model kinematics is exactly where a machine needs identity kinematics: motion reports the error and disables the machine, and the operator needs a mode that solves at the current pose to move clear. motion.switchkins-type rests at zero and the shipped configs drive it from motion.analog-out-03, which is also zero until an M68 runs, so type 0 is both the type a machine starts in and the type it falls back to.
grandixximo
force-pushed
the
switchkins-identityfirst
branch
from
August 28, 2026 08:48
af74175 to
0cf11ca
Compare
Contributor
You are of course correct about the Thanks for the usual prompt and thorough fix. |
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.
sparm=identityfirstmakes switchkins-type 0 identity kinematics and type 1 the module's own. It exists inxyzac-trt-kins,xyzbc-trt-kinsand5axiskins.genserkins,pumakins,scarakins,three21kinsandgenhexkinshardcode type 0 to their own kinematics, so those machines can only start in the kinematics that can fail. This adds the option to all five.Refs #4480.
Why type 0 is the one that matters
motion.switchkins-typeis an input pin that rests at 0, and the shipped configs drive it frommotion.analog-out-03, which is also 0 until anM68runs. Whatever is registered as type 0 is therefore both the startup type and the type a machine falls back to, so it is the one that has to solve at any pose.Other controls treat the kinematic transformation as a modal state that is off unless the program turns it on:
TRAORI/TRAFOOFon Sinumerik,FUNCTION TCPM/FUNCTION RESET TCPMon Heidenhain,#TRAFO ON/#TRAFO OFFon TwinCAT CNC, whereauto_enable_kin_trafodecides what a program start selects. Robot controls take the other route and keep joint jog available at all times, which is the documented way out of a singularity on a FANUC. LinuxCNC has both routes; this closes the gap in the second one.Iterative forward kinematics
A type with iterative forward kinematics restarts from the pose it last produced, and that pose only accumulates while the type is running. A type that has never run therefore had nothing to start from. With identity kinematics selected first, genhexkins reported the hexapod platform at the origin instead of the place it is at, and switching to it adopted that position, so the next
G0dropped the platform 20 mm.switchkins now tracks whether it holds a pose for a type at all. Without one it starts from the estimate the caller passes, which motion already seeds from
[TRAJ]HOME. That covers any iterative type, not just genhexkins.A gui type that cannot solve also no longer fails the running type. Those pins drive a vismach display, and a stale reading there was being reported to motion as a forward-kinematics failure of the type actually running.
Position after a failed switch
handle_kinematicsSwitch()ran the new type's forward kinematics straight intocarte_pos_cmdand ignored the result, so a type that cannot solve at the current pose left whatever the failed solver had written there andtpSetPos()adopted it. The next move then ran from a position the machine is not at. It now solves into a local pose and commits only on success.Verification
Each sim config run twice, stock and with
sparm=identityfirst, comparing the world position after switching to the module kinematics:For the hexapod the
skgui.*pins also read the true platform pose while identity kinematics are running, and switching back to identity returns the same joint values as the stock ordering.runtests: 296 run, 296 successful, 0 failed, 3 skipped.Open question
The setting exchanges type 0 and type 1, so G-code or HAL that selects a type by number has to match. #4480 asks for identity to be the default rather than an option, which would mean that renumbering on every existing genserkins and pumakins config. Sinumerik makes the equivalent choice a machine-data bit, so a configurable default is not unusual, and I have kept this opt-in. Say the word if the default should flip instead.
@Sigma1912 one question on the report itself. In AXIS
$toggles joint jog mode, and free mode never calls the inverse kinematics, so after the controller drops out you can re-enable and jog the joints clear without changing kinematics type. Which GUI were you on, and what stopped the recovery there? Starting in identity is worth having either way, I would just like to know whether there is a second problem underneath.