Simulation Installation and Environment Setup (Windows)
Note: This page applies only to Windows users.
There are several pieces of software needed to get up and running with the simulator, namely PX4, Unreal Engine, and MavSDK. You will also need the software ubiquitous to the software team:
- git
- poetry
- if you are on Windows 11, Poetry will not automatically be added to your PATH variable (which is important for ease-of-use)
- find the folder where poetry was installed (likely
C:\Users\<your user>\AppData\Roaming\pypoetry
) in a file explorer or terminal- copy the full path of the
\venv\Scripts
subdirectory- this path will probably look something like
C:\Users\<your username>\AppData\Roaming\pypoetry\venv\Scripts
- this path will probably look something like
- type “environment variables” into the Windows search bar and selected the “Edit system environment variables” option
- if this doesn’t work, go to your Windows Settings > About > Advanced System Properties > Environment variables…
- in the top list of variables (the User variables), click the
PATH
option, then click “Edit…” -
click the “New” button on the right; paste the full path of the Poetry scripts directory into the next PATH entry
- click “Ok” on all the Windows you’ve pull up to the point
- restart any terminals you have open
- now you should have access to the
poetry
command!
- copy the full path of the
Table of Contents
It is recommended you follow this tutorial in the order listed.
- Installing Unreal Engine
- Installing AirSim
- Installing PX4 and MavSDK
- Initial Environment Setup
- Next Steps
Installing Unreal Engine
We will be using Unreal Engine for simulating virtual drones. If you have the Epic Games Launcher installed already (e.g., if you own Fortnite), you can download Unreal Engine from the “Unreal Engine” tab. If you don’t have the Epic Games Launcher, then you will have to download it to install Unreal Engine.
The Unreal Engine version you will download is 4.27.2. AirSim, which allows us to simulate multirotors in Unreal, does not work with Unreal Engine 5 or greater.
Finally, run Unreal Engine at least once before continuing to the next steps.
Installing AirSim
Visual Studio
To install AirSim, you must first install Microsoft’s Visual Studio Community 2022. This will also be the IDE you will use for programming C++ code for Unreal.
When installing, you must select the following:
C++ Development Pack
Windows SDK 10
AirSim
AirSim is an Unreal Engine plugin for simulating multirotors and cars that was previously maintained by Microsoft; it is the backbone of simulation.
To install AirSim, follow these steps:
- clone the AirSim GitHub repository:
git clone https://github.com/Microsoft/AirSim
- the location of your local copy does not matter
- Launch
x64 Native Tools Command Prompt for VS 2022
(using Windows search)- navigate to where you cloned AirSim with the
cd
command - run the command
.\build.cmd
- wait for AirSim to build
- you can move on to the next step while waiting
- navigate to where you cloned AirSim with the
Installing PX4 and MavSDK
These two softwares act as the bridge between your code and the virtual drone.
PX4
- download the PX4 0.9 installer and run the
.msi
file that is downloaded.- if Windows attempts to prevent you from running the installer, click on “more info” and click “run anyway”
- the installer will ask you where to install PX4; you may install it wherever you please (default location is
C:\PX4\
) - Do NOT check the box at the end that says “Clone PX4 Repository and Start Simulation”
- Open a command line prompt/open file explorer and navigate to where you installed PX4
- Run/click on
run-console.bat
to start the Cygwin bash console - Clone the PX4 Firmware repository from within the opened bash console:
git clone --recursive -j8 https://github.com/PX4/Firmware.git
- go to the newly-cloned Firmware repository and checkout this “known good” branch:
git checkout v1.11.3
- run
make px4_sitl_default none_iris
. You will encounter serveral red text messages: in response to each, type ‘u’ and press enter.
MavSDK
The MavSDK server is what your Python code will directly interface with; then, the MavSDK server will relay instructions to PX4, which in turn communicates with the virtual drone.
- install MavSDK
- unzip the downloaded ZIP file wherever you please
- keep track of where you unzipped MavSDK; you will need it for Environment Setup
Environment Setup
Simulation Git Repository
The simulation git repository contains many useful files that streamline running code. Open a terminal instance and clone it to your desired location using git clone https://github.com/MissouriMRR/Simulation-2023.git
. This creates a new directory called \Simulation-2023\
in the current working directory of your terminal.
Next, you should navigate to your local copy of the repository (just run cd .\Simulation-2023\
immediately after running git clone
) and run poetry install
. This should create a virtual environment for you to run code.
Configuration File Setup
After cloning our repository, navigate to the \scripts\
directory within it. In that directory, run .\setup.ps1
. (If this command results in an error that mentions Execution Policy, follow these steps, then try again). This command will create two files: \scripts\server-config.json
and \scripts\airsim-settings.json
. Open server-config.json
in a text editor of your choice and do the following:
- replace
mav_sdk_server_path
with the absolute path to the\bin
directory located in your MavSDK server install (the zip you downloaded previously) - replace
px4_path
with the absolute path of your PX4 directory (default isC:\PX4\
) drone_port
should ideally be correct already; if you encounter any issues with connecting to the virtual drone at later steps, check the debugging page
Your final server-config.json
should look similar to this:
{
"drone_port": 14030,
"mavsdk_server_path": "C:\\Dev\\school\\multirotor\\MavSDK\\bin",
"px4_path": "C:\\PX4"
}
Incompatible Execution Policy
If you encountered no errors completing the above, you may skip this.
Sometimes, Windows may not allow you to run PowerShell scripts due to your Execution Policy. To fix this, start a PowerShell/Terminal as Administrator (right-click the application as click “Run as Administrator”). Then, run the following command:
Set-ExecutionPolicy RemoteSigned
Afterward, restart all Terminal/PowerShell instances to apply the change.
Next Steps
If you’ve run all the above steps, you’re environment should be set up!
Next, you should go the the flying page to see how to fly the virtual drone with Python code.
Also, if you run into problems while attempting to fly the drone, check out the environment debugging page.