Skip to main content

Variables

Variables are values that can be set globally for a Foxglove layout. They’re prefixed with a $ for easy reference (e.g. $my_global_var) and can be set to any valid string, number, boolean, or undefined. It can also be set to an array containing any of those primitive values (e.g. ["x", 2, false]), or a map of strings to any of those primitive values (e.g. {"x": 2, "y": false}).

Open the sidebar's "Variables" tab to view, add, and update variables.

variables tab

Certain panels like the 3D and Variable Slider panels have built-in ways to update variable values with user interactions. Panels that support message path syntax – like Raw Messages, Plot, and State Transitions – can reference variables to dynamically decide what to visualize.

You can leverage variables to quickly switch between subsets of your data – for example:

  • Create a $my_ID variable in the Variables tab, and set its value to 101
  • Type /my_objects.objects[:]{id==$my_ID} in a Raw Messages panel to inspect the object whose id field equals 101
  • Add /my_objects.objects[:]{id==$my_ID}.velocity as a y-axis value in a Plot panel to plot that same object's velocity

Shortcuts

  • Click input + – Increment numeric variable values
  • Click input + – Decrement numeric variable values