Lockstep implementation in Gazebo


I willingly ignored the absence of lockstep mechanism with the “new” Gazebo for a while but I am starting to realize how important it would be to my use-case (UAV fleet control with Gazebo Garden). Indeed when the number of PX4 SITL instances increase, the computation load for PX4 increase faster than the one of Gazebo, thus leading to de-synchronization.

I would like to implement an optional lockstep functionality to the PX4 - Gazebo couple, but I don’t want to reinvent the wheel and as I know lockstep was already implemented with gazebo-classic, I seek advise on how to implement this.

My questions are:

  1. What modules should be updated ?
  2. How to properly test that I didn’t break anything ?
  3. Is there already a way of telling the PX4 SITL “do your computations for the next X microseconds” ? (that could be called by a coordinator program, outside of Gazebo)