Gazebo Sim's graphical user interface is powered by Gazebo GUI. Therefore, Gazebo Sim's GUI layout can be defined in Gazebo GUI configuration files. These are XML files that describe what plugins to be loaded and with what settings.
How to load different GUI configurations
There are a few places where the GUI configuration can come from:
- A file passed to the
--gui-config
command line argument - A
<gui>
element inside an SDF file - The default configuration file at
$HOME/.gz/sim/<#>/gui.config
*, where<#>
is Gazebo Sim's major version.
If a configuration file is specified using --gui-config
, Gazebo will ignore both the <gui>
element inside the SDF file and the default configuration file. Otherwise, Gazebo will load plugins by combining plugins in the <gui>
element and the default configuration file. How Gazebo combines these plugins is determined by the <include_gui_default_plugins>
policy set in <gz:policies>
:
<include_gui_default_plugins>true</include_gui_default_plugins>
: Plugins from the default configuration file merged with plugins from the SDF file. Plugins from SDF files take precedence over plugins from the default configuration file. This means, if a plugin is specified in both places, by default, only the one specified in the SDF file will be loaded. If replacement occurs, the replacement plugin will take the position of the replaced plugin in the order of plugins. If replacement does not occur, the plugin is appended to the end of the list.The main use case for this policy is for users to rely on the default list of plugins and only add extra plugins they need for the application. This policy is also useful for overriding the parameters of a small subset of the default plugins. This is the default setting in Gazebo Ionic and later.
<include_gui_default_plugins>false</include_gui_default_plugins>
: If there are any plugins specified in the SDF file, plugins from the default configuration file are ignored. This allows the user to have complete control over which plugins are loaded. This is the default setting in Gazebo Harmonic and earlier.
* For log-playback, the default file is
$HOME/.gz/sim/<#>/playback_gui.config
Try it out
Default configuration
Let's try this in practice. First, let's open the default Gazebo world:
gz sim default.sdf
You should see an empty world with several plugins loaded by default, such as the 3D Scene, the play/pause button, etc.
By default, you're loading this file:
$HOME/.gz/sim/<#>/gui.config
That file is created the first time you load Gazebo. Once it is created, Gazebo will never write to it again unless you delete it. This means that you can customize it with your preferences and they will be applied every time Gazebo is started!
Let's try customizing it:
Open this file with your favorite editor:
$HOME/.gz/sim/<#>/gui.config
- Change
material_theme
fromLight
toDark
Reload Gazebo:
gz sim default.sdf
Note how the UI is now in dark mode!
You'll often want to restore default settings or to use the latest default provided by Gazebo (when you update to a newer version for example). In that case, just delete that file, and the next time Gazebo is started a new file will be created with default values:
rm $HOME/.gz/sim/<#>/gui.config
SDF
Let's try overriding the default configuration from an SDF file. Open your favorite editor and save this file as fuel_preview.sdf
:
Now let's load this world:
gz sim <path to>/fuel_preview.sdf
Notice how the application has only 3 GUI plugins loaded, as defined on the SDF file above.
If you delete the <gui>
element from the file above and reload it, you'll see the same model loaded into the default GUI layout.
Now, let's change the policy so that default plugins are included
You will now see the same model loaded in the default GUI layout similar to when you deleted the <gui>
element altogether. Note that this will also be the behavior if we removed <include_gui_default_plugins>
tag.
Command line
It's often inconvenient to embed your GUI layout directly into every SDF file. But you also don't want to be editing the default config file every time you want to start with a different layout. That's why Gazebo also supports loading configuration files from the command line.
Let's start by creating a custom configuration file, but instead of editing by hand, we'll create it from the UI.
Let's start loading the SDF world we created above, with the
<gui>
element back:gz sim <path to>/fuel_preview.sdf
- Now from the top-right menu, choose to add the "View Angle" plugin. This plugin has convenient buttons to change the camera angle, try them out!
- Undock the inserted plugin by clicking on the □ button on top of it.
- Now that the plugin is floating, drag it to any place you want.
- Finally, let's save our configuration by going to the top-left menu and choosing "Save client configuration as".
- Save the file at a path of your choice, and name it
saved.config
. - Close Gazebo
- Take a look at the saved file if you're curious, it will look a lot like the default file, but with more properties defined.
Finally, let's load the previous world, with our custom configuration:
gz sim <path to>/fuel_preview.sdf --gui-config <path to>saved.config
- Gazebo should open with your custom layout.
Tip: From the top-left menu, you can choose "Save client configuration" to save directly to $HOME/.gz/sim/<#>/gui.config
.