# Simulation-Gazebo Reference

{% hint style="info" %}
The `simulation-gazebo` package depends on either Gazebo Garden or Gazebo Harmonic. With AOS 4.1.x and higher it is required to install Gazebo Harmonic. For AOS 3.x.y use Gazebo Garden.
{% endhint %}

**simulation-gazebo** acts as a wrapper for default Gazebo Sim. It sets several environmental variables that are required to create a network connection between Gazebo and the Virtual FMU app.

## Installation

If you haven't already installed Gazebo Sim, you'll need to add its GPG key before installing **simulation-gazebo**, as simulation-gazebo depends on Gazebo Sim:

```
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
```

You're then ready to install **simulation-gazebo**:

```
sudo apt update
sudo apt install simulation-gazebo
```

{% hint style="info" %}
In case the Gazebo Sim GPG key address changes and `apt` has trouble finding dependencies, refer to the official Gazebo Sim documentation: <https://gazebosim.org/docs/garden/install_ubuntu>
{% endhint %}

## Usage

After installing the package, **simulation-gazebo** can be launched by executing the following command:

```
simulation-gazebo --world baylands
```

{% hint style="info" %}
If you encounter an error `QSocketNotifier: Can only be used with threads started with QThread`when launching **simulation-gazebo** with the simulation window crashing, you need to first export the following in your terminal: `export QT_QPA_PLATFORM=xcb` (to permanently apply this to any newly opened terminal add the line to your `/home/<user>/.bashrc` file)
{% endhint %}

When intending to run custom vehicle models or simulation worlds, you have to ensure that Gazebo can find them. Since worlds also need to be accessible to PX4, it is necessary to place worlds in the `~/.simulation-gazebo/worlds` directory. For models, you can use the `--model_store` flag to point simulation-gazebo to the correct directory location.

The open-source PX4 Autopilot provides several example worlds [here](https://github.com/PX4/PX4-gazebo-models/tree/6b4ed09d1b495fbff663f098979cc046df013abd/worlds).

{% hint style="warning" %}
If you provide a custom `--model_store` path, ensure that it ends in a `/models` directory. For instance, the default `model_store` is set to `~/.simulation-gazebo/models`
{% endhint %}

### Available Launch Flags

{% hint style="info" %}
All flags mentioned below are optional.
{% endhint %}

Below is a list of all currently supported flags for simulation-gazebo package:

<table><thead><tr><th width="255">Flag</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>--world</code></td><td><pre><code>default
</code></pre></td><td>A string variable that leads to the sdf file which runs the simulation world. This is a required argument</td></tr><tr><td><code>--gz_partition</code></td><td><code>virtual_skynode_relay</code></td><td>A string variable that sets the gazebo partition to run in</td></tr><tr><td><code>--gz_ip</code></td><td><code>10.41.200.1</code></td><td>A string variable that sets the IP of the outgoing network interface</td></tr><tr><td><code>--gz_headless</code> , <code>-s</code></td><td><code>false</code></td><td></td></tr><tr><td><code>--interactive</code></td><td><code>false</code></td><td>A boolean variable that requires the ability to run the code in interactive mode, allowing for custom paths for <code>--model_download_source</code>. If this is not set, <code>--model_download_source</code> will only download from the default Github repo.</td></tr><tr><td><code>--model_download_source</code></td><td><pre><code>https://github.com/PX4/PX4-gazebo-models/archive/refs/heads/main.zip
</code></pre></td><td>A string variable setting the path to a directory from where models are to be imported. At the moment this can only be a local file directory or a http address. The source should end with the zipped model file. (e.g. <a href="https://path/to/simulation/models/models.zip">https://path/to/simulation/models/models.zip</a>)</td></tr><tr><td><code>--model_store</code></td><td><pre><code>~/.simulation-gazebo
</code></pre></td><td>A string variable setting the path to the model storage directory. This is where the zip file provided in <code>model_download_source</code> will be placed.</td></tr><tr><td><code>--overwrite</code></td><td><pre><code>False
</code></pre></td><td>A boolean variable providing the ability to overwrite existing directories with new data.</td></tr><tr><td><code>--dryrun</code></td><td><pre><code>False
</code></pre></td><td>A boolean variable that can be set when running test cases. It will not provide any interactivity and will not start Gazebo simulation.</td></tr><tr><td><code>--force_version</code> , <code>-f</code></td><td><code>None</code></td><td><p>Run gz sim with a forced version, e.g. <code>-f 7</code> to enforce gz-garden.</p><p>Will fail if specific version is not installed.</p></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.auterion.com/app-development/simulation/virtual-skynode/simulation-gazebo-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
