SITL Simulator Notes [1-1]

By admin No comments

The SITL (software in the loop) 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.



"Simulation plays an important role in li-ion battery design" I have learned from last SURF experience. It would be helpful to avoid some predictable error and reduce the failure of the prototype. If we add some new sensors or implement some fantasy algorithms to our copter without test, the first flight would be dangerous and irreliable. Safty is always important. Moreover, the cost of a test flight need be concerned. Simulation is convient that I can do it in the pleasent office. However, the comparable and resonable simulation can reduce risks and it is time-saving.

Overview Features

  • SITL allows you to run ArduPilot on your PC directly, without any special hardware. 

  • When running in SITL the sensor data comes from a flight dynamics model in a flight simulator.

  • ArduPilot has a wide range of vehicle simulators built in, and can interface to several external simulators.

    • i.e. X-Plane10\Gazebo\CRRCSim\FlightGear
  • Adding new simulated vehicle types or sensor types is straightforward.

    • The new idea can be tested on simulator to avoid some error.

Start SITL

Setting up SITL

The specific commands were tested on Ubuntu from 12.10 to 18.04. Our project will be on the 18.04(The bash history can be found in Appendix)

The first setup on my dell computer is successful and there is not any exceptional case happen!

Please strictly follow the official guide!!!!
Please strictly follow the official guide!!!!
Please strictly follow the official guide!!!!

Main Steps

SITL Advanced Testing Outline

  • Selecting a vehicle/frame type
  • Setting vehicle start location
  • Loading a parameter set
  • Setting parameters
  • Testing RC failsafe
  • Testing GPS failure
  • Testing the effects of vibration
  • Testing the effects of wind
  • Adding a virtual gimbal
  • Adding a virtual rangefinder
  • Adding a virtual optical flow sensor
  • Accessing log files
  • Graphing vehicle state
  • Using a joystick
  • Using real serial devices
  • Changing the speed of the simulation
  • Testing Compass Calibration
  • Connecting other/additional ground stations
  • SITL with MAVProxy (UDP)
  • SITL without MAVProxy (TCP)
  • Connecting Mission Planner (UDP)
  • Testing Precision Landing
  • Testing Visual Positioning

Some useful command for beginer

Firstly, you can run the demonstration on the dev document.

After completely install the SITL and the demo is working fine, then the follwing command will be helpful.

Starting FlightGear Simulator

If you want to run simulation on FlightGear, please run FlightGear First!
Start a NEW terminal.

cd  ..Tools/autotest

Starting SITL

//Location of ArduCopter
cd <Location>/ardupilot/ArduCopter
//Start SITL with map, console and osd
../Tools/autotest/ --map --console --osd 

The SITL is Started, you can see map, console and OSD. Then you may want to start FlightGear.

Setting parameters

//Many of the following tasks involve setting parameter values over MAVLink, which you do using the param set command as shown:

//All available parameters can be listed using param show. The SITL-specific parameters start with SIM_, and can be obtained using:
param show SIM_*

Graph the figure of a parameter

module load graph

graph RANGEFINDER.distance

You can also use the following commands to graph rangefinder information (defined as MAVProxy aliases):

grangealt - graph rangefinder distance and relative altitude.
grangev - rangefinder voltage
grange - graph “rangefinder_roll”

BUT, the gXXXX call did not work on my terminal.

Using QGC to control

Run QGC first, it will wait for connections. Then run SITL.