Setting up SITL on Linux¶
This page describes how to setup the SITL (Software In The Loop) on Linux. The specific commands were tested on Ubuntu from 12.10 to 16.04.
The SITL simulator allows you to run Plane, Copter or Rover without any hardware. It is a build of the autopilot code using an ordinary C++ compiler, giving you a native executable that allows you to test the behaviour of the code without hardware.
SITL runs natively on Linux and Windows. See the separate windows installation page for a windows install.
Please follow each of the steps described below.
There is also a linked video below showing how to do the setup.
The video hasn’t been updated according to the text. Please read the written instructions in case of error.
For example the video speak about
sim_vehicle.sh where it is
Git is a free and open source distributed version control system that is used to manage ArduPilot codebase. Git is available on all major OS platforms, and a variety of tools exist to make it easier to get started.
Git command line¶
Linux/Ubuntu users can install with apt :
sudo apt-get update
sudo apt-get install git
sudo apt-get install gitk git-gui
Clone ArduPilot repository¶
“Cloning” is git’s term for making a local copy of a remote repository (i.e. one held on the GitHub servers).
Developers should clone the main ArduPilot repository (if they simply want to download and compile the latest code) or their own fork (if they want to make changes to the source code and potentially submit changes back).
Instructions for commonly used tools are below but whichever tool is used, the URL for the source repo will be required. This can be found on the right side of the screen on each Github repository home page but in general the URL is:
https://github.com/ArduPilot/ardupilot.gitfor the main ardupilot repo
https://github.com/your-github-account/ardupilotfor your fork of the ardupilot repo
Cloning with the command line¶
open a terminal and navigate to the directory where you would like the clone to be stored
clone your fork:
git clone https://github.com/your-github-userid/ardupilot cd ardupilot git submodule update --init --recursive
or the main project repo:
git clone https://github.com/ArduPilot/ardupilot cd ardupilot git submodule update --init --recursive
Install some required packages¶
If you are on a debian based system (such as Ubuntu or Mint), we provide a script that will do it for you. From ardupilot directory :
Reload the path (log-out and log-in to make permanent):
Now you should be able to build with waf as described in BUILD.md.
Add some directories to your search path (Facultative)¶
ONLY if you didn’t run the install-prereqs script from previous step.
Add the following lines to the end of your “.bashrc” in your home directory (notice the . on the start of that filename. Also, this is a hidden file, so if you’re using a file manager, make sure to turn on “show hidden files”).
export PATH=$PATH:$HOME/ardupilot/Tools/autotest export PATH=/usr/lib/ccache:$PATH
Then reload your PATH by using the “dot” command in a terminal
Start SITL simulator¶
To start the simulator first change directory to the vehicle directory. For example, for the multicopter code change to ardupilot/ArduCopter:
Then start the simulator using sim_vehicle.py. The first time you run it you should use the -w option to wipe the virtual EEPROM and load the right default parameters for your vehicle.
After the default parameters are loaded you can start the simulator normally. First kill the sim_vehicle.py you are running using Ctrl-C. Then:
sim_vehicle.py --console --map
has many useful options, ranging from setting the simulation speed
through to choosing the initial vehicle location. These can be listed by
calling it with the
-h flag (and some are demonstrated in Using SITL for ArduPilot Testing).
If the map titles don’t load, you can temporary change the map provider in the map window by clicking View/Service. To keep the new map service between launch, add the following lines to the end of your “.bashrc” (change MicrosoftHyb by the provider you want):
To get the most out of SITL you really need to learn to use MAVProxy. Have a read of the MAVProxy documentation. Enjoy flying!
For ArduPlane you can choose several possible simulators. A popular choice is JSBSim, which you can enable with the -f jsbsim option to SITL.
JSBSim is a sophisticated flight simulator that is used as the core flight dynamics system for several well known flight simulation systems.
In the past ArduPilot required a special version of JSBSim. As of December 2018 that is no longer the case, and we can use the standard JSBSim releases.
In order to build JSBSIM, you need Cmake, install it with :
sudo apt-get install cmake
In the same directory (your home directory) run these commands:
git clone git://github.com/JSBSim-Team/jsbsim.git cd jsbsim mkdir build cd build cmake -DCMAKE_CXX_FLAGS_RELEASE="-O3 -march=native -mtune=native" -DCMAKE_C_FLAGS_RELEASE="-O3 -march=native -mtune=native" -DCMAKE_BUILD_TYPE=Release .. make -j2
If using the JSBSim plane simulator you can specify a different JSBSim model than the default Rascal110 by specifying the model name using the -f parameter to sim_vehicle.py, like this:
sim_vehicle.py -v ArduPlane -f jsbsim:MyModel --console --map
the model should be in the Tools/autotest/aircraft/ directory.
FlightGear 3D View (Optional)¶
Developers can optionally install the FlightGear Flight Simulator and use it (in view-only mode) to display a 3D simulation of the vehicle and its surroundings. This provides a much better visualization than the 2D maps and HUD flight displays provided by MAVProxy and Mission Planner.
FlightGear support is currently only in master (January 2016). It should appear in the next versions of the vehicle codelines (not present on current versions: Copter 3.3, Plane 3.4, Rover 2.5).
SITL outputs FlightGear compatible state information on UDP port 5503. We highly recommend you start FlightGear before starting SITL (although this is not a requirement, it has been found to improve stability in some systems).
The main steps (tested on Ubuntu Linux 14.04 LTS) are:
Install FlightGear from the terminal:
sudo apt-get install flightgear
This will start FlightGear.
Start SITL in the terminal in the normal way. In this case we’re specifying the start location as San Francisco airport (KSFO) as this is an interesting airport with lots to see:
sim_vehicle.py -L KSFO
FlightGear will always initially start by loading scenery at KSFO (this is hard-coded into the batch file) but will switch to the scenery for the simulated location once SITL is started.
- If the vehicle appear to be hovering in space (no
- scenery) then FlightGear does not have any scenery files for the selected location. Choose a new location!