Skip to content

Setting up your simulator

Lucas Young edited this page May 25, 2019 · 29 revisions

We have two methods of setting up a simulator of ArduPilot's master branch. The first method is easier. The second method should be used if you cannot get the first method to work.

Method 1: Setting up Ardupilot simulator (easier)

Prerequisites for Windows users

  1. Install and launch the Ubuntu subsystem. In the Ubuntu terminal,
  2. sudo apt install g++
  3. sudo apt-get install python2.7
  4. sudo apt install python-pip
  5. pip install future Proceed to compiling the binary

Compiling the binary

  1. Clone the ardupilot repository. Cd into it.
  2. Set vehicle to SITL ./waf configure --board sitl
  3. Compile desired vehicle ./waf copter

Start your sim

./build/sitl/bin/arducopter -M QuadCopter
The vehicle can be connected to over TCP at port 5760.

  1. Open QGroundControl. Go to Comm Links and add a TCP connection to 127.0.0.1, port 5760.
  2. QGroundControl will now connect to your simulated vehicle. In the vehicle settings (tab with cog wheel icon), go to Airframe and ensure that frame class is a Quad and the frame type is X.
  3. Go to Safety and make sure none of the arming checks are checkedc.
  4. Now the simulated vehicle is ready to fly with DroneKit. Execute whichever python script you need. The connection string that your script uses should be ""tcp:127.0.0.1:5763" if you still have QGroundControl connected to the vehicle, otherwise "tcp:127.0.0.1:5760."

Method 2: Setting up a Vagrant simulator

Prerequisites

  1. Git
    Leave line endings untouched git config --global core.autocrlf false
  2. Install VirtualBox for your OS
  3. Install Vagrant for your OS
  4. Clone the autopilot repository git clone https://github.com/ArduPilot/ardupilot.git

Configure Vagrant

  1. Within the ardupilot directory add the following lines to your vagrantfile before the final "end"

    config.vm.network "forwarded_port", guest: 5760, host: 5760, protocol: "tcp"
    config.vm.network "forwarded_port", guest: 5761, host: 5761, protocol: "tcp"
    config.vm.network "forwarded_port", guest: 5762, host: 5762, protocol: "tcp"
    config.vm.network "forwarded_port", guest: 5763, host: 5763, protocol: "tcp"

  2. Launch vagrant vagrant up
  3. Initialize submodules
    vagrant ssh
    cd /vagrant
    git submodule update --init --recursive
    exit

Launching VTOL simulator

  1. vagrant ssh
  2. cd into ArduPlane
  3. sim_vehicle.py -l 35.328423,-120.752505,580,0 -j4 -f quadplane --console --map