tutorial
ROS
visualization

Announcing Message Converter Extensions in Foxglove

Use message converters to visualize your custom messages

tutorial
ROS
visualization

Foxglove offers a suite of Visualization Panels, but many require data in a specific format.

With our newly released Message Converter Extensions, you can visualize custom messages in Foxglove's built-in panels – even when these messages don't adhere to the Panels' supported schemas.

When to use Message Converters

Before Foxglove v1.33, visualizing your custom robotics data with non-standard message types required building entirely new custom panels. While building a panel from scratch tailored to your unique message schemas and visualization needs is infinitely flexible, this route requires a significant amount of work.

With the release of Message Converter Extensions, this process becomes much easier. Instead of building your own panel, you can visualize your team’s proprietary data by leveraging the powerful visualizations Foxglove offers in built-in panels.

Some example uses of Message Converters are visualizing a robot planning path within the 3D Panel, building 3D scenes from perception output, or plotting custom GPS messages in the Map Panel.

Building a message converter extension

For the purpose of this tutorial, let’s assume that we have custom GPS messages that we want to plot in Foxglove’s Map Panel (download example MCAP file here). However, we have one small problem – the panel only supports foxglove.LocationFix messages, whereas our data uses our custom sensors.MyGps schema:

type MyGps = {
 lat: number;
 lon: number;
};

language-typescript

Instead of creating an entirely new panel to handle your custom messages, let’s write a Message Converter that transforms them into already-supported foxglove.LocationFix messages, so that they can be visualized in the existing Map Panel.

Set up your extension directory

Use create-foxglove-extension to generate our extension directory:

$ npm init foxglove-extension@latest myGpsConverter

language-bash

This will create a myGpsConverter directory with some template source code.

Write the converter

The index.ts file in your project's src folder is the entry point for your extension source code. It exports an activate function that accepts a single extensionContext argument of type ExtensionContext.

To register a Message Converter, we call registerMessageConverter on the extensionContext argument with three arguments: the source schema name (sensors.MyGps), the destination schema name (foxglove.LocationFix), and the converter function that will do the transformation:

export function activate(extensionContext: ExtensionContext) {
 extensionContext.registerMessageConverter({
   fromSchemaName: "sensors.MyGps",
   toSchemaName: "foxglove.LocationFix",
   converter: (inputMessage) => {
     // logic to turn sensors.MyGps messages into foxglove.LocationFix messages
   },
 });
}

language-typescript

Fill out the converter function to re-map our sensors.MyGps messages’ lat and lon fields to the foxglove.LocationFix schema’s latitude and longitude fields:

   converter: (inputMessage: MyGps) => {
     return {
       latitude: inputMessage.lat,
       longitude: inputMessage.lon,
     };
   },

language-typescript

Test the extension

To build and install your extension for local testing in the Foxglove desktop app, run the following command in the extension directory:

$ yarn local-install

language-bash

In the Foxglove desktop app, open your app settings to see myGpsConverter appear in the list of installed extensions.

Connect to your data source, and add a Map Panel to the layout. You should now see your custom GPS messages visualized on the map!

Map panel

Release your extension

Once you are happy with how your extension works, you can package it and share it with your team using the foxglove CLI tool. This will deploy the extension to all users within your organization.

$ yarn package
$ foxglove extensions publish ./my-extension.1.0.0.foxe

language-bash

Check out our documentation to learn more about sharing with your team.

Share your feedback

Read the extensions documentation for more details on Foxglove's extension API.

As we continue building out extension support, we’d love to hear your feedback. Join the conversation in our Discord community or on Twitter.

Read more

Start building with Foxglove.

Get started for free