# Virtual Skynode

The Virtual Skynode allows you to fully simulate a Skynode device running AuterionOS. With Virtual Skynode you get all the benefits of a physical Skynode during app development. For example:

* Virtual Skynode offers the same APIs for installing and managing apps as a physical Skynode
* The MAVLink communication inside Virtual Skynode is set up identically to a physical Skynode
* Apps do not need to be aware that they are being installed in a Virtual Skynode. This significantly simplifies the build workflow of apps
* Virtual Skynode's simulated hardware closely resembles a real device when it comes to number of CPU cores, amount of system memory, file system partitioning and size etc.

## Getting started

Virtual Skynode requires two components:

1. virtual-skynode launcher package installed through your operating system's package manager
2. virtual-skynode's AuterionOS image which can be found on [Suite](https://suite.auterion.com)

The installation of both components is explained in the following section.

### Installation

In order to use the Virtual Skynode, the launcher has to be installed on the developer machine first.

{% tabs %}
{% tab title="Linux" %}
The following instructions were tested on Ubuntu 22.04:

Verify that your system supports Kernel-based Virtual Machine (KVM) by running:

```
sudo apt install cpu-checker
sudo kvm-ok
```

If this check does not return positively, CPU virtualization is most likely disabled in the BIOS. Virtual Skynode can be used without KVM, but this comes with a heavy performance penalty as the Virtual Skynode CPU will then be fully emulated in software.

Add the public Auterion debian package repository to apt:

```
curl -1sLf 'https://dl.cloudsmith.io/public/auterion/public/setup.deb.sh'| sudo -E bash
```

Install the Virtual Skynode:

```
sudo apt update
sudo apt install virtual-skynode
```

{% endtab %}

{% tab title="Mac" %}
If you are working on a Mac:

```
brew tap Auterion/auterion
brew install virtual-skynode
```

{% endtab %}
{% endtabs %}

### Downloading the AuterionOS image for Virtual Skynode

