Error Spawning Multiple Drones with Cameras in PX4 SITL and Gazebo Classic

I am encountering issues while attempting to spawn multiple drones with custom camera plugin in PX4 SITL using Gazebo Classic. Here are the details:

  1. When running a single drone simulation, I can successfully access camera topics (e.g., /camera/camera_info, /camera/points). However, I do not receive PX4 messages, even with the Micro-XRCE agent running in the background.
  2. When trying to spawn multiple drones (e.g., using sitl_multiple_run.sh -m iris -n 2), the drones fail to spawn properly, and Gazebo throws errors. Specifically, I encounter a segmentation fault (core dumped) and an error related to multiple nodes with the same name (/depth_camera_controller). This seems to result from conflicting plugin names or namespaces.

How can I resolve these issues to:

  • Ensure proper spawning of multiple drones with cameras.
  • Receive both camera topics and PX4 messages simultaneously?

Any guidance on fixing these problems would be greatly appreciated!

╭─munawwar at munawwar-ASUS in ~/PX4-Autopilot on main✘✘✘
╰─± ./Tools/simulation/gazebo-classic/sitl_multiple_run.sh -m iris -n 2

killing running instances
GAZEBO_PLUGIN_PATH /usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../build/px4_sitl_default/build_gazebo-classic
GAZEBO_MODEL_PATH /usr/share/gazebo-11/models:/usr/share/gazebo-11/models::/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/models
LD_LIBRARY_PATH /home/munawwar/ws_offboard_control/install/px4_ros_com/lib:/home/munawwar/ws_offboard_control/install/px4_msgs/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/humble/opt/rviz_ogre_vendor/lib:/opt/ros/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../build/px4_sitl_default/build_gazebo-classic
Starting gazebo
Gazebo multi-robot simulator, version 11.10.2
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 10.3.13.191
[Msg] Loading world file [/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/postoffice.world]
[Wrn] [OBJLoader.cc:79] Both `d` and `Tr` parameters defined for "SUV_Body". Use the value of `d` for dissolve (line 8 in .mtl.)
Both `d` and `Tr` parameters defined for "SUV_Wheels". Use the value of `d` for dissolve (line 22 in .mtl.)

