osrf / gazebo_experimental

Repo for Gazebo 9 development. Starting from entity_component_system_prototype branch on gazebo repo. This repo will be merged back into the gazebo repo in the future.
0 stars 1 forks source link

Changes to simulation time to support pausing #12

Closed osrf-migration closed 7 years ago

osrf-migration commented 7 years ago

Original report (archived issue) by Shane Loretz (Bitbucket: Shane Loretz, GitHub: sloretz).


An important feature of Gazebo is pausing a simulation and allowing the world to be changed. Currently the change in simulation time must be passed into Manager::UpdateSystems(). ECSystems are given a single variable dt which is the change in simulation time since the system was last called. This has it's own issues (see #8). This is a proposal to make the Manager class be the authority for simulation time.

Add

Change

The PauseLock increases a reference counter on construction and decreases it on destruction. It's purpose is to prevent systems running at the same time from pausing/unpausing and conflicting with each other. This solves an issue observed recently where someone wanted to synchronize gazebo with an external process by pausing it, but some unknown part of gazebo kept unpausing the simulation. This way the simulation only proceeds when all PauseLocks cease to exist.

The Duration would be an enhancement to ignition-common. It would probably be based on the ROS 1 roscpp Duration and methods would be added to ignition::common::Time to support adding and subtracting durations.

osrf-migration commented 7 years ago

Original comment by Shane Loretz (Bitbucket: Shane Loretz, GitHub: sloretz).


When not paused Manager::UpdateSystems() adds the time step to the current simulation time and updates the systems. When paused Manager::UpdateSystems() updates the systems, but the current simulation time is unchanged. A convenience method bool Manager::IsPaused() could be added for systems to check. This allows GUI / rendering / movement systems to update when paused, while systems like the physics system should check if the simulation is paused and skip the update.

osrf-migration commented 7 years ago

Original comment by Shane Loretz (Bitbucket: Shane Loretz, GitHub: sloretz).


Passing on this in favor pull request #19. Related to #8