# Multi-Vehicle Simulation with JMAVSim
This topic explains how to simulate multiple UAV (multicopter) vehicles using JMAVSim and SITL. All vehicle instances are started at the same position in the simulation.
TIP
This is the easiest way to simulate multiple vehicles running PX4. It is suitable for testing multi-vehicle support in QGroundControl (or the MAVSDK (opens new window), etc.). Multi-Vehicle Simulation with Gazebo should be used for swarm simulations with many vehicles, or for testing features like computer vision that are only supported by Gazebo.
# How to Start Multiple Instances
To start multiple instances (on separate ports):
Build PX4
make px4_sitl_default
make px4_sitl_default
Start the first instance:
./Tools/jmavsim_run.sh
2): <code>./Tools/sitl_multiple_run.sh 2</code>
Start the first instance:
./Tools/jmavsim_run.sh -l
Start subsequent instances, specifying the simulation UDP port for the instance:
./Tools/jmavsim_run.sh -p 14561
The port should be set to14560+i
fori
in[0, N-1]
../Tools/jmavsim_run.sh -p 4561 -l
The port should be set to
4560+i
fori
in[0, N-1]
.
Ground stations such as QGroundControl listen for all vehicle instances on the PX4's remote UDP port: 14550
(all GCS traffic is sent to the same remote port).
Developer APIs such as MAVSDK or MAVROS listen on sequentially allocated PX4 remote UDP ports from 14540
(first instance) to 14549
. Additional instances all connect to port 14549
.
# Additional Resources
- See Simulation for more information about the UDP port configuration.