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


---

# 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://davids-tutorials.gitbook.io/robotics/ardupilot-and-sitl.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.
