Multi Vehical position mismatch

When I was running two drones at the same time in a multi-vehicle simulation, and sending the same position to both drones in offboard mode, both positions were the same in the vehicle_local_position topic, but it was obvious in gazebo that one drone was high and one drone was low. When turning on multiple drones, a warning is prompted:

WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN [health_and_arming_checks] Compass senser 0 missing

I would like to know how to fix it to get the correct position information of the drone. Thanks!

What do your model and world .sdf files look like?

Can the issue you’re talking about be solved by adding a reference link at the start of the model (mentioned in my last post here)? The positions seem to be taken relative to the first link in the world and thus if your first link is a drone, the reference position will move, giving strange results.

After reading your last post, I added the reference link to the nested model, the following is my world.sdf inside the model section:

    <model name="multi_x500">
      <link name='ref'>
        <inertial>
          <pose>0 0 0 0 0 0</pose>
          <mass>0.00</mass>
          <inertia>
            <ixx>0.166667</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>0.166667</iyy>
            <iyz>0</iyz>
            <izz>0.166667</izz>
          </inertia>
        </inertial>
      </link>
      <include>
        <uri>x500</uri>
        <name>x500_1</name>
        <pose>-2.5 0 .24 0 0 0</pose>
      </include>
      <include>
        <uri>x500</uri>
        <name>x500_2</name>
        <pose>2.5 0 .24 0 0 0</pose>
      </include>
      <link name="sphere_link">
          <pose> 0 0 0.1 0 0 0</pose>
          <inertial>
            <pose>0 0 0.1 0 0 0</pose>
            <mass>0.2</mass>
            <inertia>
              <ixx>0.00011666</ixx>
              <ixy>0.0</ixy>
              <ixz>0.0</ixz>
              <iyy>0.00011666</iyy>
              <iyz>0.0</iyz>
              <izz>0.0001</izz>
            </inertia>
          </inertial>
          <collision name="collision">
            <pose>0 0 0.1 0 0 0</pose>
            <geometry>
              <sphere>
                <radius>0.1</radius>
              </sphere>
            </geometry>
          </collision>
          <visual name="visual">
            <pose>0 0 0.1 0 0 0</pose>
            <geometry>
              <sphere>
                <radius>0.1</radius>
              </sphere>
            </geometry>
            <material>
              <diffuse>1.0 1.0 1.0 1.0</diffuse>
            </material>
          </visual>
      </link>
      <include>
        <uri>rope</uri>
        <name>rope_1</name>
        <pose> -2.26 0 0.195 1.5708 0 -1.5708</pose>
      </include>
      <include>
        <uri>rope</uri>
        <name>rope_2</name>
        <pose>2.26 0 0.195 1.5708 0 1.5708</pose>
      </include>
      <joint name="joint0" type="fixed">
        <pose>-2.5 0 .24 0 0 0</pose>
        <child>x500_1::base_link</child>
        <parent>rope_1::base_link</parent>
      </joint>
      <joint name="joint1" type="fixed">
        <pose>2.5 0 .24 0 0 0</pose>
        <child>x500_2::base_link</child>
        <parent>rope_2::base_link</parent>
      </joint>
      <joint name="joint2" type="fixed">
        <pose>-0.1 0 0.1 0 0 0</pose>
        <child>rope_1::base_link</child>
        <parent>sphere_link</parent>
      </joint>
      <joint name="joint3" type="fixed">
        <pose>0.1 0 0.1 0 0 0</pose>
        <child>rope_2::base_link</child>
        <parent>sphere_link</parent>
      </joint>
    </model>

Following the method of opening multiple vehicles under the official documentation, I found that this problem also exists, and may have nothing to do with the nested model. However, after consulting the official px4 ekf documentation, I reset the following parameters under the PX4-Autopilot/src/module folder EKF2_MULTI_IMU = 2, EKF2_MULTI_MAG = 2, SENS_IMU_MODE = 0, SENS_MAG _MODE = 0. After making px4_sitl, I found that ekf is still losing data when opening the second px4.

How do you run the srcond drone ? Make sure you are assigning different mavlink id and node id to each one otherwise comamnds and packets might be conflicted
You can dohble check it by checkjng the rate of hear beat message receiving be exactly one (means no packets are conflicting)

Hi @alireza_ghaderi, Following the instructions in the documentation, I am using such a command:

PX4_SYS_AUTOSTART=4001 PX4_GZ_MODEL_NAME=x500_1 ./build/px4_sitl_default/bin/px4 -i 1
PX4_SYS_AUTOSTART=4001 PX4_GZ_MODEL_NAME=x500_2 ./build/px4_sitl_default/bin/px4 -i 2

For communication between ROS and PX4, I used micro XRCE-DDS and only had one terminal open

MicroXRCEAgent udp4 -p 8888

Should I open two micro XRCE-DDS terminals and communicate with two drones separately?

I found that when I change the parameters inside the src/modules/sensers/senser_params_mag.c file and make px4_sitl , it doesn’t change the parameters. I would like to know where to add a parameter file like senser_params_mag.c to the cmake file.

Had simillar problem that parametes would be overwritten
If i am not msitaken, you should go to build folder init.d and look for rcs file . In that you can use command " set param " for your parameters

I’ve tried this method, but I found that ekf is still lost when doing multi-computer simulation, it shouldn’t be a problem with the parameter.

have you ever figured this out?