How to control simulation speed from API ?

asked 2023-03-22 03:45:01 -0500

TheotimeBalaguer gravatar image

Hello,

I launch and interact with Gazebo from the API, and I would like to programmatically change the max_step_size attribute from a (c++) program. For now, I can change it from the .sdf file of my world, like the following :

<physics name="4ms" type="ode">
            <max_step_size>0.004</max_step_size>
            <real_time_factor>-1.0</real_time_factor>
            <real_time_update_rate>250</real_time_update_rate>
</physics>

I set real_time_factor to -1 because I don't want it to interfere with the steps of the simulation. I want Gazebo to aim at a running speed of max_step_size * real_time_update_rate.

In am able to control real_time_update_rate from the ServerConfig API with ServerConfig.SetUpdateRate() :

        // Object to pass custom configuration to the server
        gz::sim::ServerConfig serverConfig;

        // Populate with some configuration, for example, the SDF file to load
        serverConfig.SetSdfFile("/home/theotime/simulation_ws/src/worlds/3_UAVS.sdf");
        serverConfig.SetUpdateRate(250); // in Hz

        // Instantiate server
        gz::sim::Server server(serverConfig);

In essence, I would like to have a ServerConfig.SetMaxStepSize(), do you know if there is a way to do that ?

  • Gazebo Garden (so gz-sim7)
  • Ubuntu 22.04

Thanks in advance !

edit retag flag offensive close merge delete