starting instance 1 in /home/munawwar/PX4-Autopilot/build/px4_sitl_default/rootfs/0
Running /home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/scripts/jinja_gen.py
/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris/iris.sdf.jinja -> /tmp/iris_1.sdf
Spawning iris_1 at 0.0 2
starting instance 2 in /home/munawwar/PX4-Autopilot/build/px4_sitl_default/rootfs/1
Running /home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/scripts/jinja_gen.py
/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris/iris.sdf.jinja -> /tmp/iris_2.sdf
Spawning iris_2 at 0.0 4
[Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call
[INFO] [1732488068.753167244] [depth_camera_controller]: Publishing camera info to [/camera/camera_info]
[INFO] [1732488068.753603943] [depth_camera_controller]: Publishing depth camera info to [/camera/depth/camera_info]
[INFO] [1732488068.753856459] [depth_camera_controller]: Publishing pointcloud to [/camera/points]
[Wrn] [gazebo_gps_plugin.cpp:77] [gazebo_gps_plugin]: iris_1::gps0 using gps topic "gps0"
[Wrn] [gazebo_gps_plugin.cpp:202] [gazebo_gps_plugin] Using default update rate of 5hz 
[Msg] Connecting to PX4 SITL using TCP
[Msg] Lockstep is enabled
[Msg] Speed factor set to: 1
[Msg] Using MAVLink protocol v2.0
Starting gazebo client
[Wrn] [OBJLoader.cc:79] Both `d` and `Tr` parameters defined for "Hybrid". Use the value of `d` for dissolve (line 8 in .mtl.)
Both `d` and `Tr` parameters defined for "Wheels3". Use the value of `d` for dissolve (line 22 in .mtl.)
Both `d` and `Tr` parameters defined for "Hybrid_Interior". Use the value of `d` for dissolve (line 36 in .mtl.)
Both `d` and `Tr` parameters defined for "Windows". Use the value of `d` for dissolve (line 50 in .mtl.)

[Wrn] [FuelModelDatabase.cc:313] URI not supported by Fuel [House_1_Normal.png]
[Wrn] [SystemPaths.cc:459] File or path does not exist [""] [House_1_Normal.png]
[ERROR] [1732488069.606850562] [gazebo_ros_node]: Found multiple nodes with same name: /depth_camera_controller. This might be due to multiple plugins using the same name. Try changing one of the the plugin names or use a different ROS namespace. This error might also result from a custom plugin inheriting from another gazebo_ros plugin and the custom plugin trying to access the ROS node object hence creating multiple nodes with same name. To solve this try providing the optional node_name argument in gazebo_ros::Node::Get() function. 
╰─± ./Tools/simulation/gazebo-classic/sitl_multiple_run.sh -m iris -n 2

killing running instances
GAZEBO_PLUGIN_PATH /usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../build/px4_sitl_default/build_gazebo-classic
GAZEBO_MODEL_PATH /usr/share/gazebo-11/models:/usr/share/gazebo-11/models::/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/models
LD_LIBRARY_PATH /home/munawwar/ws_offboard_control/install/px4_ros_com/lib:/home/munawwar/ws_offboard_control/install/px4_msgs/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/humble/opt/rviz_ogre_vendor/lib:/opt/ros/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../build/px4_sitl_default/build_gazebo-classic
Starting gazebo
Gazebo multi-robot simulator, version 11.10.2
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 10.3.13.191
[Msg] Loading world file [/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/postoffice.world]
[Wrn] [OBJLoader.cc:79] Both `d` and `Tr` parameters defined for "SUV_Body". Use the value of `d` for dissolve (line 8 in .mtl.)
Both `d` and `Tr` parameters defined for "SUV_Wheels". Use the value of `d` for dissolve (line 22 in .mtl.)

starting instance 1 in /home/munawwar/PX4-Autopilot/build/px4_sitl_default/rootfs/0
Running /home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/scripts/jinja_gen.py
/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris/iris.sdf.jinja -> /tmp/iris_1.sdf
Spawning iris_1 at 0.0 2
starting instance 2 in /home/munawwar/PX4-Autopilot/build/px4_sitl_default/rootfs/1
Running /home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/scripts/jinja_gen.py
/home/munawwar/PX4-Autopilot/Tools/simulation/gazebo-classic/../../../Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris/iris.sdf.jinja -> /tmp/iris_2.sdf
Spawning iris_2 at 0.0 4
[Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call
[INFO] [1732488068.753167244] [depth_camera_controller]: Publishing camera info to [/camera/camera_info]
[INFO] [1732488068.753603943] [depth_camera_controller]: Publishing depth camera info to [/camera/depth/camera_info]
[INFO] [1732488068.753856459] [depth_camera_controller]: Publishing pointcloud to [/camera/points]
[Wrn] [gazebo_gps_plugin.cpp:77] [gazebo_gps_plugin]: iris_1::gps0 using gps topic "gps0"
[Wrn] [gazebo_gps_plugin.cpp:202] [gazebo_gps_plugin] Using default update rate of 5hz 
[Msg] Connecting to PX4 SITL using TCP
[Msg] Lockstep is enabled
[Msg] Speed factor set to: 1
[Msg] Using MAVLink protocol v2.0
Starting gazebo client
[Wrn] [OBJLoader.cc:79] Both `d` and `Tr` parameters defined for "Hybrid". Use the value of `d` for dissolve (line 8 in .mtl.)
Both `d` and `Tr` parameters defined for "Wheels3". Use the value of `d` for dissolve (line 22 in .mtl.)
Both `d` and `Tr` parameters defined for "Hybrid_Interior". Use the value of `d` for dissolve (line 36 in .mtl.)
Both `d` and `Tr` parameters defined for "Windows". Use the value of `d` for dissolve (line 50 in .mtl.)

[Wrn] [FuelModelDatabase.cc:313] URI not supported by Fuel [House_1_Normal.png]
[Wrn] [SystemPaths.cc:459] File or path does not exist [""] [House_1_Normal.png]
[ERROR] [1732488069.606850562] [gazebo_ros_node]: Found multiple nodes with same name: /depth_camera_controller. This might be due to multiple plugins using the same name. Try changing one of the the plugin names or use a different ROS namespace. This error might also result from a custom plugin inheriting from another gazebo_ros plugin and the custom plugin trying to access the ROS node object hence creating multiple nodes with same name. To solve this try providing the optional node_name argument in gazebo_ros::Node::Get() function. 
^C./Tools/simulation/gazebo-classic/sitl_multiple_run.sh: line 153: 312631 Segmentation fault      (core dumped) gzserver ${src_path}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/${world}.world --verbose $ros_args`
^C./Tools/simulation/gazebo-classic/sitl_multiple_run.sh: line 153: 312631 Segmentation fault      (core dumped) gzserver ${src_path}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/${world}.world --verbose $ros_args```

do you solve your problem i have the same problem when running multiple iris,i cannot control any of them with ros2 node

It may be possible to namespace each vehicle’s plugin so the topic names don’t conflict, however I am not entirely sure with the gazebo classic ↔ ros gz plugin