Skip to content

feat: Add Rotation * Pose and Pose * Rotation transformations - #127

Open
vamshidharre wants to merge 1 commit into
helsing-ai:mainfrom
vamshidharre:feat/pose-rotation-transforms
Open

vamshidharre wants to merge 1 commit into
helsing-ai:mainfrom
vamshidharre:feat/pose-rotation-transforms

Conversation

@vamshidharre

Copy link
Copy Markdown

Summary

In spatial applications, robotics, and aerospace navigation, transforming an object's pose across coordinate frames related by a pure rotation (such as NED to ENU, or body-axis rotations) is a common requirement.

Previously in sguaba::engineering, Pose<In> only implemented Mul with RigidBodyTransform, but not Rotation. Every other spatial primitive (Coordinate, Vector, Bearing, Orientation) supported multiplication with both Rotation and RigidBodyTransform. As a result, users wanting to transform a Pose using a Rotation were forced to either manually decompose and reconstruct the pose (Pose::new(pose.position() * rot, pose.orientation() * rot)) or wrap the rotation in an unsafe RigidBodyTransform::new.

This PR completes the algebra:

  1. Pose and Rotation Transformation Operators:
    • Implemented Mul<Rotation<From, To>> for Pose<From> (Pose * Rotation -> Pose<To>).
    • Implemented Mul<Pose<To>> for Rotation<From, To> (Rotation * Pose -> Pose<From>).
    • Automatically enables Rotation::transform(pose) and Rotation::inverse_transform(pose) via existing Mul bounds.
  2. Pose::origin() & Pose::aligned():
    • Added Pose::origin() and Pose::aligned() constructors returning an object at Coordinate::origin() with Orientation::aligned(), matching Coordinate::origin() and Orientation::aligned().
  3. AbsDiffEq & RelativeEq for Orientation and Pose:
    • Implemented approx::{AbsDiffEq, RelativeEq} for Orientation<In> and Pose<In> under #[cfg(any(test, feature = "approx"))], delegating directly to their underlying Rotation and RigidBodyTransform representations. This brings complete uniformity with Coordinate, Vector, Rotation, and RigidBodyTransform.
  4. Comprehensive Test Suite:
    • Added pose_rotation_transform_round_trip verifying NED <-> ENU transformations.
    • Added parameterized pose_arbitrary_rotation_round_trip across arbitrary 3D Tait-Bryan rotations, verifying invariance of distance_from_origin(), component-wise identity, and round-trip consistency.

Verification

  • cargo test --all-targets passed (248 tests).
  • cargo test --doc passed (48 doctests + 16 compile-fail tests).
  • cargo clippy --all-features passed with zero warnings.
  • cargo check --no-default-features --features libm passed (#![no_std] compatibility).
  • cargo fmt -- --check clean.

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.

1 participant