Replace Jacobian pseudo-inverse with Damped Least Squares (panic-free IK)#173
Open
kmolan wants to merge 6 commits into
Open
Replace Jacobian pseudo-inverse with Damped Least Squares (panic-free IK)#173kmolan wants to merge 6 commits into
kmolan wants to merge 6 commits into
Conversation
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.
Summary
Swaps
JacobianIkSolver's pseudo-inverse step for Damped Least Squares (manipulability-baseddynamic damping) and adds opt-in null-space joint-limit avoidance (Liégeois). DLS solves min ‖JΔθ − e‖² + λ²‖Δθ‖², which replaces the pseudo-inverse's unbounded singular values 1/σ with σ/(σ²+λ²) — finite for all σ, so the step stays bounded and the normal matrix JJᵀ+λ²I is always invertible (SPD) instead of blowing up near singularities. Cleans up the logic to now have a single path for IK instead of the earlier three separate branches. Also added more tests for IK.
Changes
JJᵀ + λ²I, ≤6×6) replaces the three pseudo-inverse branches; the.unwrap()panic sites become a gracefulInverseMatrixError.λ² = 0when well-conditioned, so DLS reduces exactly to the old pseudo-inverse.set_joint_limit_avoidance_gain(default0.0= inert) + damping setters, all with doctests.before/after benchmark writeup.
Compatibility
Default
gain = 0⇒ existing results unchanged; only near-singular behavior changes (panic → bounded).Ship as 0.33.0.
Results
Ran examples/ik_benchmark.rs before and after my changes. Comparison result:
i7-12650H,
--release, 200 seeded solves/regime.Robustness / accuracy (residuals over successes)
Timing (criterion mean vs saved
beforebaseline)bench_redundant_constrained(m=5, n=6)bench_wellconditioned(m=n=6)Well-conditioned & redundant results are unchanged (backward-compat); near-singular stays finite with
much cleaner solutions. Redundant path is 40% faster (Cholesky replaces SVD); the square path costs
~0.57 µs more for the damping (negligible on a sub-5 µs solve).