Add viam.spatialmath: FFI bindings for rust-utils orientation math#1233
Open
Nick Hehr (HipsterBrown) wants to merge 15 commits into
Open
Add viam.spatialmath: FFI bindings for rust-utils orientation math#1233Nick Hehr (HipsterBrown) wants to merge 15 commits into
Nick Hehr (HipsterBrown) wants to merge 15 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RotationMatrix now exposes the rdk rotation-matrix convention (the nalgebra column-major storage read directly), and AxisAngle returns the canonical (0,0,1) axis for zero rotation. Adds the golden-vector parity test asserting all conversions match Go rdk/spatialmath. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ridges Viam Pose/Orientation protos express theta in degrees, while the spatialmath classes are radians-native (matching the FFI and Go rdk). The proto bridges now convert at the boundary instead of passing degrees through as radians. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
Ethan (@stuqdog) I've removed that Go module responsible for generating the |
Ethan (stuqdog)
approved these changes
Jun 23, 2026
Ethan (stuqdog)
left a comment
Member
There was a problem hiding this comment.
Didn't personally test everything but given that tests are passing, assuming golden.json came from RDK this all seems good to me!
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.
Summary
Adds a new
viam.spatialmathpackage: Pythonic, object-oriented wrappers over the sharedrust-utils(libviam_rust_utils) spatial-math FFI, exposing orientation conversions whose results match Gordk/spatialmath.Quaternion,Vector3,OrientationVector,EulerAngles,AxisAngle,RotationMatrix— each owning an opaque FFI handle freed deterministically viaweakref.finalize, with conversions between every representation.viam.proto.common—OrientationVector/Vector3from_proto/to_protoandQuaternion.from_pose/to_pose. Classes are radians-native; the proto bridges convert to/from the Viam protos' degrees convention at the boundary.libviam_rust_utilsctypes loading fromrpc/dial.pyintoviam/_native.pyso both the dialer and spatialmath load one cachedCDLL.libviam_rust_utils, and hatchling already bundles the lib and picks up the new sub-package.Conventions (matched to Go
rdk/spatialmath)RotationMatrix.elementsis row-major, matching rdk's convention.AxisAnglereturns the canonical axis(0, 0, 1), matching rdk.Test Plan
tests/spatialmath/fixtures/golden.jsonis generated from canonical Gordk/spatialmath(generator inetc/spatialmath_golden/); a parametrized test asserts all conversions (orientation-vector, Euler, axis-angle, rotation-matrix) match within1e-9across identity / 90°-X / 180°-Y / tumble cases.ValueError.ruff checkandpyrightclean on the new modules;dial.pyrefactor verified against existing dial tests.🤖 Generated with Claude Code