Repository navigation
angvec2r: reject a zero axis for a non-zero angle - #267
Open
petercorke wants to merge 1 commit into
Open
petercorke wants to merge 1 commit into
petercorke wants to merge 1 commit into
Conversation
angvec2r returned the identity whenever the axis norm was ~0, whatever the angle, so a non-zero rotation about no axis silently gave the identity (angvec2tr, SO3/SE3.AngleAxis and AngVec inherit this). Test the angle for zero instead, which is what the docstring already described for `tol`: a zero angle (within tol eps) returns the identity and ignores the axis; otherwise the axis is normalized with unitvec, which raises ValueError for a zero-length axis. Consistent with UnitQuaternion.AngVec in rai-opensource#266. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
4 tasks
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
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.
Follow-up to #266, which makes
UnitQuaternion.AngVecraiseValueErrorfor a non-zero angle about a zero axis. As noted there, the base functions did not behave consistently with that.Problem
angvec2rtested the axis norm and returned the identity if it was ~0, whatever the angle:angvec2tr,SO3.AngleAxis/AngVecandSE3.AngleAxis/AngVecinherit this. The docstring already says thattolis for the "zero-rotation case" and thatVmust have finite length when the angle is non-zero, but the code did not do that.Change
Test the angle for zero instead:
toleps, viaiszero): return the identity, axis ignoredunitvec, which raisesValueErrorfor a zero-length axisDocstring notes for
angvec2randangvec2trupdated (the oldθ ~= 0wording was MATLAB "not equal" and read ambiguously).Behaviour change
A non-zero angle about a zero-length axis (including a tiny axis below 20 eps) now raises
ValueErrorrather than returning the identity. Non-zero axes of any length are unaffected.Downstream
I audited the sibling toolboxes. The only affected caller is a line-of-sight helper in RTB that applies
AngleAxistocross(a, b), which is zero for (anti)parallel vectors. It is already wrong for antiparallel vectors today, andSO3.RotatedVector(in the released 1.1.18) is the correct replacement. Tracked in petercorke/robotics-toolbox-python#843, to land before this is released.Tests
test_angvec2r_nonunit_axis,test_angvec2r_zero_axis(rad and deg), additions totest_angvec2tr, andtest_AngleAxis_zero_axisforSO3/SE3🤖 Generated with Claude Code