robot_msgs

ColorRGBA

Red, green, blue and alpha, each a float in 0..1 (alpha 1 is opaque).

Full docstring
`from_hex` / `to_hex` read and write ``#rrggbb`` and ``#rrggbbaa`` (8 bits a channel).
std_msgs/ColorRGBA is float32, so a ROS round trip keeps 8-bit colours exactly but not
arbitrary float64 values.
Import
from robot_msgs.std import ColorRGBA
ROS 2std_msgs/msg/ColorRGBA

Preview

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

Plot of an example ColorRGBA

Fields

NameTypeDefault
rfloat0.0
gfloat0.0
bfloat0.0
afloat1.0

Example

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

ColorRGBA(r=0.5, g=0.25, b=0.75, a=1.0)
to_dict() as JSON
{
  "_type": "std/ColorRGBA",
  "r": 0.5,
  "g": 0.25,
  "b": 0.75,
  "a": 1.0
}

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

Functions

Constructors

Classmethods and staticmethods: ways to build one.

from_array(array: Any) -> ColorRGBA

No docstring.

from_hex(text: str) -> ColorRGBA

#rrggbb, #rrggbbaa or the CSS shorthand #rgb; the # is optional.

from_dict

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

No docstring.

Methods

Return new values; messages are never mutated.

as_array() -> np.ndarray

(4,) = r g b a.

to_hex(alpha: bool | None = None) -> str

#rrggbb, plus the alpha pair when alpha is true or (by default) when not opaque.

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