Announcing Message Converter Extensions in Foxglove Studio

Use message converters to visualize your custom messages
Esther WeonEsther Weon ·
5 min read
Published

Foxglove Studio offers a suite of data visualization panels to help you debug your robotics data, but many of these panels require data in a specific format.

With our newly released message converter extensions, you can visualize custom messages in Studio's built-in panels – even when these messages don't adhere to the panels' supported schemas.

When to use message converters

Before Foxglove Studio 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 Studio 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 Studio’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;
};

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

This will create a myGpsConverter directory with some template source code for a message converter extension.

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
    },
  });
}

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,
      };
    },

Test the extension

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

$ yarn local-install

In the Studio desktop app, open the Extensions tab in the app sidebar – you'll now 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

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

Share your feedback

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

As we continue building out extension support, we’d love to hear your feedback. Join the conversation in our Slack community or on Twitter, or check out our GitHub to file feature requests.


Read more:

Visualizing Point Clouds with Custom Colors
tutorial
ROS
studio
Visualizing Point Clouds with Custom Colors

Use Foxglove Studio’s new color modes to customize your point clouds.

Esther WeonEsther WeonEsther Weon
Jacob Bandes-StorchJacob Bandes-StorchJacob Bandes-Storch
11 min read
How to Use ROS 1 Launch Files
tutorial
ROS
How to Use ROS 1 Launch Files

Executing and configuring multiple ROS 1 nodes at once.

José L. MillánJosé L. MillánJosé L. Millán
9 min read

Get blog posts sent directly to your inbox.

Ready to get started?Download today on Linux, Windows, or macOS.