Repository navigation
fix(ik): abandon a search whose joint angles diverge, and restart it - #948
Merged
Merged
Conversation
A Gauss-Newton or Newton-Raphson search can diverge from a bad start. With the compiled fkine the infinite joint angles give NaN, and the search burned iterations until ilimit; with the pure-Python fkine, rotz(inf) raises ValueError: math domain error, which escaped solve() and ended the whole call. Which of test_IK_GN1 and test_IK_NR8 failed depended on the platform: a 1e-13 change to the target flipped the outcome. _solve() now abandons the search as soon as q or E is no longer finite, as it already does for LinAlgError, and says so in the failure reason. A ValueError with a finite q is still raised. step() updates q in place, so q shows which case it is. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 19 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
What
A Gauss-Newton or Newton-Raphson search can diverge from a bad start. With the compiled
fkinean infinite joint angle gives NaN, and the search burned iterations untililimit. With the pure-Pythonfkine,rotz(inf)raisesValueError: math domain error, which escapedsolve()and ended the whole call._solve()now abandons the search as soon asqorEis no longer finite, and restarts it, as it already does fornumpy.linalg.LinAlgError. The failure reason says how many searches diverged. AValueErrorwith a finiteqis still raised:step()updatesqin place, soqshows which case it is (checked forIK_NR,IK_LM,IK_GNandIK_QP).Found by the new pure-Python coverage leg in #946.
test_IK_GN1failed on a Mac andtest_IK_NR8on the Ubuntu runner: the searches are chaotic, and a 1e-13 change to the target flipped the outcome, so which test failed depended on the platform.Refs #898.
Behaviour
ValueError; it now restarts.ilimit. The result is the same, butiterationscan be lower in those cases.What I ran, and what I could not
TestDivergedSearchintests/test_IK.py: a step that diverges by raising, one that diverges by returning NaN, a failure message that names the cause, and an unrelatedValueErrorthat must still propagate. Three of the four fail without the change.test_IK_GN1andtest_IK_NR8now succeed at all six target perturbations (0 to 1e-9); before, they raised or failed at most of them.tests/test_IK.pyandtests/test_Robot.pythere show no new failures. The ones left need the compiled extension, or are fixed by fix(robot): update link scene-node transforms without the compiled extension #947, which this branch does not include.AI assistance
Written with Claude Code (Claude Sonnet 5.5), reviewed by the maintainer.
🤖 Generated with Claude Code