Multivehicle python

Hi everyone, it’s possible to connect 2 drones with gazeblo-classic on QGC, using python? Because i’ve tryied the basic connection model and it doesn’t work.

Have you tried Multi-Vehicle Simulation with Gazebo Classic | PX4 User Guide

Yes, and it doesn’t work… I’m trying to write down 2 python script to control a mission for each drone:
for drone 1:

import asyncio
from mavsdk import System
from mavsdk.mission import (MissionItem, MissionPlan)

async def run():
    drone = System(sysid=2)
    await drone.connect(system_address="udp://:14541")

    await drone.action.arm()

    mission_items = []
    #mission_items.append(MissionItem(47.398039859999997, 8.5455725400000002, 2.5, 5, 
    #                                 True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    mission_items.append(MissionItem(47.3978133, 8.5456344, 2.5, 5, 
     True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    
    mission_items.append(MissionItem(47.3977222, 8.5457436, 2.5, 5, 
     True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    
    mission_items.append(MissionItem(47.3976182, 8.5456850, 2.5, 5, 
     True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    
    mission_items.append(MissionItem(47.3977494, 8.5455343, 2.5, 5, 
     True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    
    

    mission_plan = MissionPlan(mission_items)
    print(drone)
    await drone.mission.upload_mission(mission_plan)
    await drone.mission.start_mission()

asyncio.get_event_loop().run_until_complete(run())

for drone 2:

import asyncio
from mavsdk import System
from mavsdk.mission import (MissionItem, MissionPlan)

async def run():
    drone = System(sysid=2)
    await drone.connect(system_address="udp://:14542")
    sysid = drone._sysid
    compid = drone._compid
    print("sysid: {sysid}")
    print("compid: {compid}")

    await drone.action.arm()

    mission_items = []
    #mission_items.append(MissionItem(47.398039859999997, 8.5455725400000002, 2.5, 5, 
    #                                 True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    mission_items.append(MissionItem(47.3978133, 8.5456344, 2.5, 5, 
     True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    
    mission_items.append(MissionItem(47.3977222, 8.5457436, 2.5, 5, 
     True, float('nan'), float('nan'), MissionItem.CameraAction.NONE, float('nan'), float('nan'),float('nan'),float('nan'),float('nan')))
    
    
    # ... aggiungi altri waypoint come necessario

    mission_plan = MissionPlan(mission_items)
    print(drone)
    await drone.mission.upload_mission(mission_plan)
    await drone.mission.start_mission()

asyncio.get_event_loop().run_until_complete(run())

@Giovanni How does it fail? It should work as far as I am concerned

@Jaeyoung-Lim Many thanks, solved it. I think that the problem was the installation of Gazebo-classic, i just uninstall and re-install it again and it works !