robot_msgs

Mesh

vertices is (N, 3) float64 metres; triangles is (M, 3) int32 vertex indices (ROS's MeshTriangle.vertex_indices), counter-clockwise seen from outside.

Full docstring
The volume, centroid and inertia methods read the mesh as a solid, so they are exact for a
closed mesh whose triangles face outward and meaningless for an open one.
Import
from robot_msgs.shape import Mesh
ROS 2shape_msgs/msg/Mesh

Preview

The figure robot_msgs.viz.plot(example) draws for the example below.

Plot of an example Mesh

Fields

NameTypeDefault
verticesArrayrequired
trianglesArrayrequired

Example

One instance from the package's own test catalog; the output is its real repr().

Mesh(vertices=float64[14×3], triangles=int32[24×3])
to_dict() as JSON
{
  "_type": "shape/Mesh",
  "vertices": {
    "dtype": "<f8",
    "shape": [14, 3],
    "data": [0.2, 0.0, -0.25, 0.17320508075688776, 0.09999999999999999, -0.25, 0.10000000000000003, 0.17320508075688773, -0.25, 1.2246467991473533e-17, 0.2, -0.25, -0.09999999999999996, 0.17320508075688776, -0.25, -0.17320508075688776, "… 26 more values"]
  },
  "triangles": {
    "dtype": "<i4",
    "shape": [24, 3],
    "data": [0, 1, 12, 13, 1, 0, 1, 2, 12, 13, 2, 1, 2, 3, 12, 13, "… 56 more values"]
  }
}

Long arrays are cut after 16 values and say so with “…”.

Functions

Constructors

Classmethods and staticmethods: ways to build one.

from_dict

from Msg
from_dict(data: Mapping[str, Any]) -> M

No docstring.

Methods

Return new values; messages are never mutated.

bounding_box() -> tuple[Point, Point]

(min, max) corners of the axis-aligned box around the vertices.

centroid() -> Point

Centre of volume of the solid (see volume for what the mesh must be).

inertia(mass: float) -> Inertia

Inertia of the solid at uniform density, about its centroid (which is com).

transformed(pose: Pose) -> Mesh

The mesh moved rigidly: every vertex rotated by pose.orientation, then shifted.

volume() -> float

Signed volume (m³) by the divergence theorem: positive when the triangles face

replace

from Msg
replace(**changes: Any) -> M

A copy with some fields changed. Validation runs again.

to_dict

from Msg
to_dict() -> dict[str, Any]

JSON-safe dict with a "_type" key; arrays keep their dtype and shape.

Operators

Python operators and protocols the type supports.

__len__() -> int

No docstring.

No other type refers to it, and it refers to none.

robot_msgs 0.2.0 @ 22ec67fGitHub · MIT license · generated from the package, not written per type