Skip to main content

Grid

A 2D grid of data

Panel support

Grid is used in the 3D and Image panels.

Schema

fieldtypedescription
timestampTimestampTimestamp of grid
frame_idstringFrame of reference
posePoseOrigin of grid's corner relative to frame of reference; grid is positioned in the x-y plane relative to this origin
column_countuint32Number of grid columns
cell_sizeVector2Size of single grid cell along x and y axes, relative to pose
row_strideuint32Number of bytes between rows in data
cell_strideuint32Number of bytes between cells within a row in data
fieldsPackedElementField[]Fields in data. red, green, blue, and alpha are optional for customizing the grid's color.
databytesGrid 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 value
  • green - Green channel value
  • blue - Blue channel value
  • alpha - 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:

encodingschema
ROS 1foxglove_msgs/Grid
ROS 2foxglove_msgs/msg/Grid
JSONfoxglove.Grid
Protobuffoxglove.Grid
FlatBuffersfoxglove.Grid
OMG IDLfoxglove::Grid

You must use the schema names specified above for Foxglove to recognize the schema.