Recently the interest for multiple vehicle simulations has grown. Being able to simulate multiple vehicles is useful to monitor the behavior of large drone fleets for light shows, for example, simultaneous mapping flights, or complex fleet operations. Simulations prepare operators for real-life deployment, and give the confidence that in real drone operations flights can be executed safely..
Previously, this was only possible by manually writing a roslaunch file, which is hard to maintain once the size of the fleet grows. Moreover, fixed-wing and VTOL models were not supported. Auterion’s contribution to the PX4 firmware enables simulating multiple vehicles in Gazebo without depending on ROS. This makes simulating any number of multiple vehicles simpler with fewer dependencies.
This post will focus on how to simulate multiple vehicle flights in PX4 with Software in the Loop (SITL) simulations in Gazebo.
Here we show a quick preview of what is possible: multiple vehicles running in SITL Gazebo for different models such as multicopters, “plane” and “standard_vtol” models.
Software in the Loop simulation
PX4 supports Software in the Loop (SITL) simulation where the flight stack is running on the computer. SITL is the fastest and safest way to test new software before using it on a real vehicle. SITL simulation can either run on the host system itself, or on a different computer. More information about simulation in PX4 can be found here.
For a single vehicle, the SITL simulation is working as illustrated in the following diagram. In the example of this post, the simulator used to simulate the dynamics and sensors of the vehicle in Gazebo. PX4 communicates with the simulator over a TCP port through MavLink HIL messages. A UDP port is used to communicate through external applications such as MAVSDK and MAVROS.
Starting the multi-vehicle simulation
Before we can run the simulation, we need to build the PX4 firmware. To install the PX4 toolchain, follow the “Getting Started” guide here. The following command builds the firmware so that we can start the Gazebo simulation.
cd src/Firmware DONT_RUN=1 make px4_sitl_default gazebo
The multi-vehicle simulation can be run as following:
cd src/Firmware Tools/gazebo_multi_vehicle.sh -m -n
Note that the model name defaults to “iris”. Models “plane” and “standard_vtol” are also supported. Currently the number of vehicles is limited to 10. For example, to simulate multiple fixed wing plane models, the simulation can be run by the following command:
Tools/gazebo_multi_vehicle.sh -m plane -n 5
What is happening under the hood
Take a look at the script gazebo_multi_vehicle.sh to better understand what is happening.
To dive deeper, the vehicle files are saved as xacro files in the sitl_gazebo submodule. This generates files in the Simulation Description File (SDF) format. These files are saved in /tmp/_.sdf
The UDP port is incremented from 14560, and the TCP port from 4560. The UDP and TCP port numbers being incremented can be changed here. All vehicles will be broadcasting on the UDP port 14550, therefore, will all appear in QGroundcontrol.
We are productizing this feature, to make it easy to use and integrated with the Auterion Ground Station and Auterion Insights, so that developers can quickly simulate and then execute multi-vehicle missions with any drone #PoweredByAuterion. Stay tuned for the upcoming product release!
Back to the Auterion blog