Skip to main content
Every node port carries a typed message. This guide shows how to use the built-in ROS 2 message types, how fixed and variable fields differ when you write them, and how to define your own workspace schema. For the full type list and reference details, see the message types reference and graph and schema files reference.

Use a ROS 2 message type

Cerulion ships native_ros2_messages, generated from ROS 2 Jazzy .msg files. Import the type you need from its package module:
Reference a type as a port by giving it a field on the node struct:
In a graph, schemas are written with a slash (sensor_msgs/Image). The colon form sensor_msgs::Image is also accepted and normalized to the slash form.

Fixed vs variable fields

How you write a message field depends on its size:
  • Fixed primitive fields (numbers, bytes, for example height, width, is_bigendian) live in a fixed section and are written directly. The macro derefs to that section and writes straight to shared memory.
  • Variable-length fields (string, T[], nested types) have no fixed size, so the macro routes them through a generated setter. You must list each one in the #[output(...)] attribute.
For sensor_msgs/Image, height and width are fixed, while encoding (a string) and data (a uint8[]) are variable:
A variable field that is not listed in #[output(...)] cannot be written through self.<port>.<field>. List simple variable fields by name (#[output(data, encoding)]), and nested-typed fields with the complex(...) form, for example #[output(data, complex(header))].
The ROS 2 primitive types map to Rust as follows (a representative subset):

Define a custom schema

When no built-in type fits, define a workspace schema.

Create the schema file

cerulion schema create <name> writes schemas/<PascalName>.yaml with a skeleton.
The generated schemas/Reading.yaml:

Add fields

Edit schemas/Reading.yaml to declare fields as type name. Use ROS 2 primitive types; T[] marks a variable-length array.

Inspect it

cerulion schema info <name> reports the name, description, field count, and a hash.
schema info first tries a ROS 2 .msg lookup for qualified names like sensor_msgs::Image, printing fields, Rust types, and the minimum wire size. If no .msg is found, it falls back to the workspace YAML schema and prints the description, fields, and FNV-1a hash shown above.
Delete a schema you no longer need:

Next steps

Define a node

Put these message types to work on node ports.

Message types

Every available package and type.