JMavSim+Gazebo Multi-drone simulation

I’m begining to work on multi-UAV control, and am starting out by using a simple control node (one for each drone) to send Mavros Attitude+Thrust commands to the drones with PX4 being run by JMavSim for each drone. For 1-5 drones, this works quite well, but when I increase the number of drone to 6-10 (number depends on test) they all become unstable and crash. All controllers are completely independant in terms of input and output, so I’m thinking it has to be an issue with gazebo running to slow compared to jmavsim or vice versa, and am wondering it the clocks between the two programs are synchronized, or if anyone else has had a similar issue. Any insight into how the two programs are linked would be greatly appreciated.

Could you provide more data about what is happening?? for example the difference between sim time
and real time, frame rate is also important, type pf machine (processor + graphic card and ram)??

Also it would be quite good to tell us how you have started the simulations?? number of ports
for all the drones, model of drones, etc…

Once CPU load is higher, the px4 code or simulator code will miss cycles and at some point this can lead to control instabilities which is probably what you’re seeing.

The solution to this is lockstep SITL which means px4 and the simulator wait on each other for the next step. I’m currently working in this pull request and you can already try it out with jMAVSim.

I don’t know if it works for multiple drones though, that’s something I have not tested, and also I don’t think the simulators are synchronized when using multiple drones, so simulation time between the simulator instances can drift.

A workaround for your problem is to do profiling and find out what uses most CPU (or GPU?) resources, then optimize that while also using a faster computer.

Thank you for you suggestions Julian, I’ll find a desktop computer to run the tests on (I’m currently using a VM on a laptop) and try the other solutions you suggested and give an update on what works.

Thanks Shrit, for your suggestions on presenting the problem. I’ll give full details once I’ve got them! I’m away from my computer for the next few days, but I can say from memory that it is using the Iris drone on a virtual machine allocated with half the resources of my macbook pro. All the simulations were started from a ROS launch file. The real time factor on Gazebo was about 0.2, and the frame rate around 1.