Skip to content

ArduPilot Simulation

patnolan33 edited this page Nov 5, 2020 · 2 revisions

Table of Contents

This page details the installation and usage of the ArduPilot Software-in-the-Loop (SITL) simulation software. This software is open source and is located at: http://ardupilot.org/dev/docs/sitl-simulator-software-in-the-loop.html. This simulation uses MAVProxy, and useful tips for usage can be found here: Copter SITL/MAVProxy Tutorial and here: Using SITL for ArduPilot Testing

Installation

Windows installation

Follow the instructions found on the Windows installation page on the ArduPilot SITL website.

NOTE: To use the SITL with MACE, it is recommended that you use the Heron Systems fork of ardupilot. To clone this fork, run:

git clone https://github.com/heronsystems/ardupilot

Linux installation

Follow the instructions found on the Linux installation page on the ArduPilot SITL website are duplicated here with modifications for the Heron Systems fork.

NOTE: To use the SITL with MACE, it is recommended that you use the Heron Systems fork of ardupilot. To clone this fork, run:

git clone https://github.com/heronsystems/ardupilot

Usage

To launch the simulation, open a terminal (note: for Windows, open a Cygwin terminal) and change directories into the vehicle type that you wish to launch. This simulation environment has been tested with MACE for both ArduCopter and ArduPlane.

To launch the simulation, we can simply change directory into your desired vehicle directory (e.g. ardupilot/ArduCopter for copter or ardupilot/ArduPlane for plane) and launch the sim_vehicle.py script:

cd ardupilot/ArduCopter
sim_vehicle.py --instance=2 --sysid=2

In the above code, --instance=2 tells the simulation to set up the correct ports for vehicle ID 2, and --sysid=2 actually changes the vehicle ID. To properly change the vehicle ID, you must change both of these numbers so the correct ports are set up in MAVProxy behind the scenes.

Setting up for MACE communications

By default, the simulation outputs data over a machine's loopback address (i.e. 127.0.0.1) on ports 14550 and 14551. Regardless of whether or not your simulation is running on the same machine as your MACE instance, you will need to add an output destination and port number to the simulation. Find your machine's IP address and start the simulation with the -m --out flag:

sim_vehicle.py -m --out=udp:<your ip address here>:<port number here> --instance=2 --sysid=2

Replace <your ip address here> with your IP address and <port number here> with a port that you wish to receive data on. Typically, this port number is set to 14550 + N, where N is your vehicle ID.

Finally, it is sometimes useful to use the MAVProxy console to visualize what is happening with the simulation. To do so, use the --console flag with launching the simulation. Note that this will launch a separate window from your terminal. While helpful, as you launch more simulations, the extra windows become cumbersome.

An example command to launch the simulation with the console, output to a machine via UDP, and set the vehicle ID is as follows:

sim_vehicle.py --console -m --out=udp:192.168.1.33:14552 -I 2

One final note: you cannot launch two simulation instances with the same ID. The simulation will not crash, however, the last simulation that is launched with a duplicate ID will supersede all previous simulations. In other words, the other simulations with that ID will enter a "Link Down" state and will not be controllable. You will, however, still be able to control the last simulation that was launched.