SITL Simulator (Software in the Loop)
SITL(环路软件)模拟器允许你跑 Plane, Copter or Rover 不用任何硬件。它使用一个普通的c++编译器构建autopilot代码,提供了一个本机可执行文件,允许您在不使用硬件的情况下测试代码的行为。
本文概述了SITL的优点和体系结构:
SITL允许您在PC上直接运行ArduPilot,无需任何特殊硬件。ArduPilot是一款便携式自动驾驶仪,可以在各种平台上运行。您的PC只是ArduPilot可以构建和运行的另一个平台。
在SITL中运行时,传感器数据来自飞行模拟器中的飞行动力学模型。ArduPilot有一个广泛的车辆模拟器内置,并可以接口到几个外部模拟器。这使得ArduPilot可以在非常广泛的车辆类型上进行测试。例如,SITL可以进行模拟。
- multi-rotor aircraft
- fixed wing aircraft
- ground vehicles
- underwater vehicles
- camera gimbals
- antenna trackers
- a wide variety of optional sensors, such as Lidars and optical flow sensors
Setting up SITL on Linux
Install steps
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 :
Tools/scripts/install-prereqs-ubuntu.sh -y
Reload the path (log-out and log-in to make permanent):
. ~/.profile
Now you should be able to build with waf as described in BUILD.md.
Add some directories to your search path (Facultative)
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
. ~/.bashrc
Start SITL simulator
Start SITL simulator
To start the simulator first change directory to the vehicle directory. For example, for the multicopter code change to ardupilot/ArduCopter:
cd 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.
sim_vehicle.py -w
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