Repository navigation
fix: Twist2.ad raised ValueError for every twist; add Twist2.Ad and SE2.Ad - #259
Open
petercorke wants to merge 1 commit into
Open
petercorke wants to merge 1 commit into
petercorke wants to merge 1 commit into
Conversation
…E2.Ad
Twist2.ad was a copy of Twist3.ad that was never adapted to 2D: it called
skew() on the scalar w and built 6x6 blocks, so it raised ValueError for any
Twist2. It was also a property while Twist3.ad is a method, and its
docstring example called unit().
Rewrite it as a method returning the 3x3 matrix of the Lie bracket,
[[0, -w, vy], [w, 0, -vx], [0, 0, 0]]
and return a list for a sequence, as skewa() does. Add Twist2.Ad() and
SE2.Ad() (tr2adjoint2 existed but only as a base function) to match
Twist3.Ad and SE3.Ad.
Also correct the 2D-specific text in tr2adjoint2's docstring, which named
tr2jac2 and said 6x6.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
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.
Problem
Twist2.adraisesValueError: argument must be a 1- or 3-vectorfor every twist, and always has. It is a copy ofTwist3.adthat was never adapted to 2D: it callsskew()on the scalarwand builds 6x6 blocks, where the 2D result is 3x3. Nothing in the repo calls it and no test covered it.It also differs from its 3D sibling in other ways:
@property, whileTwist3.adis a method and both docstrings sayS.ad().S.unit(), and its see-also points atSE3.Ad.Twist2has noAd(), and neither doesSE2.tr2adjoint2exists, but only as a base function, so thead/Adpair thatTwist3andSE3have was half missing in 2D.Changes
Twist2.ad()is now a method returning the 3x3 matrix of the Lie bracket,[[0, -ω, v_y], [ω, 0, -v_x], [0, 0, 0]]. For a sequence it returns a list, asskewa()does.Twist2.Ad()is new and mirrorsTwist3.Ad(): the adjoint of the equivalent SE(2) pose.SE2.Ad()is new and mirrorsSE3.Ad().tr2adjoint2docstring: its text namedtr2jac2and said 6x6. Now it namestr2adjoint2and gives 3x3 (1x1 for SO(2)).Verification
The new
tests/test_twist2_adjoint.pychecks against independent oracles, not against the implementation:ad(S) @ Tequals the commutator of the augmented skew matrices,vee([S, T]).[S, S] = 0andad(S) T = -ad(T) S.expm(ad(S))equalsAd(exp(S)).SE2.Ad() @ Sequalsvee(T [S] T^-1).Ad(T1 T2) = Ad(T1) Ad(T2), andAdof the identity isI.All six fail on
masterand pass here. Full suite: 386 passed, 3 skipped. Black is clean. The branch merges cleanly with #225, #248, #249, #258 and the integration hub #246.Not changed
tr2adjointandtr2adjoint2both have a.. math:directive with a single colon (so it renders as a comment) and unbalanced braces in the formula. I left those alone because the 3D function shares them and fixing the math needs a check of the Sphinx macros.Twist3.ad()silently uses the first element of a sequence.Twist2.ad()returns a list, so the two now differ for sequences. I'd harmonize them separately.🤖 Generated with Claude Code