Launch one or more PX4 SITL vehicles in Gazebo from a single scenario script.
chmod +x launch_*.pyAdd this to your ~/.bashrc (then open a new shell):
export PX4_Autopilot_Dir=~/PX4-Autopilot./launch_multi_atmos.pyThe launcher runs in the foreground and prefixes each vehicle's output with its
name. Press Ctrl-C to stop every vehicle and its Gazebo process group.
Scenario state files are stored under ~/.cache/px4-sitl/.
Each scenario script has a small CONFIG block at the top. Edit it to change the world, the state session name, or the vehicle list (names, models, poses):
WORLD = "kthspacelab"
SESSION = "atmos"
VEHICLES = [
Vehicle(name="snap", model="gz_atmos", pose=(1, 0, 0.2)),
Vehicle(name="crackle", model="gz_atmos", pose=(2, 0, 0.2)),
]Vehicle.name is used for the DDS namespace, live output prefix, and status output.
Gazebo assigns its own model names such as atmos_0 and atmos_1; this is
intentional because setting PX4_GZ_MODEL_NAME makes PX4 attach to an existing
Gazebo model instead of spawning one.
To add a new model, edit px4_sitl_launcher.py and add it to both
MODEL_AUTOSTART and MODEL_BUILD.
./launch_multi_atmos.py --detach # launch and return to the shell
./launch_multi_atmos.py --status # show vehicle PIDs and states
./launch_multi_atmos.py --stop # stop only this scenarioDetached scenarios are still owned by their individual process groups, so stopping one scenario does not kill unrelated PX4 or Gazebo processes.
ROS 2 integration. In a separate terminal, run the XRCE-DDS agent:
micro-xrce-dds-agent udp4 -p 8888Each vehicle's topics then appear under its name, e.g. /snap/fmu/out/....
PX4 binary not found at .../build/<target>/bin/px4 — build the target it asks for:
cd $PX4_Autopilot_Dir
make px4_sitl_spacecraft # gz_atmos / gz_atmos_dual
make px4_sitl_uuv # gz_uuv_bluerov2_heavy