Skip to content

Add normalized to SE2 and SE3 - #398

Merged
kmolan merged 1 commit into
kmolan:mainfrom
jay23606:pr-go/377-add-normalized-to-se2-and-se3
Dec 2, 2026
Merged

kmolan merged 1 commit into
kmolan:mainfrom
jay23606:pr-go/377-add-normalized-to-se2-and-se3

Conversation

@jay23606

@jay23606 jay23606 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Problem

SO2 and SO3 have normalized, which removes the rotation drift that long composition chains accumulate. SE2 and SE3 did not, so callers had to rebuild the pose with from_parts by hand. Odometry composes an SE2 on every tick, so this drift is a real concern.

Change

  • SE2::normalized(self) and SE3::normalized(self) renormalize the rotation and keep the translation unchanged. Both are #[inline] and #[must_use], and are implemented as Self::from_parts(self.rotation.normalized(), self.translation).
  • se2_normalized_removes_composition_drift composes an SE2 step 10 000 times, checks that the rotation drifted, then checks that normalized() restores a unit-norm rotation and leaves the translation exactly equal.
  • se3_normalized_removes_composition_drift does the same for SE3, checking the rotation quaternion norm against 4.0 * f64::EPSILON.
  • A changelog entry is added under 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.
  • Against the base sources (SE2/SE3 without normalized), the test build fails with no method named normalized for 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

@jay23606
jay23606 requested a review from kmolan as a code owner December 2, 2026 01:52
@kmolan
kmolan merged commit e21eafc into kmolan:main Dec 2, 2026
16 checks passed
@jay23606
jay23606 deleted the pr-go/377-add-normalized-to-se2-and-se3 branch December 3, 2026 01:16
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.

Add normalized to SE2 and SE3

2 participants