[Bug] Gazebo Multi-Vehicle Simulation: PX4 not getting connected to multiple vehicles

Hi all!

I am trying to simulate multiple planes (advanced plane - 4008) in Gazebo with the latest PX4 version 1.16.0 by following steps from the official docs (Multi-Vehicle Simulation with Gazebo). When only one plane is spawned, I am able to do takeoff using QGC. If I spawn another one, the second one shows some sensor issue (mostly compass not found error) due to which arming isn’t possible.

Below are the steps I have followed.

Spawn GZ model and PX4 together

PX4_SYS_AUTOSTART=4008 \
PX4_SIM_MODEL=gz_advanced_plane \
./build/px4_sitl_default/bin/px4 -i 0

Above command spawns a plane with name gz_advanced_plane_0. Spawned next plane with the following command.

PX4_SYS_AUTOSTART=4008 \
PX4_SIM_MODEL=gz_advanced_plane \
./build/px4_sitl_default/bin/px4 -i 1

I can see this plane in QGC, but there are pre-flight errors; below are the logs.

$ PX4_SYS_AUTOSTART=4008 \
PX4_SIM_MODEL=gz_advanced_plane \
./build/px4_sitl_default/bin/px4 -i 1
INFO  [px4] instance: 1
INFO  [px4] working directory /home/xxx/PX4-Autopilot/build/px4_sitl_default/rootfs/1

______  __   __    ___ 
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] startup script: /bin/sh etc/init.d-posix/rcS 1
env SYS_AUTOSTART: 4008
INFO  [param] selected parameter default file parameters.bson
INFO  [param] importing from 'parameters.bson'
INFO  [parameters] BSON document size 324 bytes, decoded 324 bytes (INT32:15, FLOAT:2)
INFO  [param] selected parameter backup file parameters_backup.bson
INFO  [dataman] data manager file './dataman' size is 1208528 bytes
INFO  [init] Gazebo simulator
INFO  [init] gazebo already running world: default
INFO  [init] Gazebo world is ready
INFO  [init] Spawning model
INFO  [gz_bridge] world: default, model: advanced_plane_1
INFO  [lockstep_scheduler] setting initial absolute time to 52204000 us
INFO  [commander] LED: open /dev/led0 failed (22)
WARN  [health_and_arming_checks] Preflight Fail: Accel Sensor 0 missing
WARN  [health_and_arming_checks] Preflight Fail: Airspeed selector module down
WARN  [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN  [health_and_arming_checks] Preflight Fail: Gyro Sensor 0 missing
WARN  [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)
WARN  [health_and_arming_checks] Preflight Fail: No connection to the ground control station	
INFO  [airspeed_selector] No airspeed sensor detected. Switch to non-airspeed mode.	
INFO  [uxrce_dds_client] init UDP agent IP:127.0.0.1, port:8888
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18571 remote port 14550
INFO  [mavlink] partner IP: 127.0.0.1
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14581 remote port 14541
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14281 remote port 14031
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13031 remote port 13281
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2026-01-15/12_51_07.ulg	
INFO  [logger] Opened full log file: ./log/2026-01-15/12_51_07.ulg
INFO  [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO  [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO  [px4] Startup script returned successfully
pxh> INFO  [tone_alarm] home set
ERROR [mavlink] vehicle_command_ack lost, generation 8 -> 26
ERROR [mavlink] vehicle_command_ack lost, generation 8 -> 26
ERROR [mavlink] vehicle_command_ack lost, generation 8 -> 26
ERROR [mavlink] vehicle_command_ack lost, generation 8 -> 26
WARN  [health_and_arming_checks] Preflight Fail: Airspeed invalid
WARN  [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN  [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)
WARN  [health_and_arming_checks] Preflight Fail: Airspeed invalid
WARN  [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)
INFO  [airspeed_selector] Airspeed sensor healthy, start using again (-1, 1)	
WARN  [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)
INFO  [mavlink] Ignore command 512 from 255/190 to 1/1
INFO  [mavlink] Ignore command 521 from 255/190 to 1/1

I have tried spawning with the PX4_GZ_STANDALONE=1 parameter also, but I see the same behaviour.

Spawn GZ model first and later connect PX4 to it

Started the gazebo simulation as below

PX4-Autopilot$ gz sim Tools/simulation/gz/worlds/default.sdf

Spawned the advanced plane by following command, I could see the plane in Gazebo.

gz service -s /world/default/create --reqtype gz.msgs.EntityFactory --reptype gz.msgs.Boolean --timeout 3000 --req 'name: "advanced_plane_0"
sdf_filename: "/home/xxx//PX4-Autopilot/Tools/simulation/gz/models/advanced_plane/model.sdf" pose {position { x: 0 y: 0 z: 0 } orientation { w: 1 } }'

Connect PX4 to this model

PX4_SYS_AUTOSTART=4008 \
PX4_GZ_MODEL_NAME=advanced_plane_0 \
./build/px4_sitl_default/bin/px4 -i 0

I get the same error as in the above log. It is always a preflight error with sensor issues.

In all these situations, I can see gz topics corresponding to the spawned planes.

Does this mean, there might exists some issues with gazebo-bridge to PX4? I was able to spawn multiple planes in the previous PX4 version.

Looking for some direction to debug this issue.

Thanks!