Grid
A 2D grid of data
Panel support
Grid is used in the 3D and Image panels.
Schema
| field | type | description |
|---|---|---|
timestamp | Timestamp | Timestamp of grid |
frame_id | string | Frame of reference |
pose | Pose | Origin of grid's corner relative to frame of reference; grid is positioned in the x-y plane relative to this origin |
column_count | uint32 | Number of grid columns |
cell_size | Vector2 | Size of single grid cell along x and y axes, relative to pose |
row_stride | uint32 | Number of bytes between rows in data |
cell_stride | uint32 | Number of bytes between cells within a row in data |
fields | PackedElementField[] | Fields in data. red, green, blue, and alpha are optional for customizing the grid's color. |
data | bytes | Grid cell data, interpreted using fields, in row-major (y-major) order. |
fields
To enable RGB color visualization in the 3D panel, include all four of these fields in your fields array:
red- Red channel valuegreen- Green channel valueblue- Blue channel valuealpha- Alpha/transparency channel value
note: All four fields must be present with these exact names for RGB visualization to work. The order of fields doesn't matter, but the names must match exactly.
Recommended type: UINT8 (0-255 range) for standard 8-bit color channels.
Example field definitions:
RGB color only:
fields: [
{ name: "red", offset: 0, type: NumericType.UINT8 },
{ name: "green", offset: 1, type: NumericType.UINT8 },
{ name: "blue", offset: 2, type: NumericType.UINT8 },
{ name: "alpha", offset: 3, type: NumericType.UINT8 },
];
RGB color with elevation (for 3D terrain visualization):
fields: [
{ name: "red", offset: 0, type: NumericType.UINT8 },
{ name: "green", offset: 1, type: NumericType.UINT8 },
{ name: "blue", offset: 2, type: NumericType.UINT8 },
{ name: "alpha", offset: 3, type: NumericType.UINT8 },
{ name: "elevation", offset: 4, type: NumericType.FLOAT32 },
];
When these fields are present, the 3D panel will offer additional "Color Mode" options including "RGBA (separate fields)" to visualize the RGB data directly. For elevation visualization, set the "Elevation field" to your elevation layer name.
data
For the data element starting at byte offset i, the coordinates of its corner closest to the origin will be:
- y = i / row_stride * cell_size.y
- x = (i % row_stride) / cell_stride * cell_size.x
Reference implementations
Foxglove schemas are framework-agnostic, and can be implemented using any supported message encoding:
| encoding | schema |
|---|---|
| ROS 1 | foxglove_msgs/Grid |
| ROS 2 | foxglove_msgs/msg/Grid |
| JSON | foxglove.Grid |
| Protobuf | foxglove.Grid |
| FlatBuffers | foxglove.Grid |
| OMG IDL | foxglove::Grid |
You must use the schema names specified above for Foxglove to recognize the schema.