To run Virtual Skynode, you have to first download **AuterionOS for Virtual Skynode** from the under **Store** > **Developer** tab on [**Auterion Suite**](https://suite.auterion.com/)&#x20;

<figure><img src="/files/t8nd8zOny0sawQJjmhRF" alt=""><figcaption><p>Place where in the Auterion Suite the AuterionOS image for Virtual Skynode can be found</p></figcaption></figure>

{% hint style="info" %}
You have to be part the Skynode Developer program to obtain AuterionOS for Virtual Skynode
{% endhint %}

### Launching the Virtual Skynode

Ensure that you are currently in the directory that contains the downloaded AuterionOS rootfs and run (replace `<VERSION-NUMBER>`):

```
virtual-skynode run --rootfs virtual-skynode-<VERSION-NUMBER>.qcow2 --storage ~/.virtual-skynode --guest-ip 10.41.200.2
```

Running this command will launch the Virtual Skynode using the downloaded version of AuterionOS. It will also (if not already present) create a storage repo in `~/.virtual-skynode` that will be used as persistent storage for all apps and files that will be created/uploaded to the Virtual Skynode.

{% hint style="warning" %}
If you want to run a different AuterionOS rootfs, make sure to use a different storage location or clear your current storage location by [resetting your Virtual Skynode](/app-development/simulation/virtual-skynode/resetting-virtual-skynode.md).
{% endhint %}

The IP specified in `--guest-ip` can be used to interface with the running Virtual Skynode. You can choose any IP in the `10.41.200.0/24` subnet. If you are looking for an interactive setup you can also just type `virtual-skynode`.

Check that Virtual Skynode is up and running by visiting the IPv4 address specified at launch. By default this is <http://10.41.200.2>:

<figure><img src="/files/nMK3xM8EI7HpAma0klAm" alt=""><figcaption><p>Virtual Skynode web interface</p></figcaption></figure>

{% hint style="warning" %}
When you run the `virtual-skynode` command for the first time, it initiates an app installation process.\
\
Do not prematurely stop the virtual-skynode process before it successfully completes the installation. If you do so, it may result in a corrupt configuration, which cannot automatically recover and you will have to [reset your Virtual Skynode](/app-development/simulation/virtual-skynode/resetting-virtual-skynode.md).\
\
You can ensure the installation is complete with the web interface in Dashboard panel.
{% endhint %}

## Virtual FMU app

The backbone of any Virtual Skynode setup is formed by the Virtual-FMU app. This app runs the PX4 Autopilot code on your Virtual Skynode and allows you to use PX4 as you would on a real Skynode.

{% hint style="info" %}
The Virtual FMU is automatically installed as a system default app on your Virtual Skynode
{% endhint %}

### Usage

1. With Virtual Skynode running visit its web interface at <http://10.41.200.2>
2. Go to the **Apps** page\ <img src="/files/z9fbktrJYjDon25wEQSp" alt="" data-size="original">
3. Find the **Virtual FMU** app (*com.auterion.virtual-fmu*) and click the **Configure** button next to it. This should open a new browser tab. This is the web interface of the Virtual FMU where the simulation environment can be modified or interacted with\
   ![](/files/IFD6qAOMs9E6JS1WlLjZ)
4. Virtual FMU starts in self-contained SIH mode by default. This mode doesn't require an external gazebo instance, you can directly connect with Auterion Mission Control and fly.

## Environment Simulation

As an alternative to running in self-contained SIH mode, the Virtual FMU app can also run external simulators like Gazebo Sim and AirSim. These can provide more accurate physics simulation and photorealistic environments useful for developing visual pipelines.

### Gazebo Simulation

Auterion provides a meta Debian package called **simulation-gazebo** that essentially 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 have not done so already, setup **simulation-gazebo** by following the instructions here: [Simulation-Gazebo Reference](/app-development/simulation/virtual-skynode/simulation-gazebo-reference.md)

#### Switch to Gazebo Simulation Mode

1. Run `simulation-gazebo` to launch gazebo. This should open up a Gazebo Sim window
2. Go to the Virtual FMU configuration browser tab
3. Click the **Simulation mode** dropdown menu and select the desired simulation mode
4. Then click the "Reload Simulation" button

<figure><img src="/files/reYr5l8zBOicacXcYs5b" alt=""><figcaption><p>Virtual FMU webpage: switch to Gazebo Sim Mode</p></figcaption></figure>

{% hint style="warning" %}
If you don't have gazebo running on your host, you will see the following warning:\
`WARN [gz_bridge] Service call timed out as Gazebo has not been detected`
{% endhint %}

If everything has been installed correctly you should see the vehicle show up in your Gazebo Sim window.

### AirSim Simulation

Auterion offers a meta debian package for Ubuntu called **simulation-airsim** that simplifies the setup required to start an AirSim simulation for quadcopter simulation. This is meant to be run in conjunction with Virtual Skynode.

{% hint style="info" %}
AirSim simulation is only available for [virtual AOS 4.1.2](https://suite.auterion.com/api/releases/files/711?token=01JWWSWZCGHYYD4T12DEW62GA5) and higher or alternatively versions with virtual FMU app 1.4.0 or higher.

Soon, a variaty of vehicles will be supported, however, so far only quadcopter simulation is supported.
{% endhint %}

#### Installation

If you have not done so already, setup simulation-airsim by following the instructions here: [Simulation-AirSim Reference](/app-development/simulation/virtual-skynode/simulation-airsim-reference.md)

#### Switch to AirSim simulation mode

1. Run `simulation-airsim` to launch AirSim. This should open up a AirSim window
2. Go to the Virtual FMU configuration browser tab
3. Click the **Simulation mode** dropdown menu and select the desired simulation mode
4. Then click the "Reload Simulation" button

<figure><img src="/files/Gfd0dJbJ5pc4zgAj3xJl" alt=""><figcaption><p>Virtual FMU webpage: switch to AirSim Mode</p></figcaption></figure>

## Build and Install Auterion Apps

Your Auterion apps that you have built for Skynode will fail to install on Virtual Skynode. This is because apps for Skynode target the linux/arm64 architecture, whereas apps for Virtual Skynode running on your machine need to target linux/amd64.

To build your Auterion app for Virtual Skynode, you can follow the [Application Development](/app-development/app-development/application-development-1.md#virtual-skynode) workflow:

```
auterion-cli app build --simulation
```

This will produce a `*-simulation.auterionos` artifact compatible with Virtual Skynode. You can now install your app either via `auterion-cli app install`, or navigating the web interface at <http://10.41.200.2> to Dashboard > Install Software.

## Multi Vehicle Simulation & Mav System ID

In case one wants to simulate a specific vehicle ID or run multiple skynodes in parallel, the vehicle ID can be set via the app's web UI.

{% hint style="info" %}
This feature is available since virtual AOS 4.1.12 with virtual FMU app 1.4.3. For

* SIH and
* Simulation-Gazebo

it works our of the box. For Airsim simulation, special configuration is required. Contact Auterion for instructions.
{% endhint %}

<figure><img src="/files/V13l0FiXFyfs01CFMs6t" alt=""><figcaption><p>Instance ID for virtual FMU</p></figcaption></figure>

After modifying the instance ID, reload your simulation. For multiple skynodes, in order to avoid conflicts by the same ID on various virtual devices, it is recommened to start the different virtual devices separately the first time and confiure them propperly, before running all together.

See [Multiple Virtual Skynodes on single machine](/app-development/simulation/virtual-skynode/multiple-virtual-skynodes-on-single-machine.md) for more details.

## Expose DDS/ROS2 messages to host

Since virtual AOS 4.1.x DDS messages from the virtual FMU and apps (in network mode `host` ) do not get exposed to the host machine by default, as it might conflict with multi-vehicle simulation configuration.

If you want to expose the DDS messages again, do the following.\\

Access the virtual AOS and open a file.

```
ssh root@10.41.200.2 # or the targeted virtual skynode of your choise
mountrw # to make the partition write-able
nano /usr/lib/python3/dist-packages/app_configurator/dds-configurator.py
```

In the file, look for the following line and un-comment those.

```
    # # Uncomment to expose DDS messages to host machine
    # if device.lower() == "simulation":
    #     interface_bridge = 'enp0s8'
    #     ip_bridge = get_ip_address(interface_bridge)
    #     if ip_bridge:
    #         data_host["whitelist_items"].append({"ip": ip_bridge, "comment": "enp0s8 bridge interface for vitrual skynode"})
```

After restarting the virtual device, you will see the messages on you host machine e.g. with

```
ros2 topic list
```

## Auterion Mission Control

You can also connect Auterion Mission Control (AMC) to the Virtual FMU. To do so open the AMC settings and select the tab "Settings/Comm Links". There create a new comm link configuration with the following settings:

| Setting                        | Value                                       |
| ------------------------------ | ------------------------------------------- |
| Name                           | Can be an arbitrary string                  |
| Type                           | TCP                                         |
| Automatically Connect on Start | True or False, based on personal preference |
| High Latency                   | False                                       |
| Host Address                   | 10.41.200.2                                 |
| TCP Port                       | 5790                                        |

<figure><img src="/files/ulBNJc7b4sMrxa1YQYN4" alt=""><figcaption><p>Example setup of a Comm Link for Virtual Skynode with AMC</p></figcaption></figure>

Click on the created comm link and select "Connect" at the bottom.


---

# 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.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.
