gazebosim / gz-sim

Open source robotics simulator. The latest version of Gazebo.
https://gazebosim.org
Apache License 2.0
711 stars 269 forks source link

New phase for handling user updates of world state #1815

Open arjo129 opened 1 year ago

arjo129 commented 1 year ago

Desired behavior

Currently gazebo has three states when running simulations. PreUpdate, Update and PostUpdate. In #1808, I ran into an issue where plugins have to calculate forces to be applied in the PreUpdate step and the user command system also spawns new vehicles in the PreUpdate phase. This leads to incorrect behavior sometimes as the order in which plugins in the same phase are run is not guaranteed. My current fix involves changing the logic of the plugin to make sure we minimize the effect of unexplained behavior. This however requires that System developers have deep understanding of gazebo. What I would like to propose is to have a UserEdit phase where users can interact with the world prior to having PreUpdate run. This way systems which modify the state of the world don't clash with systems which apply physical forces and new entities will always have forces applied to them before the first physical step takes place. So UserCommandSystem would always spawn objects during the UserEdit phase.

Alternatives considered

scpeters commented 6 months ago

This leads to incorrect behavior sometimes as the order in which plugins in the same phase are run is not guaranteed.

There is a prototype in #2394 for controlling order of execution for system callbacks. It could be possible to address this by thoughtful adjustment of the system priority values