Skip to content

Fix mesh-upload TypeError: MeshTriangle.vertex_indices needs a plain ndarray - #133

Open
grahas wants to merge 1 commit into
AndrejOrsula:mainfrom
grahas:main
Open

Fix mesh-upload TypeError: MeshTriangle.vertex_indices needs a plain ndarray#133
grahas wants to merge 1 commit into
AndrejOrsula:mainfrom
grahas:main

Conversation

@grahas

@grahas grahas commented Aug 8, 2026

Copy link
Copy Markdown

Summary

add_collision_mesh-style calls that build shape_msgs/MeshTriangle from a trimesh.Trimesh's .faces raise a TypeError at message-fill time. trimesh's mesh.faces is a TrackedArray (a numpy.ndarray subclass used for change-tracking) rather than a plain numpy.ndarray, and ROS 2's generated message code does a strict type(x) is numpy.ndarray check on vertex_indices — a subclass instance fails it even though isinstance would pass.

Fix

Build vertex_indices via np.array(face, dtype=np.uint32, subok=False) instead of passing face straight through — subok=False forces a plain ndarray, discarding the TrackedArray subclass wrapper.

Testing

Verified against a real mesh (add_workspace_scene-style collision object upload) that previously raised the TypeError on every call — now uploads successfully to a running move_group.

…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>
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