Comment on page
Simulators allow PX4 Autopilot to control a modeled drone in a simulated environment.
Simulation is a quick, easy, and most importantly, safe way to test changes to PX4 code before attempting to fly in the real world. It is also a good way to start flying with PX4 when you haven't yet got a vehicle to experiment with. -- PX4 Developer Guide
Many PX4 developers test their code changes in a simulator before flying a real drone with the modified software. It is much safer (and cheaper) to crash your drone in a simulator than in real-life. It is strongly recommended that you also do this if you start making changes to the PX4 firmware.
PX4 supports both Software In the Loop (SITL) simulation, where the flight stack runs on computer (either the same computer or another computer on the same network) and Hardware In the Loop (HITL) simulation using a simulation firmware on a real flight controller board. -- PX4 Developer Guide
Software-In-The-Loop simulation is the most used setup. It is best supported and more straightforward to use. It is actually more representative of how the software would behave in a real world flight than when using Hardware-In-The-Loop, because in HITL several software components are being bypassed. More information is available in the PX4 Developer Guide.
What the PX4 developers refer to as Hardware-In-The-Loop (HITL) is often called Processor-In-The-Loop (PITL or PIL) in industry. The term Hardware-In-The-Loop is applicable when also other parts of the real hardware are being used (e.g. sensors), not just the processor with simulated inputs.
There are multiple simulators that work with PX4 Autopilot. Most simulators support SITL, some also support HITL. Gazebo is the recommended choice, it is a very powerful simulation tool and is often used together with ROS. Other options include jMAVSim and Microsoft Airsim. A complete overview and up-to-date of simulators that support PX4 is available in the PX4 Developer Guide.
Note - A sister competition to HoverGames uses the same hardware for cars/rovers. While still new, there may be activity available showing use of CARLA for use of PX4 in an automotive simulation environment.
Many HoverGames participants will be using a virtual machine for (PX4) software development. The pre-configured virtual machine does NOT come with a simulator installed and the step-by-step guide also does not explain how to setup a simulator. It is left to the user to install one if desired.
Be aware that most simulators are resource heavy and may not run very will in a virtual machine. This is especially true if your computer is not the most powerful. It is usually better to install the simulator in a native environment setup. Simulators like MS Airsim make use of gaming engines Unity and Unreal Engine for things like environmental controls, and as such the equivalent of a Gaming PC may make a good host machine.
For reference: Decent results have been achieved with Gazebo on a virtual machine running Ubuntu. The virtual machine was assigned 3 processor cores of a modern quad-core Intel Core i7 with hyperthreading, and 8 out of 16 GB RAM.
The PX4 Developer Guide has a whole chapter dedicated to simulation, including some basic instructions on how to setup the simulator. It is the best resource available about simulating PX4 and it is strongly recommend that you base your simulation setup on their instructions and information:
Simulators can be configured for quite advanced and realistic environments including weather, automated obstacles, and wind. Typically gazebo by default is intentionally a very plain environment. You may be able to find material in the ROS project which shows methods of configuring the gazebo environment in a more rich fashion for flying drones. See the YouTube video below for a talk from Tully Foote at the 2019 PX4 Developer summit