0
$\begingroup$

I can control the length of a Gazebo step size through the world's SDF. Example with max_step_size=4 ms :

<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>

But, can I also set this value through an API call ?

Another simulation parameter, the Update rate, can be controlled through the .SDF or programmatically with a call to gz::sim::ServerConfig::SetUpdateRate. Example:

// 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(config["world_sdf_path"].as<std::string>());
serverConfig.SetUpdateRate(update_rate); // in Hz

I would like to do the same for max_step_size.

Note 1: Gazebo's SimulationRunner seem to have this capability (see this method), but I don't know how to access it from a "user" point of view.

Note 2: Transfer from unanswered answers.gazebosim question

$\endgroup$
2
  • $\begingroup$ Can you give more background info why you want to do this? I.e. what you want to achieve by changing this programmatically? $\endgroup$
    – JRTG
    Commented Jul 1, 2023 at 16:43
  • $\begingroup$ I do co-simulation with another simulator (namely ns-3, a network simulator), so I need to control the execution steps of Gazebo finely. I chose to keep a fixed step_size during the whole simulation. The user edit a global configuration file and has the ability to define max_step_size. For now, I have to inject the user choice in the .sdf file, but this is ugly XML editing, which is less elegant than an API call. The way REAL_TIME_update_rate can be changed is way more convenient and readable, but clearly this is just for comfort as it still can be done with xml editing. $\endgroup$ Commented Jul 3, 2023 at 8:11

1 Answer 1

2
$\begingroup$

The set_physics service is able to set the max_step_size using a gz::msgs::Physics. I don't see a tutorial for this, but some code from the user_commands integration test can be used as a reference:

$\endgroup$
1
  • 1
    $\begingroup$ Worked like a charm. Thank you for the pointer ! $\endgroup$ Commented Jul 12, 2023 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.