PX4_SIM_SPEED_FACTOR on Multiple Drones in Gazebo

Looking to use PX4_SIM_SPEED_FACTOR on an empty world using gazebo_sitl_multiple_run.sh.

My full command is: PX4_SIM_SPEED_FACTOR=5 Tools/gazebo_sitl_multiple_run.sh -mplane -n2

The error I am receiving is: [Err] [gazebo_mavlink_interface.cpp:397] max_step_size of 0.004 s does not match real_time_update_rate of 1250, aborting.

Things I have tried:

  • PX4_SIM_SPEED_FACTOR=5 make px4_sitl gazebo - This part works.
    Then, I have tried running multiple with and without the env set after compiling PX4 in this way.
    The same error occurs in the latter instance.

  • Manually changing the max_step_size in empty.world. This results in a different error, not helpful.

Any suggestions as to how to run multiple with speed factor set higher?

After doing a bit more research and looking into the gazebo_mavlink_interface.cpp file, I found this:

// Adapt the real_time_update_rate according to the speed
// that we ask for in the env variable.
real_time_update_rate *= speed_factor_;
presetManager->SetCurrentProfileParam("real_time_update_rate", real_time_update_rate);

Now, this is correct code, but it is done in the wrong order (kind of). Namely, the check for 1.0 / real_time_update_rate != max_step_size is done BEFORE this calculation. This is likely correct behavior, since you don’t want to worry about the calculation in the world file

On the other hand, this calculation fails to take into account multiple drones. This is not a problem with a time scale of 1 because the scale would simply be unchanging. Nor is it a problem with having only one drone, as the values would not accumulate. But because of the Set... at the bottom there, the values accumulate for each drone.