Skip to content

Broadcast scalar integration steps over twist sequences - #248

Open
antonsoo wants to merge 1 commit into
rai-opensource:masterfrom
antonsoo:fix/twist-sequence-scalar-time
Open

antonsoo wants to merge 1 commit into
rai-opensource:masterfrom
antonsoo:fix/twist-sequence-scalar-time

Conversation

@antonsoo

Copy link
Copy Markdown

Twist3.exp documents applying one integration step to every twist in a sequence, but currently raises ValueError: length mismatch. The SE3 conversion also rejects that case. The corresponding Twist2 methods fail too, including matched per-twist steps in SE2.

Handle the shared scalar step in all four methods, and match individual steps in Twist2.SE2. Check degree-mode warnings per twist so that path works for sequences as well. Singleton expansion and mismatched-length rejection are retained.

from spatialmath import Twist3

motion = Twist3([Twist3.Rx(0.2), Twist3.Ry(-0.3)])
print(len(motion.exp(0.5)))  # 2; currently raises ValueError
print(len(motion.SE3()))     # 2; currently raises ValueError

Validation: 20 focused cases compare the results to independent SciPy matrix exponentials (17 fail before). A 717-row camera-reconstruction fixture exercises 96 motion increments in 2D and 3D: all 21 formerly aborting sequence workflows complete, and transformed points agree with the independent reference within 4e-14. Ordinary single-twist output hashes are unchanged. Full suite: 367 passed, 3 existing skips; project pre-commit hooks pass. Linux/Python 3.12.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@petercorke petercorke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The broadcast semantics match the existing docstrings, the tests pass locally (367 passed), and round trips against expm agree. It also merges cleanly with the integration hub (#246) and with #249.

One pre-existing issue turned up while reviewing, which this PR sidesteps in Twist2.SE2 but does not fix: the isprismatic property raises AttributeError on any twist sequence. I'll follow up with a separate PR on top of this one.

@petercorke

Copy link
Copy Markdown
Collaborator

Thank you for your interest in SMTB and for this contribution. Welcome, and congratulations on your first PR here!

I've approved this. The broadcast semantics match what the exp() docstring already promised, and the round trips against expm agree. Reviewing it turned up a few related problems (isprismatic/isrevolute failing on sequences, Twist2.__rmul never being called, and some copied docstrings), which I've sent as a follow-up PR on top of yours in #258, so you get credit for the base change.

@antonsoo

Copy link
Copy Markdown
Author

Thanks for the review and for building #258 on this branch. I have read #257 and will add the concrete cases from the trajectory and pole checks there.

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.

3 participants