Repository navigation
Add normalized to SE2 and SE3 - #398
Merged
kmolan merged 1 commit intoDec 2, 2026
Merged
Conversation
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
SO2andSO3havenormalized, which removes the rotation drift that long composition chains accumulate.SE2andSE3did not, so callers had to rebuild the pose withfrom_partsby hand. Odometry composes anSE2on every tick, so this drift is a real concern.Change
SE2::normalized(self)andSE3::normalized(self)renormalize the rotation and keep the translation unchanged. Both are#[inline]and#[must_use], and are implemented asSelf::from_parts(self.rotation.normalized(), self.translation).se2_normalized_removes_composition_driftcomposes anSE2step 10 000 times, checks that the rotation drifted, then checks thatnormalized()restores a unit-norm rotation and leaves the translation exactly equal.se3_normalized_removes_composition_driftdoes the same forSE3, checking the rotation quaternion norm against4.0 * f64::EPSILON.Unreleased/Added.Testing
wsl -d Debian -- bash -lc 'cd /mnt/e/pr-go-state/work/kmolan_multicalc-rust-377-12496-d88fa2 && cargo test -p multicalc --test suite se2_normalized': passes.wsl -d Debian -- bash -lc 'cd /mnt/e/pr-go-state/work/kmolan_multicalc-rust-377-12496-d88fa2 && cargo test -p multicalc --test suite se3_normalized': passes.SE2/SE3withoutnormalized), the test build fails withno method named normalizedfor both types.cargo fmt --all -- --check: clean.cargo clippy -p multicalc --all-targets --features alloc -- -D warnings: finishes with no warnings.Regression test: fails on base twice (/no method named
normalized/), passes on fix twice (cargo test -p multicalc --test suite se2_normalized)Fixes #377