Skip to content

Accept a stacked (N, r, c) ndarray as a sequence of poses (SE3, SO3, SE2, SO2) - #243

Open
RoboX2020 wants to merge 5 commits into
rai-opensource:masterfrom
RoboX2020:prajval/feat/se3-ndarray-sequence
Open

RoboX2020 wants to merge 5 commits into
rai-opensource:masterfrom
RoboX2020:prajval/feat/se3-ndarray-sequence

Conversation

@RoboX2020

@RoboX2020 RoboX2020 commented Oct 10, 2026 •

Copy link
Copy Markdown

Closes #236.

SE3(arr) with an (N, 4, 4) array raised "bad argument to constructor", and with check=False it returned a malformed object (length 1, but .A of shape (N, 4, 4)).

Changes:

  • BasePoseList.arghandler: an ndarray with shape (N, r, c), where (r, c) is the shape of one value of the class, is now taken as N values, the same as SE3(list(arr)). Each matrix still goes through the class's validity check when check=True. This covers the matrix classes SE3, SO3, SE2 and SO2.
  • With check=False, single arrays keep their historical behavior; only a stacked 3D array whose per-matrix size is wrong is rejected, whatever check is.
  • The SE3 error message now lists the accepted forms, and the constructor docstring documents the new form.

Test: test_constructor_stacked_array covers SE3 and SO3 from a stacked array with both check values, the empty (0, 4, 4) case, rejection of invalid matrices with check=True and of a wrong-sized stack with either value. It fails on master and passes with this change.

Run locally (Python 3.11): pytest tests gives 348 passed, 3 skipped. black 23.10.0 is clean. Not run: the docs build and other Python versions.

Added support for stacked numpy arrays in baseposelist.py.
… error

Added support for SE3 constructor with (N, 4, 4) NumPy array.
Add unit test for SE3 constructor with stacked array input.

@taughz taughz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be a regression here with check=False. I've pushed some testing changes to your branch. Happy to re-review.

@taughz

taughz commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

@RoboX2020 Ping?

The shape guard added with the stacked-array support rejected every
array whose shape differed from the class's internal value shape when
check=False. That broke accepted equivalent forms: Twist3 from a 4x4
SE(3)/se(3) matrix, Twist2 from a 3x3 SE(2)/se(2) matrix, and
Quaternion from a non-4-vector array, all of which the class _import
methods deliberately accept unchecked.

Only reject when a matrix pose class (SE3, SO3, SE2, SO2) gets a 3D
array whose per-matrix size is wrong: such an array can only be read
as a stack, so the mismatch is never a valid pose, whatever check is.
Single 2D arrays keep their historical check=False behavior.
@RoboX2020

Copy link
Copy Markdown
Author

Fixed - the shape guard was too broad. With check=False it rejected single arrays in forms the constructors deliberately accept unchecked (Twist3 from a 4x4 SE(3)/se(3) matrix, Twist2 from a 3x3, Quaternion from a non-4-vector). Now only a stacked 3D array with the wrong per-matrix size is rejected, whatever check is. Your new tests pass along with the rest of the suite: 348 passed, 3 skipped. Ready for re-review.

This branch has not been deployed

No deployments
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.

Enhancement: SE3 constructor should accept an (N, 4, 4) ndarray as N poses

2 participants