Pegasus Simulator Mavros port issue

Iā€™m using the Pegasus simulators 2_px4_multi_vehicle.py.
This launches 5 instances of PX4:


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

px4 starting.

INFO  [px4] Calling startup script: /bin/sh /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/r
Creating symlink /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/ -> /tmp/tmp3jdma62e/etc

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

px4 starting.

INFO  [px4] Calling startup script: /bin/sh /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/r
Creating symlink /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/ -> /tmp/tmp4p684zew/etc

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

px4 starting.

INFO  [px4] Calling startup script: /bin/sh /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/r
Creating symlink /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/ -> /tmp/tmpqzqz0c83/etc

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

px4 starting.

INFO  [px4] Calling startup script: /bin/sh /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/r
Creating symlink /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/ -> /tmp/tmppqw2z_si/etc

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

px4 starting.

INFO  [px4] Calling startup script: /bin/sh /home/ajifoster3/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/r
INFO  [init] found model autostart file as SYS_AUTOSTART=10016
INFO  [init] found model autostart file as SYS_AUTOSTART=10016
INFO  [param] selected parameter default file eeprom/parameters_10016
INFO  [init] found model autostart file as SYS_AUTOSTART=10016
[param] parameter file not found, creating eeprom/parameters_10016
INFO  [init] found model autostart file as SYS_AUTOSTART=10016
INFO  [param] selected parameter default file eeprom/parameters_10016
[param] parameter file not found, creating eeprom/parameters_10016
INFO  [init] found model autostart file as SYS_AUTOSTART=10016
INFO  [param] selected parameter default file eeprom/parameters_10016
[param] parameter file not found, creating eeprom/parameters_10016
INFO  [param] selected parameter default file eeprom/parameters_10016
[param] parameter file not found, creating eeprom/parameters_10016
INFO  [param] selected parameter default file eeprom/parameters_10016
[param] parameter file not found, creating eeprom/parameters_10016
  SYS_AUTOCONFIG: curr: 0 -> new: 1
  SYS_AUTOCONFIG: curr: 0 -> new: 1
  SYS_AUTOCONFIG: curr: 0 -> new: 1
  SYS_AUTOCONFIG: curr: 0 -> new: 1
  SYS_AUTOCONFIG: curr: 0 -> new: 1
* MAV_SYS_ID: curr: 1 -> new: 3
* MAV_SYS_ID: curr: 1 -> new: 2
  SYS_AUTOSTART: curr: 0 -> new: 10016
* MAV_SYS_ID: curr: 1 -> new: 5
* MAV_SYS_ID: curr: 1 -> new: 4
  SYS_AUTOSTART: curr: 0 -> new: 10016
  CAL_ACC0_ID: curr: 0 -> new: 1310988
  SYS_AUTOSTART: curr: 0 -> new: 10016
  SYS_AUTOSTART: curr: 0 -> new: 10016
  SYS_AUTOSTART: curr: 0 -> new: 10016
  CAL_ACC0_ID: curr: 0 -> new: 1310988
  CAL_GYRO0_ID: curr: 0 -> new: 1310988
  CAL_ACC0_ID: curr: 0 -> new: 1310988
  CAL_ACC0_ID: curr: 0 -> new: 1310988
  CAL_ACC0_ID: curr: 0 -> new: 1310988
  CAL_GYRO0_ID: curr: 0 -> new: 1310988
  CAL_ACC1_ID: curr: 0 -> new: 1310996
  CAL_GYRO0_ID: curr: 0 -> new: 1310988
  CAL_GYRO0_ID: curr: 0 -> new: 1310988
  CAL_GYRO0_ID: curr: 0 -> new: 1310988
  CAL_ACC1_ID: curr: 0 -> new: 1310996
  CAL_ACC1_ID: curr: 0 -> new: 1310996
  CAL_GYRO1_ID: curr: 0 -> new: 1310996
  CAL_ACC1_ID: curr: 0 -> new: 1310996
  CAL_ACC1_ID: curr: 0 -> new: 1310996
  CAL_GYRO1_ID: curr: 0 -> new: 1310996
  CAL_GYRO1_ID: curr: 0 -> new: 1310996
  CAL_ACC2_ID: curr: 0 -> new: 1311004
  CAL_GYRO1_ID: curr: 0 -> new: 1310996
  CAL_GYRO1_ID: curr: 0 -> new: 1310996
  CAL_ACC2_ID: curr: 0 -> new: 1311004
  CAL_ACC2_ID: curr: 0 -> new: 1311004
  CAL_GYRO2_ID: curr: 0 -> new: 1311004
  CAL_ACC2_ID: curr: 0 -> new: 1311004
  CAL_ACC2_ID: curr: 0 -> new: 1311004
  CAL_GYRO2_ID: curr: 0 -> new: 1311004
