Multiple PX4 sitl Gazebo on interacting UAV

Hi, I’m working on multiple interacting UAV in Sitl Gazebo controlled by multiple PX4 (vehicles) in QGC. The issue I’m running into is that the setup is different from the gazebo_sitl_multiple_run example since the UAV need to be connected using joints and controlled by multiple PX4 ports/vehicles in QGC. Currently I’ve created a python script to create an .sdf file including the UAV and joints with different ports for mavlink. So far no succes where the second UAV PX4 terminates the first UAV PX4 start.
Question, would it even be possible to use one .sdf with multiple (nested) UAV and joints controlled by multiple PX4 mavlinks? If so would there be an example or tips to get this to work? Thanks.

@Inonyx As long as the mavlink interface plugin in gazebo is configured to have the right TCP port, it should just work: PX4-SITL_gazebo/iris.sdf.jinja at 1b1afca3440df678167818eaf8e38f301b16bcbd · PX4/PX4-SITL_gazebo · GitHub

gazebo_sitl_multiple_run.sh is basically doing exactly that:

For your use case, you just need to do it manually

Thank you for the response. The multiple_run.sh you point at as far as I understand creates a new (same) instance and increase the port numbers. And then spawns the instances with a certain position offset. What I don’t if this would also be possible with different (nested) instances and joints with mavlink plugin calls like the following .sdf framework as example:

Drone1
Mavlink plugin (Port: 4560, Udp port: 14560)
___Drone 2
___Joint Drone1 to Drone2
___Mavlink plugin (Port: 4570, Udp port: 14570)

Or how to achieve something similar.

@Inonyx I am not sure if I understand your question. Do you have a problem when doing what you described?

@Jaeyoung-Lim Hi, I’m developing something very similar to @Inonyx , where I have a nested model using two drones because they need to be able to interact with each other. I am planning on developing a double sls system, like two drones stabilizing one load, so both drones need to be in the same sdf file, but also need separate PX4 instances. I am using nested models for the two drones, but PX4 is having issues connecting to the drone models, and I keep getting invalid local position estimate errors in QGC and PX4 continuously requests the home position endlessly. Using the multi-vehicle launch files provided is not what I am looking for since they create separate sdf files for each drone with different mavlink ids, and so I cannot create a physical link between the two in gazebo. Could you help me find a work around for this? I am using gazebo-classic and on the main branch of PX4-autopilot.

Here is what my sdf file looks like right now for the nested drone models:

<model name = "drones">

  <model name="drone1">
    <include>
      <uri>model://px4vision</uri>
      <name>drone1</name> 
      <pose>0 0 0 0 0 0</pose> 
    </include>
  </model>

  <model name="drone2">
    <include>
      <uri>model://px4vision2</uri>
      <name>drone2</name> 
      <pose>0 2 0 0 0 0</pose> 
    </include>
  </model>      


</model>