> For the complete documentation index, see [llms.txt](https://bellflight.gitbook.io/vertical-robotics-competition-phase-ii/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bellflight.gitbook.io/vertical-robotics-competition-phase-ii/phase-ii-software/gui.md).

# GUI

For teams that choose not to write any autonomous code, we have provided a small desktop app to help control the peripherals connected to the PCC.

## Setup

First, clone the Phase 2 repo to your Windows laptop like you did in Phase I: <https://bellflight.gitbook.io/vertical-robotics-competition/hardware/laptop-setup/clone-the-vrc-repo>

Now, open up the Anaconda virtual environment you used during Phase I with the Phase II repo this time: <https://bellflight.gitbook.io/vertical-robotics-competition/hardware/peripheral-component-computer/test-the-pcc#back-at-the-computer>

Open up a terminal with VS Code (Terminal -> New Terminal at the very top), and run the command:

```bash
python -m pip install -r GUI/requirements.txt
```

to install the needed dependencies.

## Usage

Now, you'll be able to open the file `GUI/app.py` and hit the Play button in VS Code.&#x20;

{% hint style="info" %}
The VMC software must be already be running on the VMC!
{% endhint %}

When the application starts, it'll ask for the IP address of your drone.

![](https://2067701961-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MiT5g4L04alXNmboKaR%2F-MkK2detGEtyA3qXH-ga%2F-MkK2xCFTcwI0fhTS47p%2Fimage.png?alt=media\&token=9ee56e71-cb0b-427c-9753-ae2452f46dd7)

Enter that, and click "Ok". The application will now connect to your drone.

![](https://2067701961-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MiT5g4L04alXNmboKaR%2F-MkK2detGEtyA3qXH-ga%2F-MkK3GR3mwgxgRfYnJwZ%2Fimage.png?alt=media\&token=d185ce2e-331e-431d-87d7-b67635991b72)

If the application is unable to connect to your drone, it'll show an error message and exit.

### Control Window

![](https://2067701961-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MiT5g4L04alXNmboKaR%2F-MkK5YMoK1Gqv2Ww-iAe%2F-MkK5iuST-S3YQxR7riW%2Fimage.png?alt=media\&token=2bb56a8f-2269-4b9a-98a8-f33f8ed4afff)

Now, you can click the buttons to change the color of the LEDs, open and close servos, and do a full peripheral computer reset.

At the bottom of the control window are status icons for the various software modules, indicating if they're online. If these are all green, you are good to fly!

![Four green status indicators](https://2067701961-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MiT5g4L04alXNmboKaR%2F-MkK56A58QUEqIBYaC_6%2F-MkK57iESfhiFte854VC%2Fimage.png?alt=media\&token=701452a9-b87c-4efa-bc45-73ebfd056d18)

#### Autonomous Mode

As for the "Autonomous" buttons of the software, this is purely optional for the teams that have chosen to write autonomous code. These buttons send a message to the MQTT topic `vrc/autonomous` with a payload of

```javascript
// enable button
{
    "enable": true,
}

// disable button
{
    "enable": false,
}
```

For any teams writing their own autonomous code, they can write a listener for this topic to enable/disable their autonomous code at certain points, rather than have it run continuously the entire time.

Example implementation:

```python
class Sandbox():
    def __init__(self) -> None:
        self.enabled = False
        
    ...
        
    def on_autonomous_message(self, payload: dict) -> None:
        self.enabled = payload["enable"]
        
    def autonomous_code(self) -> None:
        if self.enabled:
            do_stuff()
```

### MQTT Explorer Window

![](https://2067701961-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MiT5g4L04alXNmboKaR%2F-MkK5YMoK1Gqv2Ww-iAe%2F-MkK5s7uwU3dgwWdmPRE%2Fimage.png?alt=media\&token=08e01ca7-87df-4780-8323-72aaadb650ef)

The MQTT Explorer window is a debug console that shows all of the MQTT messages being sent by the software running on the drone. The relevant topics and data structures needed to write your own autonomous software is covered in the README of the Phase II repository: <https://github.com/bellflight/VRC-2021-Phase-II/blob/main/README.md>

You can safely close this window.
