Fix mesh-upload TypeError: MeshTriangle.vertex_indices needs a plain ndarray - #133
Open
grahas wants to merge 1 commit into
Open
Fix mesh-upload TypeError: MeshTriangle.vertex_indices needs a plain ndarray#133grahas wants to merge 1 commit into
grahas wants to merge 1 commit into
Conversation
…ndarray trimesh loads faces as a TrackedArray (an ndarray subclass) of int64 by default. shape_msgs/MeshTriangle's generated setter requires vertex_indices to be exactly numpy.ndarray (a strict type-name check in the rosidl C extension, not just dtype) -- found by actually running this against a real STL (add_workspace_scene.py in the parol6_dispenser repo). .astype() preserves the TrackedArray subclass by default, which still fails that check even with the right dtype; np.array(..., dtype=..., subok=False) is needed to get a plain ndarray. Was sitting as an uncommitted local diff with zero version control -- anyone cloning upstream pymoveit2 fresh would hit this exact failure. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
add_collision_mesh-style calls that buildshape_msgs/MeshTrianglefrom atrimesh.Trimesh's.facesraise aTypeErrorat message-fill time.trimesh'smesh.facesis aTrackedArray(anumpy.ndarraysubclass used for change-tracking) rather than a plainnumpy.ndarray, and ROS 2's generated message code does a stricttype(x) is numpy.ndarraycheck onvertex_indices— a subclass instance fails it even thoughisinstancewould pass.Fix
Build
vertex_indicesvianp.array(face, dtype=np.uint32, subok=False)instead of passingfacestraight through —subok=Falseforces a plainndarray, discarding theTrackedArraysubclass wrapper.Testing
Verified against a real mesh (
add_workspace_scene-style collision object upload) that previously raised theTypeErroron every call — now uploads successfully to a runningmove_group.