> For the complete documentation index, see [llms.txt](https://gi-ata.gitbook.io/ros-arducopter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gi-ata.gitbook.io/ros-arducopter/installation-guide.md).

# Installation Guide

<figure><img src="/files/bSqXw6aEJe6eFiWu3Er6" alt=""><figcaption></figcaption></figure>

**Developed by William Chamorro PhD. for the GI-ATA research group**

**ArduCopter** and **ArduPilot** are two open-source projects for controlling autonomous vehicles. ArduPilot is the main project, encompassing a wide range of vehicles including planes, helicopters, rovers (land vehicles), and boats. ArduCopter, on the other hand, is a specific part of ArduPilot dedicated to controlling drones or multirotor aircraft such as quadcopters and hexacopters.

Both projects, ArduCopter and ArduPilot, offer open-source software and hardware that enables enthusiasts and developers **to create and control their own autonomous vehicles.** They provide navigation functions, flight control, mission planning, among others, allowing for extensive customization and adaptation to different types of vehicles and specific needs.

{% hint style="info" %}
This guide was tested in standard CPU with **ROS-noetic** and **Ubuntu focal**
{% endhint %}

The following sections show what tested open source nodes to install in order to have a successful **Arducopter - ROS** integration

## Installation of QGroundControl

<figure><img src="/files/KhlOeoD1GFTFqQHYPC67" alt=""><figcaption></figcaption></figure>

**QGroundControl** is a ground control station software used to c**ontrol and monitor unmanned vehicles**, particularly drones and autonomous vehicles. It's an open-source application that provides a user-friendly interface for configuring vehicles, planning missions, monitoring telemetry data (like altitude, speed, and battery status), and controlling the vehicle during flight.

QGroundControl supports various types of vehicles and is compatible with different autopilot systems, including **ArduPilot and PX4**, offering a comprehensive set of tools for mission planning, flight control, and vehicle setup. It's a critical component in the operation of unmanned systems, allowing users to interact with and manage their vehicles efficiently and safely from the ground. Te following summarize how to install this app.

Create a folder and download QGroundControl

{% code overflow="wrap" lineNumbers="true" %}

```bash
mkdir QGround && cd QGround
sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager
wget https://s3-us-west-2.amazonaws.com/qgroundcontrol/latest/QGroundControl.AppImage
```

{% endcode %}

<figure><img src="/files/MZ8DkW5DQ5iBYuGHidJd" alt=""><figcaption><p>Screenchot of the downloading process</p></figcaption></figure>

Change permissions and execute for testing

{% code overflow="wrap" lineNumbers="true" %}

```bash
chmod +x ./QGroundControl.AppImage 
./QGroundControl.AppImage
```

{% endcode %}

<figure><img src="/files/c7naKHXNbb2dRO745q7k" alt="" width="321"><figcaption><p>That is how QGropundControl looks like </p></figcaption></figure>

## Installing Gazebo and ArduPilot Plugin

Robot simulation is an essential tool in every roboticist's toolbox. A well-designed simulator makes it possible to rapidly test algorithms, design robots, perform regression testing, and train AI system using realistic scenarios. **Gazebo** offers the ability to accurately and efficiently simulate populations of robots in complex indoor and outdoor environments.

{% hint style="success" %}
This plugin was aimed for Gazebo 11
{% endhint %}

### Gazebo 11 installation

This section is intended in case we do not have installed Gazebo 11. Recall that Gazebo installs along ROS noetic in the desktop-full version.

Update packages before installing

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo apt-get update
sudo apt-get upgrade
```

{% endcode %}

Setup your computer to accept software

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
```

{% endcode %}

Setup keys

{% code overflow="wrap" lineNumbers="true" %}

```bash
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
```

{% endcode %}

Reload software list

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo apt update
```

{% endcode %}

Install Gazebo

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo apt-get install gazebo11 libgazebo11-dev
```

{% endcode %}

### Gazebo plugin installation

Update packages before installing

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo apt-get update
sudo apt-get upgrade
```

{% endcode %}

Download the APM plugin

{% code overflow="wrap" lineNumbers="true" %}

```bash
cd ~
git clone https://github.com/khancyr/ardupilot_gazebo.git
```

{% endcode %}

Compile the package

{% code overflow="wrap" lineNumbers="true" %}

```bash
cd ardupilot_gazebo
mkdir build
cd build
cmake ..
make -j4
sudo make install
```

{% endcode %}

Set up bashrc

{% code overflow="wrap" lineNumbers="true" %}

```bash
echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc
echo 'export GAZEBO_MODEL_PATH=~/ardupilot_gazebo/models' >> ~/.bashrc
. ~/.bashrc
```

{% endcode %}

If everything was done correctly we will be able to launch the plugin but it will not fly yet.

**Terminal 1 type,**

{% code overflow="wrap" lineNumbers="true" %}

```bash
gazebo --verbose ~/ardupilot_gazebo/worlds/iris_arducopter_runway.world
```

{% endcode %}

<figure><img src="/files/ibbvnOMQ0dI1MlKHFmZh" alt="" width="375"><figcaption></figcaption></figure>

### Install Ardupilot and MAVProxy Ubuntu

MAVProxy stands for "MAVlink Proxy." It's a versatile command-line ground control station (GCS) used primarily with ArduPilot, which is a popular open-source autopilot software. MAVProxy acts as an i**ntermediary communication system between the ground control station and the vehicle's autopilot**, allowing users to interact with the vehicle using a command-line interface.

Clone ArduPilot

{% code overflow="wrap" lineNumbers="true" %}

```bash
cd ~
sudo apt install git
git clone https://github.com/ArduPilot/ardupilot.git
cd ardupilot
```

{% endcode %}

Install dependencies

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo apt-get update –y
sudo apt-get install -y python3-testresources
cd ardupilot
Tools/environment_install/install-prereqs-ubuntu.sh -y
```

{% endcode %}

If all dependencies were successfully installed you will see the following message.

<figure><img src="/files/z9PX0t7iR3jmWHPbk7JA" alt=""><figcaption><p>Successfully installed dependencies</p></figcaption></figure>

Reload the profile

{% code lineNumbers="true" %}

```bash
. ~/.profile
```

{% endcode %}

Checkout for the most stable version&#x20;

{% code overflow="wrap" lineNumbers="true" %}

```bash
git checkout Copter-4.0.4
git submodule update --init --recursive
```

{% endcode %}

{% hint style="warning" %}
If git submodule update fails

{% code overflow="wrap" lineNumbers="true" %}

```bash
git config --global url.https://.insteadOf git://
```

{% endcode %}
{% endhint %}

Test installed dependencies

{% code overflow="wrap" lineNumbers="true" %}

```bash
cd ~/ardupilot/ArduCopter
sim_vehicle.py -w
```

{% endcode %}

<figure><img src="/files/3xyVUi6BbKJ5a2X4TzPG" alt="" width="375"><figcaption><p>ArduCopter Execution</p></figcaption></figure>

### Install MAVROS

MAVROS stands for "MAVLink Robot Operating System." It's a middleware that acts as a **bridge between MAVLink based autopilots,** like the ones used in ArduPilot or PX4, and the Robot Operating System (ROS).

Install extras

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras
```

{% endcode %}

Then install GeographicLib datasets

{% code overflow="wrap" lineNumbers="true" %}

```bash
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
./install_geographiclib_datasets.sh
```

{% endcode %}

Install the ros node

{% hint style="info" %}
We use **catkin build** instead of catkin\_make
{% endhint %}

Install python catkin tools

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo apt-get install python-catkin-tools python-rosinstall-generator -y
```

{% endcode %}

Create the workspace

{% code overflow="wrap" lineNumbers="true" %}

```bash
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
wstool init src
```

{% endcode %}

Install MAVROS

{% code overflow="wrap" lineNumbers="true" %}

```bash
rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y
```

{% endcode %}

{% hint style="info" %}
We asume that rosdep is enabled in your computer, if not do this before rosdep install

{% code overflow="wrap" lineNumbers="true" %}

```bash
rosdep init
rosped update
```

{% endcode %}
{% endhint %}

Install Geographic lib datasets

{% code overflow="wrap" lineNumbers="true" %}

```bash
./src/mavros/mavros/scripts/install_geographiclib_datasets.sh
```

{% endcode %}

{% hint style="info" %}
Remember to use this on each window that runs a ROS node

{% code overflow="wrap" lineNumbers="true" %}

```bash
source devel/setup.bash
```

{% endcode %}
{% endhint %}

Clone simulation packages

{% code overflow="wrap" lineNumbers="true" %}

```bash
cd ~/catkin_ws/src
git clone https://github.com/Intelligent-Quads/iq_sim.git
echo "GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/catkin_ws/src/iq_sim/models" >> ~/.bashrc
```

{% endcode %}

**Compile** all packages

{% code overflow="wrap" lineNumbers="true" %}

```bash
catkin build
```

{% endcode %}

Update global variables

{% code overflow="wrap" lineNumbers="true" %}

```bash
source ~/.bashrc
```

{% endcode %}

If all packages were successfully compiled you will see this

<figure><img src="/files/nNB19TVsF4hbVpdlPBcj" alt="" width="375"><figcaption></figcaption></figure>

prueba

roslaunch iq\_sim runway.launch

/ardupilot/ArduCopter$ sim\_vehicle.py -v ArduCopter -f gazebo-iris --console
