robot_msgs

PointCloud

points is (N, 3) float32 in header.frame_id; each channel has leading dimension N.

Full docstring
Channels keep their own dtype: `rgb` (N, 3) uint8, `intensity` (N,), `normals` (N, 3) ...

WHY float32 points: half the memory of float64, and it is what PointCloud2 carries.
Import
from robot_msgs.sensor import PointCloud
ROS 2sensor_msgs/msg/PointCloud2

Preview

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

Plot of an example PointCloud

Fields

NameTypeDefault
pointsArrayrequired
channelsMapping[str, Array]{}
headerHeaderHeader()

Example

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

PointCloud(points=float32[100×3], channels={'rgb': uint8[100×3]}, header=Header(stamp=1761600000.25, frame_id='camera_color_optical_frame'))
to_dict() as JSON
{
  "_type": "sensor/PointCloud",
  "points": {
    "dtype": "<f4",
    "shape": [100, 3],
    "data": [0.9499886631965637, 0.591343343257904, 1.8206182718276978, 1.3160899877548218, -0.1465705782175064, 1.6935900449752808, 1.2241992950439453, -0.40974128246307373, 0.35544049739837646, 1.1388827562332153, 0.28662607073783875, 1.06144380569458, 0.44097617268562317, 0.7493008375167847, -0.2722027003765106, 0.4252520203590393, "… 284 more values"]
  },
  "channels": {
    "rgb": {
      "dtype": "|u1",
      "shape": [100, 3],
      "data": [248, 144, 15, 226, 89, 33, 204, 111, 83, 249, 230, 191, 40, 163, 158, 46, "… 284 more values"]
    }
  },
  "header": {
    "_type": "std/Header",
    "stamp": 1761600000.25,
    "frame_id": "camera_color_optical_frame",
    "meta": {}
  }
}

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

Functions

Constructors

Classmethods and staticmethods: ways to build one.

from_depth(
    depth: Image,
    camera_info: CameraInfo,
    rgb: Image | None = None,
) -> PointCloud

Back-project a depth image through the pinhole model, row-major pixel order.

from_dict

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

No docstring.

Methods

Return new values; messages are never mutated.

cropped(min_xyz: Array, max_xyz: Array) -> PointCloud

Points inside the axis-aligned box (edges included), channels filtered alike.

downsampled(voxel_size: float) -> PointCloud

One point per voxel_size cube: the first point (in cloud order) that falls in it.

transformed(transform: Transform) -> PointCloud

Rotate then translate the points. Channels are unchanged; set the new header.

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.

Uses

Types its fields refer to.

Header

robot_msgs 0.1.0 @ 2dc6666GitHub · MIT license · generated from the package, not written per type