robot_msgs

Image

data is (H, W) or (H, W, C) in the dtype encoding names; the dtype is kept as is.

Full docstring
Depth conventions follow ROS: 16UC1 is millimetres, 32FC1 is metres.
Import
from robot_msgs.sensor import Image
ROS 2sensor_msgs/msg/Image

Preview

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

Plot of an example Image

Fields

NameTypeDefault
dataArrayrequired
encodingstrrequired
headerHeaderHeader()

Example

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

Image(data=uint8[48×64×3], encoding='rgb8', header=Header(stamp=1761600000.25, frame_id='camera_color_optical_frame'))
to_dict() as JSON
{
  "_type": "sensor/Image",
  "data": {
    "dtype": "|u1",
    "shape": [48, 64, 3],
    "data": [190, 247, 186, 149, 158, 191, 65, 42, 139, 169, 209, 225, 199, 36, 223, 245, "… 9200 more values"]
  },
  "encoding": "rgb8",
  "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_array(
    array: Array,
    encoding: str | None = None,
    header: Header | None = None,
) -> Image

Wrap an array. Without encoding, infer it where only one reading is sensible.

from_dict

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

No docstring.

Properties

Read-only views computed from the fields.

channels: int

No docstring.

height: int

No docstring.

step: int

Bytes per row, as in ROS.

width: int

No docstring.

Methods

Return new values; messages are never mutated.

crop(x_offset: int, y_offset: int, width: int, height: int) -> Image

The width×height window whose top-left pixel is (x_offset, y_offset).

to_rgb() -> Array

(H, W, 3) uint8 for display. Depth and 16-bit images are min-max normalised to grey.

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.

Uses

Types its fields refer to.

Header

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