Ardupilot + MAVROS + Airsim Multivehicle config


I am running into an issue when simulating more than 5 vehicles with the Ardupilot + MAVROS + Airsim stack. When I add a 6th vehicle, it causes the first drone to “wobble” when it takes off, all other drones work fine. Similarly, when I add a seventh vehicle the first AND the second drone “wobble” when they take off, while all the others continue to work fine. This effect seems to be consistent. Any ideas what could be causing this?

This is my mavros launch script that gets called for each drone:

<?xml version="1.0"?>
    <!-- MAVLink System ID for the drone -->
    <arg name="mavlink_sys_id" default="1" />

    <!-- Calculate port numbers based on mavlink_sys_id to ensure unique ports for each drone -->
    <arg name="num1" default="$(eval 14550 + (mavlink_sys_id) * 10)" />
    <arg name="num2" default="$(eval 14555 + (mavlink_sys_id) * 10)" />
    <arg name="group_ns" default="drone$(arg mavlink_sys_id)" />

    <!-- MAVROS and vehicle configs within a namespace to support multiple instances -->
    <group ns="$(arg group_ns)">
        <!-- MAVROS configuration -->
        <arg name="ID" value="$(eval (arg ('mavlink_sys_id') + 1))"/>

        <!-- <arg name="fcu_url" default="udp://:$(arg num1)@"/> -->
        <arg name="fcu_url" default="udp://:$(arg num1)@localhost:$(arg num2)"/>
        <!-- MAVROS node launch -->
        <include file="$(find mavros)/launch/node.launch">
            <arg name="pluginlists_yaml" value="$(find mavros)/launch/px4_pluginlists.yaml" />
            <!-- Adjust the config_yaml path as needed -->
            <arg name="config_yaml" value="$(find gs_sitl)/config/apm_config_airsim_drone$(arg mavlink_sys_id).yaml" />
            <arg name="fcu_url" value="$(arg fcu_url)"/>
            <arg name="gcs_url" value=""/>
            <arg name="tgt_system" value="$(arg ID)"/>
            <arg name="tgt_component" value="1"/>

        <!-- Set up fcuX frame to be a child of front_left_custom_body -->
        <node pkg="tf" type="static_transform_publisher" name="tf_camera_$(arg group_ns)" required="true" args="0.0 0 -0.13 0 0 0 $(arg group_ns)/camera_link  fcu$(arg mavlink_sys_id) 5"/> 

        <!-- Unrotates the camera frame so we can offset fcu1 (i.e. drone pose) with the position of the camera, might still need to apply odometry rotation to fcu1 though -->
        <node pkg="tf" type="static_transform_publisher" name="tf_fcu_offset_adjustment_$(arg group_ns)" required="true" args="0 0 0 0 0.785398 0 $(arg group_ns)/front_left_custom_body $(arg group_ns)/camera_link 5"/>

        <!-- Set up droneX_enu frame to be a child from drone1 frame -->
        <node pkg="tf" type="static_transform_publisher" name="tf_body_$(arg group_ns)" required="true" args="0 0 0 1.57 0 3.14 $(arg group_ns) $(arg group_ns)_enu 5"/> 



And this is the ardupilot launch script:


while getopts p:s:a:u: flag
    case "${flag}" in
        p) path=${OPTARG};;  # Path to ArduPilot
        s) sysid=${OPTARG};;  # MAVLink system ID
        a) airsim=${OPTARG};;  # AirSim enabled (1) or not (0)
        u) udpout=${OPTARG};;  # UDP out (optional, not used in this script but kept for future use)

echo "Path: $path"
echo "MAVLink System ID: $sysid"
echo "Airsim: $airsim"

# Navigate to the specified path
$path_raw eval cd $path

# Launch a single vehicle with the specified MAVLink system ID
if [ "$airsim" == "1" ]; then
    gnome-terminal -- .$path_raw/Tools/autotest/ -L OSPN -v ArduCopter -f airsim-copter --console --auto-sysid -I $sysid &
elif [ "$airsim" == "0" ]; then
    gnome-terminal -- .$path_raw/Tools/autotest/ -L OSPN -v ArduCopter --console --auto-sysid -I $sysid &

# Exit gracefully
exit 0