robot_msgs

SolidPrimitive

type is one of the ROS constants below and dimensions follows ROS's index layout:

Full docstring
=========  =============================  ==========================================
type       dimensions                     origin
=========  =============================  ==========================================
BOX        x, y, z extents                centre
SPHERE     radius                         centre
CYLINDER   height, radius                 centre, axis along z
CONE       height, radius                 bounding-box centre, base down, apex up
PRISM      height                         `polygon` extruded along z, centred on z=0
=========  =============================  ==========================================

WHY the cone's origin is the middle of its height, not its base or centroid: ROS defines every
primitive with its bounding box centred on the origin. The base is at ``z = -h/2``, the apex
at ``+h/2`` and the centroid at ``-h/4``; `inertia` reports that offset as `com`.

`polygon` is ``(N, 2)`` metres in the xy plane, for PRISM only: a simple polygon (no crossing
edges), either winding. ROS's Polygon holds Point32s whose z is not used here.

Build one with `box`, `sphere`, `cylinder`, `cone` or `prism`; read it with `size`, `radius`
and `height`.
Import
from robot_msgs.shape import SolidPrimitive
ROS 2shape_msgs/msg/SolidPrimitive

Preview

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

Plot of an example SolidPrimitive

Fields

NameTypeDefault
typeintrequired
dimensionsArrayrequired
polygonArray | NoneNone

Example

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

SolidPrimitive(type=1, dimensions=[0.3, 0.2, 0.5])
to_dict() as JSON
{
  "_type": "shape/SolidPrimitive",
  "type": 1,
  "dimensions": {
    "dtype": "<f8",
    "shape": [3],
    "data": [0.3, 0.2, 0.5]
  },
  "polygon": null
}

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

Functions

Constructors

Classmethods and staticmethods: ways to build one.

box(x: float, y: float, z: float) -> SolidPrimitive

A box with extents x, y, z (m) along its own axes, centred on the origin.

cone(height: float, radius: float) -> SolidPrimitive

Base (radius radius) at z = -height/2, apex at z = +height/2.

cylinder(height: float, radius: float) -> SolidPrimitive

Axis along z, centred on the origin (ROS and URDF).

prism(height: float, polygon: Any) -> SolidPrimitive

polygon (N, 2) extruded from z = -height/2 to +height/2.

sphere(radius: float) -> SolidPrimitive

No docstring.

from_dict

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

No docstring.

Properties

Read-only views computed from the fields.

height: float

Height of a CYLINDER, CONE or PRISM.

radius: float

Radius of a SPHERE, CYLINDER or CONE.

size: Vector3

x, y, z extents of a BOX.

Methods

Return new values; messages are never mutated.

bounding_box() -> tuple[Point, Point]

(min, max) corners of the axis-aligned box around the primitive, in its own frame.

centroid() -> Point

Centre of volume, in the primitive's frame: the origin, except a cone's (z = -h/4,

contains(points: Any) -> Any

Whether each point (in the primitive's frame) is inside; the surface counts as inside.

inertia(mass: float) -> Inertia

Inertia of the uniform solid, about its centroid, axes parallel to the primitive's

to_mesh(resolution: int = 32) -> Mesh

A closed, outward-facing triangle mesh with vertices on the surface (so it is inscribed

volume() -> float

Exact volume (m³).

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.

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