Announcing Message Converter Extensions in Foxglove

Use message converters to visualize your custom messages
Esther WeonEsther Weon ·
Jacob Bandes-StorchJacob Bandes-Storch ·
5 min read
Published
Announcing Message Converter Extensions in Foxglove

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

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.

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 desktop app, run the following command in the extension directory:

$ yarn local-install

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

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 Slack community or on Twitter.

This post was last edited on for accuracy.


Read more:

Implementing a macOS Search Plug-In for Robotics Data
article
visualization
MCAP
Implementing a macOS Search Plug-In for Robotics Data

How we built a Spotlight Importer for MCAP files using Swift

Jacob Bandes-StorchJacob Bandes-StorchJacob Bandes-Storch
18 min read
Visualizing Point Clouds with Custom Colors
tutorial
ROS
visualization
Visualizing Point Clouds with Custom Colors

Use Foxglove's new color modes to customize your point clouds

Esther WeonEsther WeonEsther Weon
Jacob Bandes-StorchJacob Bandes-StorchJacob Bandes-Storch
11 min read

Get blog posts sent directly to your inbox.

Ready to try Foxglove?

Get started for free