Skip to content

fix(ik): trajectory residual is the maximum, and document trajectory behaviour - #712

Open
petercorke wants to merge 3 commits into
mainfrom
fix/ik-trajectory-docs-residual
Open

petercorke wants to merge 3 commits into
mainfrom
fix/ik-trajectory-docs-residual

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • For a trajectory of poses, IKSolver.solve (so all ikine_* methods) returned the minimum residual over the poses, which hid poses solved badly or not at all. It is now the maximum, the worst case.
  • Trajectory behaviour was undocumented. It is now described in IKSolver.solve, the ikine_LM/NR/GN/QP methods of ETS and RobotKinematics, DHRobot.ikine_LM and docs/source/IK/ik.rst: accepted inputs (SE3 with N poses or an (N, 4, 4) array), q of shape (N, n), every pose seeded with the same q0 (so consecutive solutions may be on different IK branches), and how success, iterations, searches, residual and reason are combined. A versionchanged:: 1.4.5 notice records the residual change.
  • Docs that were wrong are corrected:
    • ik_NR / ik_GN (in ETS and RobotKinematics) said they accept a pose trajectory. The C++ solvers take a single 4x4 pose and raise TypeError otherwise.
    • ETS.ik_GN and ik.rst said the C++ solvers return a tuple. They return an IKSolution.

Behaviour change

Only the trajectory residual value changes (min to max). Single-pose results are unchanged. Code that checks sol.success is unaffected. Code that relied on the old minimum as a "best pose" measure would see a larger value.

Test plan

  • tests/test_IK.py and tests/test_ik_joint_limits.py pass locally
  • New test_trajectory_residual_is_maximum (stub solver, known residuals) and test_trajectory_failure_is_reported (one reachable, one unreachable pose) both fail on main and pass here
  • CI

🤖 Generated with Claude Code

…behaviour

For a trajectory of poses the numeric IK returned the minimum residual over
the poses, which hid poses that were solved badly (or not at all).  It is now
the maximum, the worst case.

Document trajectory behaviour, which was missing: accepted inputs, q of shape
(N, n), every pose seeded with the same q0 so consecutive solutions may be on
different IK branches, and how success, iterations, searches, residual and
reason are combined.  Applies to IKSolver.solve and the ikine_* methods, and
to docs/source/IK/ik.rst.

Correct docs that were wrong:
- ik_NR and ik_GN claimed to accept a pose trajectory, but the C++ solvers take
  a single 4x4 pose and raise TypeError otherwise
- ETS.ik_GN and ik.rst said the C++ solvers return a tuple, they return an
  IKSolution

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

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.

The next release will be 1.5.0, the 1.4.5 release is not being published.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (acc6842) to head (d2fb0d1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/roboticstoolbox/robot/IK.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #712   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        143     143           
  Lines      14269   14269           
=====================================
  Misses     14269   14269           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

q0 may be a vector (n,) or a matrix (m, n) whose rows are the starting points
of the first m searches, as _solve already does.  This was undocumented, every
q0 description said "the initial joint coordinate vector".  Document it on
IKSolver.solve and the ikine_* methods, and add a test.

The ValueError for a badly shaped Tep said "Tep must be a 4x4 SE3 matrix", it
now says what is accepted: an SE3, a 4x4 array or an (N, 4, 4) array.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant