# ArduPilot & SITL

* Versioning Warning:
  * Might need Gazebo Garden&#x20;

### Installation Instructions \[[1](#sources)]

Open the terminal with `Ctrl` + `Alt` + `T`

```
sudo apt-get update
sudo apt-get install git
sudo apt-get install gitk git-gui
```

```
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git
```

> Note: this takes a minute

```
cd ardupilot
```

```
Tools/environment_install/install-prereqs-ubuntu.sh -y
```

> &#x20;Note: this takes a minute

```
. ~/.profile
```

### SITL Set up \[[2](#sources)]

```
cd ~/ardupilot/ArduCopter
```

```
sim_vehicle.py -w
```

> Note: this is only ran once right after installing
>
> wait until \[ 0/1195] completes
>
> Pop up will show of command line "Setting SIM\_SPEEDUP=1.0000 ...."
>
> Once done, hit (Ctrl + C) or (Ctrl + D) to stop program

```
sim_vehicle.py --console --map
```

> Console, Map, ArduCopter with 'X' will pop up
>
> hit (Ctrl + C) or (Ctrl + D) to stop program

```
#in terminal
STABILIZE> 
mode guided
arm throttle
*wait gps*
arm throttle
takeoff 1
mode LAND
```

### Set up Gazebo with SITL

```
sudo apt update && sudo apt upgrade -y
```

```
sudo apt install libgz-sim7-dev rapidjson-dev -y
```

> create workspace and clone repo
>
> Note: this is where you will launch "gz sim etc.."

```
cd ~
```

```
mkdir -p gz_ws/src && cd gz_ws/src
git clone https://github.com/ArduPilot/ardupilot_gazebo
```

> Build the plugin

```
cd ardupilot_gazebo
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j4
```

> Note: need to run following two before sim (every time)

```
export GZ_SIM_SYSTEM_PLUGIN_PATH=$HOME/gz_ws/src/ardupilot_gazebo/build:$GZ_SIM_SYSTEM_PLUGIN_PATH
```

```
export GZ_SIM_RESOURCE_PATH=$HOME/gz_ws/src/ardupilot_gazebo/models:$HOME/gz_ws/src/ardupilot_gazebo/worlds:$GZ_SIM_RESOURCE_PATH
```

###

### Sources

\[1] [ArduPilot Setup on Linux](https://ardupilot.org/dev/docs/building-setup-linux.html) (Note: Finished at "Cleaning" step)\
\[2] [SITL Setup](https://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html#setting-up-sitl-on-linux)\
\[x] [ArduPilot SITL Tutorial](https://ardupilot.org/dev/docs/sitl-with-gazebo.html)
