Repository navigation
Conversation
…dling The forward tested its errors for convergence with >, which is false for a NaN, and after the step, so it returned a NaN pose as success where the seed already fits and a strut length is NaN, or the Jacobian is singular, as with no lead and the platform turned 90 degrees at home, or flat in the base's plane. Require the step to be finite. A NaN length difference makes it NaN. With genhexkins.screw-lead set, each strut length carries a correction that changes with the pose, but the forward's Newton step left its rates out of the Jacobian rows. Over the 600 poses of tests/genhexkins-forward with a lead of 5, each seeded a cycle away, 455 did not converge within 8 iterations; at the default limit of 120, 24 still did not and 9 came back off the pose. Add the rates to the rows, as the gradient of the twist about the strut; none of the poses takes more than 5 iterations. From a seed well off, as the one from home after a failure, a full step can lead to another pose that has the same strut lengths, or not converge. With a lead set, shorten a step that moves roll, pitch or yaw by more than 0.2 radian. One cycle away the steps are almost always shorter than that. genhex_jacobian() differenced the inverse when a lead was set. It takes the same rates now, in closed form, and tests/kins-jacobian's lead-5 case checks them. The correction was asin() of the sine of the twist, taken as the dot product of two normalised vectors. At a quarter turn rounding can carry the product past +-1, and asin() is NaN, in the strut lengths of the inverse or in a step of the forward. Next to one asin() loses half the digits, and the forward takes more iterations. Take atan2() of the twist's sine and |cosine|, which is the same angle and does neither. tests/genhexkins-forward checks a NaN strut and a singular Jacobian, and its own comparison now fails on a NaN pose rather than pass it. It runs its grid a second time with a lead of 5, with three far poses from home that need the shortened step, and 2049 poses next to a quarter turn, where 621 failed with the rates but with asin(), on amd64. It also pins the correction of a strut past a quarter turn.
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.
Three fixes in genhexkins, with checks for each in
tests/genhexkins-forward. Withscrew-leadat 0, its default, only the first changes anything.genhex_jacobian()takes the same rates, in closed form, instead of differencing the inverse.From a seed well off, as the one from home after a failure, a full step could lead to another pose with the same strut lengths, or not converge. With a lead set, a step that moves roll, pitch or yaw by more than 0.2 rad is now shortened to that. From a cycle away no step is that long in practice (3 of a million seeds).
asin()could give NaN, in the inverse or in a step of the forward, and next to it the forward took more iterations: with the rates but withasin(), 621 of 2049 poses there failed at the test's limit of 8. It is nowatan2()of the sine and |cosine|, the same angle.Numbers from a harness outside LinuxCNC, lead 5 and the default geometry:
limit-iterationsat 8, 1463 fail, against 351 without the shortening; on master all do.The correction still folds at a quarter turn; that is #4902. pentakins has the same NaN tests; I've left it.
🤖 Generated with Claude Code