Skip to main content

Introduction

coScene typically requires messages to follow specific structures for proper visualization. Using the Foxglove Schema allows you to take full advantage of the platform's built-in visualization capabilities.

Supported Formats

If you have written custom messages, you can use Message Converter extensions to convert them into schemas supported by coScene.

Protobuf and JSON Schema Types

Copy the required .proto files or .json files directly into your project and publish data through the coScene WebSocket connection or record to MCAP files.

Note:

For Protobuf data, time values of type google.protobuf.Timestamp or google.protobuf.Duration will be represented with sec and nsec fields instead of seconds and nanos in User Scripts, Message Converters, and other parts of coScene to maintain consistency with time and duration types in other data formats.

You can also import JSON schemas through the @foxglove/schemas npm package:

import { CompressedImage } from '@foxglove/schemas/jsonschema';

We provide WebSocket libraries for real-time data (Python, JavaScript, C++), as well as MCAP writers for pre-recorded data files (Python, JavaScript, C++).

See the example blog post about recording your Protobuf data using the MCAP C++ writer: Recording Robocar Data with MCAP.

JSON Without Schema Type

MCAP supports writing JSON messages without specifying a schema type. To write JSON message data without a schema type, set the channel's message encoding to json and the schema type ID to 0. This indicates that the channel has no schema type. For details, see: https://mcap.dev/spec#channel-op0x04

ROS

Install the foxglove_msgs package:

sudo apt install ros-noetic-foxglove-msgs # For ROS 1
sudo apt install ros-galactic-foxglove-msgs # For ROS 2

Then, import the required schemas in your ROS project to start publishing data:

from foxglove_msgs.msg import Vector2

msg = Vector2()
msg.x = 0.5
msg.y = 0.7

TypeScript

Import coScene message schemas as TypeScript types for type checking.

In coScene's User Script Panel, you can specify the required schema type using Message<"foxglove.[SchemaName]">:

import { Input, Message } from './types';

type Output = Message<'foxglove.Point2'>;

export const inputs = ['/input/topic'];
export const output = '/studio_script/output_topic';

export default function script(event: Input<'/input/topic'>): Output {
return { x: 1, y: 2 };
}

For your own TypeScript projects, you can import types directly from the @foxglove/schemas npm package:

import { Point2 } from '@foxglove/schemas';
const myPoint: Point2 = { x: 1, y: 2 };

Import these types when working with JavaScript WebSocket or MCAP projects, or when writing custom data transformation scripts in coScene's User Script Panel.