# Setup companion computer

These guide describes how to setup any Linux-based computer as a companion one. It can either be your laptop or headless Raspberry Pi on the ground or micro-PC onboard.

### How it works <a href="#how-it-works" id="how-it-works"></a>

Telemetry messages got from autopilot board over serial or USB port, by wires or radio link,  then a small script transmits these messages to GCS.uno server. When you open GCS.uno dashboard in a web-browser, this telemetry is got from server and rendered to a screen almost in realtime. In opposite direction, you press an action button on a web-page, this magically transforms to a MAVLink message and reaches onboard autopilot to be executed.

Assuming you have your computer running with internet connected and command shell available.

### Install MAVProxy

[MAVProxy](http://ardupilot.github.io/MAVProxy/html/index.html) is a fully-functioning command-line GCS for UAVs. It is used to proxy one telemetry source to many different locations. For example, one for [GCS.uno](https://www.gcs.uno) script, one for [ROS](http://www.ros.org), and another one for [QGroundControl](http://qgroundcontrol.com) in local network.

Follow [official MAVProxy manual](http://ardupilot.github.io/MAVProxy/html/getting_started/download_and_installation.html#linux) to install it on your system.

### Telemetry source

If companion computer is placed onboard, it likely communicates with autopilot over serial (UART) port. Here is a good example of [configuring Pixhawk with Raspberry Pi](http://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html). Radio modems can be connected either over serial or USB port. Follow modem's manuals to connect it to your computer.&#x20;

#### Serial port

Check it with MAVProxy:

```
sudo -s
mavproxy.py --master=/dev/ttyAMA0 --baudrate 57600
```

This command makes MAVProxy listen serial port 0 for telemetry messages and show autopilot's status messages in console. The same source will be also for a radio modem, connected over serial port.

#### USB port

Check it with MAVProxy:

```
sudo -s
mavproxy.py --master=/dev/ttyUSB0 --baudrate 57600
```

#### UDP port

MAVProxy can also listen to local UDP port:

```
mavproxy.py --master=udp:127.0.0.1:UDP_PORT
```

If MAVProxy successfully connects with your autopilot continue with installing GCS.uno board scripts.

### Install additional dependencies <a href="#install-additional-dependencies" id="install-additional-dependencies"></a>

#### NodeJS <a href="#nodejs" id="nodejs"></a>

```
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -sudo apt-get install -y nodejs build-essential
```

#### PM2 process manager <a href="#pm2-process-manager" id="pm2-process-manager"></a>

```
sudo npm install pm2 -g
```

### Download and install board scripts <a href="#download-and-install-board-scripts" id="download-and-install-board-scripts"></a>

```bash
cd
git clone https://github.com/GCS-uno/drone_board.git
cd drone_board
npm install
```

Inside `drone_board` directory you can find two shell scripts `mavproxy.sh` and `video.sh` which help running MAVProxy and video streaming. If you are sure not to use them, just skip to next step, otherwise make them executable:

```bash
chmod +x mavproxy.sh
chmod +x video.sh
```

### Get your drone keys <a href="#get-your-drone-keys" id="get-your-drone-keys"></a>

Sign in to your [GCS.uno dashboard](https://pilot.gcs.uno/), add new drone and get its MAVLink and Video keys.

![](https://3748318177-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJGeH9CamtpOqRPgXs0%2F-LK2Qczd9zlbSlHTGks7%2F-LK2Qh4MRLu-L4lGaY7i%2Fget_drone_keys.png?alt=media\&token=8cb615f5-2578-4a46-a319-4eda05edbe52)

Then put them in following commands to be readable by scripts. For MAVLink key (replace `abcd1234` with one copied from dashboard):

```
DRONE_MAVLINK_KEY=abcd1234; echo "export DRONE_MAVLINK_KEY=$DRONE_MAVLINK_KEY" >>~/.bash_profile && source ~/.bash_profile
```

The same for Video key (replace `abcd1234`):

```
DRONE_VIDEO_KEY=abcd1234; echo "export DRONE_VIDEO_KEY=$DRONE_VIDEO_KEY" >>~/.bash_profile && source ~/.bash_profile
```

### Start board scripts <a href="#start-board-scripts" id="start-board-scripts"></a>

Open `mavproxy.sh` file and put in MAVLink source in right way described above:

```bash
nano mavproxy.sh
```

Then check how it works

```
./mavproxy.sh
```

If it looks good `Ctrl+C` to exit and then run it in background with PM2 process manager:

```
pm2 start mavproxy.sh --name mavproxy
```

Now run `drone.js` to check connection with GCS.uno server:

```
node drone  
```

If it reports that connection is established, `Ctrl+C` to stop and run it again with PM2:

```
pm2 start drone.js --name drone
```

#### Enable scripts to start on system boot <a href="#enable-scripts-to-start-on-system-boot" id="enable-scripts-to-start-on-system-boot"></a>

Enable PM2 to start on boot:

```
pm2 startup
```

This will prompt a `sudo` command which must be copied and executed to enable autostart. Then save list of active processes:

```
pm2 save
```

And check it:

```
pm2 list
```

Now check your GCS.uno dashboard, you can see you drone's telemetry streaming.


---

# 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://gcs.gitbook.io/uno/setup-companion-computer.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.
