The MicroXRCE Agent not working with multiple px4 iris drone models in a gazebo simulation

Hello! I am trying to create a gazebo simulation with multiple drones that I want to fly to different positions in a gazebo world to simulate a surveying task. I am using the PX4-Autopilot firmware, gazebo-classic 11 and ROS2 foxy running on ubuntu 20.04, and I am using the XRCE-DDS bridge for the client-agent communication. When I load a gazebo world with just one PX4 iris drone model and run MicroXRCEAgent udp4 -p 8888 to create the agent, everything works, and I can see that the topics for me to interact with the drone model are created. However, when I load a gazebo world with multiple px4 iris drone models (using ./Tools/simulation/gazebo-classic/sitl_multiple_run.sh -t px4_sitl_rtps -m iris -n 2) and run MicroXRCEAgent udp4 -p 8888, the agent doesn’t connect to the clients and the topics are not created. QGroundControl shows me that they are not connected as well. Surprisingly, this used to work without giving me any troubles, I started noticing this behavior a few days ago. If anyone knows what might be causing this and how I can fix it, please let me know, I would greatly appreciate it. Thank you!

which PX4 version / tag / commit are you using?

Thanks for a quick response, I’m using the main branch tag v1.14.0-beta2.

Oh I see!
You have to modify a bit your simulation startup script then. The rtps targets have been removed!
Please give a look at the documentation:

Thanks for sharing the documentation, I went through it but I am still not really sure of what exactly do I need to change. After going through the documentation, my guess was that I need to change something about the UDP ports configuration in the file located at this path β€œ/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/rcS”, but I am not really sure which files to edit. I have only been working with the simulation for a few months so I am not that experienced and I am probably missing something trivial, any additional guidance on what exactly I need to change would be very helpful. Thank you!

To clarify my problem further, for simulating multiple drones I used to run ./Tools/simulation/gazebo-classic/sitl_multiple_run.sh -t px4_sitl_rtps -m iris -n 2 to launch the simulation with two drones, and then I only needed to run one MicroXRCE Agent using β€œMicroXRCEAgent udp4 -p 8888” and it connected to all the clients of the drones in the simulation. Using ROS2 nodes or QgroundControl I could control one specific drone or multiple drones at the same time. Now when I load multiple drones and run the MicroXRCE Agent, I don’t see the drones in QgroundControl and topics I can use to interact with the drones using ROS2 nodes are not created (all this still works when I run the simulation with only one drone model using β€œmake px4_sitl gazebo-classic”). This started happening like 2 days ago and I think I did not change anything that would have caused this. I am guessing that the PX4-Autopilot firmware github repo was updated and I need to change some settings to accommodate those updates, but I am not sure exactly what I need to change. Thanks!

Update: I ended fixing it by changing the target (-t) flag form px4_sitl_rtps to px4_sitl_default in this command ./Tools/simulation/gazebo-classic/sitl_multiple_run.sh -t px4_sitl_rtps -m iris -n 2. Thank you so much for your help, I appreciate it!

2 Likes

Yes, that was the right thing to do - RTPS needed specific firmware but with MicroXRCE you can just use the defaults.

This is in the migration guide: uXRCE-DDS (PX4-ROS 2/DDS Bridge) | PX4 User Guide

I’ve made this PR to make it even more crystal clear: uxrce_dds.md - spell it out for _rtps targets by hamishwillee Β· Pull Request #2626 Β· PX4/PX4-user_guide Β· GitHub

2 Likes