Skip to content

fix(ik): Robot.ikine_* accept an (N, 4, 4) array of poses - #714

Open
petercorke wants to merge 1 commit into
mainfrom
fix/robot-ikine-trajectory-array
Open

petercorke wants to merge 1 commit into
mainfrom
fix/robot-ikine-trajectory-array

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • ETS.ikine_* accept an (N, 4, 4) array as a pose trajectory, but the Robot wrappers (Robot.ikine_LM/NR/GN/QP) did not. They built the pose with SE3(Tep, check=False), which silently makes a malformed object from a 3-D array, and the solver then failed deep inside with ValueError: operands could not be broadcast together with shapes (3,4) (3,).
  • Convert the array with a small helper, _as_se3, that works around spatialmath not accepting such an array (reported as Enhancement: SE3 constructor should accept an (N, 4, 4) ndarray as N poses rai-opensource/spatialmath-python#236), and reject any other array shape up front with a clear ValueError. The helper is used at all seven wrap sites (the four ikine_* and the three C++ ik_* wrappers). The ik_* solvers still handle a single pose only.

Notes

  • Found while checking which IK entry points accept which input forms, for the docs in fix(ik): trajectory residual is the maximum, and document trajectory behaviour #712. That PR's trajectory docstrings say an (N, 4, 4) array is accepted by Robot.ikine_*, which is only true with this change.
  • The two PRs touch the same files but merge cleanly in either order (checked with a trial merge).
  • The workaround can be removed once spatialmath accepts stacked arrays.

Test plan

  • tests/test_IK.py and tests/test_ik_joint_limits.py pass locally
  • test_robot_ikine_accepts_pose_arrays (LM/GN/NR, array vs SE3 input give the same result, and a single 4x4 array still works) fails on main with the ValueError above and passes here
  • test_robot_ikine_rejects_badly_shaped_arrays
  • CI

🤖 Generated with Claude Code

ETS.ikine_* accept an (N, 4, 4) array as a pose trajectory but the Robot
wrappers did not: they built the pose with SE3(Tep, check=False), which
silently makes a malformed object from a 3-D array, and the solver then failed
deep inside with a shape-mismatch ValueError.

Convert the array with a small helper that works around spatialmath not
accepting such an array (spatialmath-python#236), and reject any other array
shape up front with a clear ValueError.  Applies to the ikine_* and ik_*
wrappers, the ik_* (C++) solvers still handle a single pose only.

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

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 14 complexity · -4 duplication

Metric Results
Complexity 14
Duplication -4

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.

@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

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

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

☔ 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.

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