Use a ROS 2 message type
Cerulion shipsnative_ros2_messages, generated from ROS 2 Jazzy .msg files. Import the type you need from its package module:
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.
sensor_msgs/Image, height and width are fixed, while encoding (a string) and data (a uint8[]) are variable:
| ROS 2 type | Rust type |
|---|---|
bool | bool |
uint8 / byte | u8 |
int32 | i32 |
uint32 | u32 |
float64 | f64 |
string | String |
T[] | Vec<T> |
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.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.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.Next steps
Define a node
Put these message types to work on node ports.
Message types
Every available package and type.