* CAL_MAG0_ID: curr: 0 -> new: 197388
  CAL_GYRO2_ID: curr: 0 -> new: 1311004
  CAL_GYRO2_ID: curr: 0 -> new: 1311004
  CAL_GYRO2_ID: curr: 0 -> new: 1311004
* CAL_MAG0_ID: curr: 0 -> new: 197388
* CAL_MAG0_ID: curr: 0 -> new: 197388
* CAL_MAG1_ID: curr: 0 -> new: 197644
* CAL_MAG0_ID: curr: 0 -> new: 197388
* CAL_MAG0_ID: curr: 0 -> new: 197388
* CAL_MAG1_ID: curr: 0 -> new: 197644
* CAL_MAG1_ID: curr: 0 -> new: 197644
* SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
* CAL_MAG1_ID: curr: 0 -> new: 197644
* CAL_MAG1_ID: curr: 0 -> new: 197644
* SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
* SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
* SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
* SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
* SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000
* SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
* SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
* SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
* SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010
* SYS_AUTOCONFIG: curr: 1 -> new: 0
* SYS_AUTOCONFIG: curr: 1 -> new: 0
* SYS_AUTOCONFIG: curr: 1 -> new: 0
* SYS_AUTOCONFIG: curr: 1 -> new: 0
* SYS_AUTOCONFIG: curr: 1 -> new: 0
* IMU_INTEG_RATE: curr: 200 -> new: 250
* IMU_INTEG_RATE: curr: 200 -> new: 250
* IMU_INTEG_RATE: curr: 200 -> new: 250
* IMU_INTEG_RATE: curr: 200 -> new: 250
* IMU_INTEG_RATE: curr: 200 -> new: 250
INFO  [dataman] data manager file './dataman' size is 7866640 bytes
INFO  [dataman] data manager file './dataman' size is 7866640 bytes
INFO  [dataman] data manager file './dataman' size is 7866640 bytes
INFO  [dataman] data manager file './dataman' size is 7866640 bytes
INFO  [dataman] data manager file './dataman' size is 7866640 bytes
PX4 SIM HOST: localhost
PX4 SIM HOST: localhost
PX4 SIM HOST: localhost
PX4 SIM HOST: localhost
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4560
PX4 SIM HOST: localhost
INFO  [simulator] Simulator connected on TCP port 4560.
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4563
INFO  [simulator] Simulator connected on TCP port 4563.
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4564
INFO  [simulator] Simulator connected on TCP port 4564.
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4561
INFO  [simulator] Simulator connected on TCP port 4561.
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4562
INFO  [simulator] Simulator connected on TCP port 4562.
2024-02-02 11:33:44 [15,673ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Waiting for first hearbeat
2024-02-02 11:33:44 [15,680ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Received first hearbeat
2024-02-02 11:33:44 [15,681ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Waiting for first hearbeat
2024-02-02 11:33:44 [15,681ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Received first hearbeat
2024-02-02 11:33:44 [15,682ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Waiting for first hearbeat
2024-02-02 11:33:44 [15,682ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Received first hearbeat
2024-02-02 11:33:44 [15,683ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Waiting for first hearbeat
2024-02-02 11:33:44 [15,683ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Received first hearbeat
2024-02-02 11:33:44 [15,683ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Waiting for first hearbeat
2024-02-02 11:33:44 [15,683ms] [Warning] [pegasus.simulator.logic.backends.mavlink_backend] Received first hearbeat
INFO  [commander] LED: open /dev/led0 failed (22)
INFO  [commander] LED: open /dev/led0 failed (22)
INFO  [commander] LED: open /dev/led0 failed (22)
INFO  [commander] LED: open /dev/led0 failed (22)
INFO  [commander] LED: open /dev/led0 failed (22)
* PWM_AUX_OUT: curr: 0 -> new: 1234
* PWM_AUX_OUT: curr: 0 -> new: 1234
* PWM_AUX_OUT: curr: 0 -> new: 1234
* PWM_MAIN_OUT: curr: 0 -> new: 1234
* PWM_MAIN_OUT: curr: 0 -> new: 1234
* PWM_AUX_OUT: curr: 0 -> new: 1234
* PWM_MAIN_OUT: curr: 0 -> new: 1234
* PWM_AUX_OUT: curr: 0 -> new: 1234
* PWM_MAIN_OUT: curr: 0 -> new: 1234
* PWM_MAIN_OUT: curr: 0 -> new: 1234
INFO  [init] Mixer: etc/mixers/quad_w.main.mix on /dev/pwm_output0
INFO  [init] Mixer: etc/mixers/quad_w.main.mix on /dev/pwm_output0
INFO  [init] Mixer: etc/mixers/quad_w.main.mix on /dev/pwm_output0
INFO  [init] setting PWM_AUX_OUT none
INFO  [init] setting PWM_AUX_OUT none
INFO  [init] Mixer: etc/mixers/quad_w.main.mix on /dev/pwm_output0
INFO  [init] Mixer: etc/mixers/quad_w.main.mix on /dev/pwm_output0
INFO  [init] setting PWM_AUX_OUT none
INFO  [init] setting PWM_AUX_OUT none
INFO  [init] setting PWM_AUX_OUT none
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18574 remote port 14550
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18573 remote port 14550
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18572 remote port 14550
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18571 remote port 14550
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14584 remote port 14544
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14583 remote port 14543
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14582 remote port 14542
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14581 remote port 14541
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14284 remote port 14034
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14283 remote port 14033
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14282 remote port 14032
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14281 remote port 14031
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13034 remote port 13284
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13033 remote port 13283
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13032 remote port 13282
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13031 remote port 13281
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2024-02-02/11_33_44.ulg	
INFO  [logger] Opened full log file: ./log/2024-02-02/11_33_44.ulg
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2024-02-02/11_33_44.ulg	
INFO  [logger] Opened full log file: ./log/2024-02-02/11_33_44.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  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2024-02-02/11_33_44.ulg	
INFO  [logger] Opened full log file: ./log/2024-02-02/11_33_44.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  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2024-02-02/11_33_44.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  [logger] Opened full log file: ./log/2024-02-02/11_33_44.ulg
INFO  [px4] Startup script returned successfully
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2024-02-02/11_33_44.ulg	
INFO  [logger] Opened full log file: ./log/2024-02-02/11_33_44.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
INFO  [px4] Startup script returned successfully
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
INFO  [px4] Startup script returned successfully
INFO  [mavlink] partner IP: 127.0.0.1
INFO  [tone_alarm] home set
INFO  [tone_alarm] home set
INFO  [tone_alarm] home set
INFO  [tone_alarm] home set
INFO  [tone_alarm] home set
INFO  [tone_alarm] notify negative
INFO  [tone_alarm] notify negative
INFO  [tone_alarm] notify negative
INFO  [tone_alarm] notify negative
INFO  [tone_alarm] notify negative
INFO  [mavlink] partner IP: 127.0.0.1
INFO  [mavlink] partner IP: 127.0.0.1
INFO  [mavlink] partner IP: 127.0.0.1
INFO  [mavlink] partner IP: 127.0.0.1
INFO  [mavlink] partner IP: 127.0.0.1

I can then run: ros2 launch mavros px4.launch fcu_url:=udp://:14540@ namespace:=mavros/uav0
I get the following

[mavros_node-1] [INFO] [1706875150.252915931] [mavros.uav0.mavros]: Known MAVLink dialects: common ardupilotmega ASLUAV AVSSUAS all csAirLink cubepilot development icarous matrixpilot paparazzi standard storm32 uAvionix ualberta
[mavros_node-1] [INFO] [1706875150.252919732] [mavros.uav0.mavros]: MAVROS UAS via /uas1 started. MY ID 1.191, TARGET ID 1.1
[mavros_node-1] [INFO] [1706875150.257578376] [mavros.uav0.imu]: IMU: High resolution IMU detected!
[mavros_node-1] [INFO] [1706875150.273064555] [mavros.uav0.imu]: IMU: Attitude quaternion IMU detected!
[mavros_node-1] [INFO] [1706875150.318963572] [mavros.uav0.mavros_router]: link[1001] detected remote address 1.191
[mavros_node-1] [INFO] [1706875150.992474813] [mavros.uav0.mavros]: CON: Got HEARTBEAT, connected. FCU: PX4 Autopilot
[mavros_node-1] [INFO] [1706875150.992556098] [mavros.uav0.mission]: WP: detected enable_partial_push: 0
[mavros_node-1] [INFO] [1706875150.992640666] [mavros.uav0.imu]: IMU: High resolution IMU detected!
[mavros_node-1] [INFO] [1706875151.005806791] [mavros.uav0.imu]: IMU: Attitude quaternion IMU detected!
[mavros_node-1] [INFO] [1706875151.994474865] [mavros.uav0.geofence]: GF: Using MISSION_ITEM_INT
[mavros_node-1] [INFO] [1706875151.994498855] [mavros.uav0.rallypoint]: RP: Using MISSION_ITEM_INT
[mavros_node-1] [INFO] [1706875151.994505428] [mavros.uav0.mission]: WP: Using MISSION_ITEM_INT
[mavros_node-1] [INFO] [1706875151.994510919] [mavros.uav0.sys]: VER: 1.1: Capabilities         0x000000000000e4ff
[mavros_node-1] [INFO] [1706875151.994517229] [mavros.uav0.sys]: VER: 1.1: Flight software:     010d02ff (46a12a09bf000000)
[mavros_node-1] [INFO] [1706875151.994520878] [mavros.uav0.sys]: VER: 1.1: Middleware software: 010d02ff (46a12a09bf000000)
[mavros_node-1] [INFO] [1706875151.994523519] [mavros.uav0.sys]: VER: 1.1: OS software:         060500ff (91bece51afbe7da9)
[mavros_node-1] [INFO] [1706875151.994525940] [mavros.uav0.sys]: VER: 1.1: Board hardware:      00000001
[mavros_node-1] [INFO] [1706875151.994528512] [mavros.uav0.sys]: VER: 1.1: VID/PID:             0000:0000
[mavros_node-1] [INFO] [1706875151.994531354] [mavros.uav0.sys]: VER: 1.1: UID:                 4954414c44494e4f
[mavros_node-1] [WARN] [1706875151.997398449] [mavros.uav0.cmd]: CMD: Unexpected command 520, result 0

And can subscribe to mavros/uav0 topics.

I then cancel ros2 mavros.

I run: ros2 launch mavros px4.launch fcu_url:=udp://:14541@ namespace:=mavros/uav1

and get the following:

[mavros_node-1] [INFO] [1706875238.583627104] [mavros.uav1.mavros]: Known MAVLink dialects: common ardupilotmega ASLUAV AVSSUAS all csAirLink cubepilot development icarous matrixpilot paparazzi standard storm32 uAvionix ualberta
[mavros_node-1] [INFO] [1706875238.583630414] [mavros.uav1.mavros]: MAVROS UAS via /uas1 started. MY ID 1.191, TARGET ID 1.1
[mavros_node-1] [INFO] [1706875239.485445954] [mavros.uav1.mavros_router]: link[1001] detected remote address 1.191
[mavros_node-1] [WARN] [1706875240.493137911] [mavros.uav1.sys]: VER: broadcast request timeout, retries left 4
[mavros_node-1] [WARN] [1706875241.491921075] [mavros.uav1.sys]: VER: broadcast request timeout, retries left 3
[mavros_node-1] [WARN] [1706875242.493285637] [mavros.uav1.sys]: VER: unicast request timeout, retries left 2
[mavros_node-1] [WARN] [1706875243.491821082] [mavros.uav1.sys]: VER: unicast request timeout, retries left 1
[mavros_node-1] [WARN] [1706875244.492012286] [mavros.uav1.sys]: VER: unicast request timeout, retries left 0
[mavros_node-1] [WARN] [1706875245.491941636] [mavros.uav1.sys]: VER: your FCU don't support AUTOPILOT_VERSION, switched to default capabilities

And recieve no data from the ros2 topics.

Now comes the interesting part, If I run:
ros2 launch mavros px4.launch fcu_url:=udp://:14540@ namespace:=mavros/uav0
and then
ros2 launch mavros px4.launch fcu_url:=udp://:14541@ namespace:=mavros/uav1

mavros/uav1 published data for uav0

This is how Pegasus sim launches PX4, the IDs are being fed in correctly:

    def launch_px4(self):
        """
        Method that will launch a px4 instance with the specified configuration
        """
        self.px4_process = subprocess.Popen(
            [
                self.px4_dir + "/build/px4_sitl_default/bin/px4",
                self.px4_dir + "/ROMFS/px4fmu_common/",
                "-s",
                self.rc_script,
                "-i",
                str(self.vehicle_id),
                "-d",
            ],
            cwd=self.root_fs.name,
            shell=False,
            env=self.environment,
        )