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`.
Preview
The figure robot_msgs.viz.plot(example) draws for the example below.

Fields
| Name | Type | Default |
|---|---|---|
type | int | required |
dimensions | Array | required |
polygon | Array | None | None |
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) -> SolidPrimitiveA box with extents x, y, z (m) along its own axes, centred on the origin.
cone(height: float, radius: float) -> SolidPrimitiveBase (radius radius) at z = -height/2, apex at z = +height/2.
cylinder(height: float, radius: float) -> SolidPrimitiveAxis along z, centred on the origin (ROS and URDF).
prism(height: float, polygon: Any) -> SolidPrimitivepolygon (N, 2) extruded from z = -height/2 to +height/2.
Properties
Read-only views computed from the fields.
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() -> PointCentre of volume, in the primitive's frame: the origin, except a cone's (z = -h/4,
contains(points: Any) -> AnyWhether each point (in the primitive's frame) is inside; the surface counts as inside.
inertia(mass: float) -> InertiaInertia of the uniform solid, about its centroid, axes parallel to the primitive's
to_mesh(resolution: int = 32) -> MeshA closed, outward-facing triangle mesh with vertices on the surface (so it is inscribed
to_dict
from Msgto_dict() -> dict[str, Any]JSON-safe dict with a "_type" key; arrays keep their dtype and shape.
Related types
No other type refers to it, and it refers to none.