Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset models and worlds similarly to Ctrl + R in Gazebo Classic #203

Open
diegoferigo opened this issue Jun 10, 2020 · 4 comments
Open

Reset models and worlds similarly to Ctrl + R in Gazebo Classic #203

diegoferigo opened this issue Jun 10, 2020 · 4 comments
Labels
close the gap Features from Gazebo-classic enhancement New feature or request GUI Gazebo's graphical interface (not pure Ignition GUI) help wanted We accept pull requests! physics Involves Ignition Physics

Comments

@diegoferigo
Copy link
Contributor

I see a lot of new GUI-related issues to track new features, and that's great! There's one feature, though, that in Gazebo Classic was used extensively by pretty much all the people I know that's still missing: resetting a world with Ctrl + R.

Gazebo Classic had the following APIs:

I never had a look at how it was implemented previously, what I want to add to this issue as a reminder is that it would be nice having a sort of callback that world and model plugins could use to reset their state.

A simple alternative would be adding a new reset component and ask plugin developers to always check if this component is present and take action. Both would equally work, at first thought I don't see major limitations of any of them. Maybe the callback would propagate better and more clearly.

Partially related to #113.

@chapulina
Copy link
Contributor

chapulina commented Jun 10, 2020

Thank you for ticketing this!

Since this PR we already have a message interface to reset simulation time, for example:

ign service -s /world/shapes/control --reqtype ignition.msgs.WorldControl --reptype ignition.msgs.Boolean --timeout 5000 --req 'reset: {all: true}'

The way systems can react to this is by looking at UpdateInfo (not a callback or components though).

From the PR:


Systems can detect rewinds by checking:

if (_info.simTime == std::chrono::steady_clock::duration::zero())
if (_info.dt < std::chrono::steady_clock::duration::zero())

To detect pause:

if (_info.paused)

To detect time jump while paused (dt is zero during regular pause):

if (_info.paused && _info.dt != std::chrono::steady_clock::duration::zero())

So I think the main missing pieces are:

  • Button / hotkey on the GUI to call the world control service and reset. This could be added to the WorldControl ign-gui plugin.
  • Making each system react properly to jumps back in time. This is the tough part, especially for physics.

@chapulina chapulina added close the gap Features from Gazebo-classic enhancement New feature or request GUI Gazebo's graphical interface (not pure Ignition GUI) physics Involves Ignition Physics labels Jun 10, 2020
@diegoferigo
Copy link
Contributor Author

diegoferigo commented Jun 11, 2020

Great, thanks for providing these details! If I understood well, there's already the initial support for something similar than Ctrl+R, actually more advanced since it allows selecting t=t_k instead of t=0 by default. However, so far there's no System yet (including Physics) that use this feature.

Few comments:

  • While it is handy having a transport-based interface, a C++ API is still missing. I don't want to go much in detail into design choices (discussions about network transparency probably would require a separated issue) but in my opinion one of the selling points of Ignition Gazebo is the possibility of using it as a library without the need to use transport. In past few years other simulators like mujoco and pybullet got an remarkable user-base thanks to this feature and I hope that also Ignition Gazebo could reach a similar feature-set (and way beyond :)).
  • Beyond time seeking, I still think that APIs like World::Reset and Model::Reset are quite useful.
  • Regarding the reset of the Physics, I have the feeling that rolling back time (by issuing negative time steps) and resetting the state of the physics engine + aligning the ECM are two very different approaches that could be implemented separately. The former could involve a (backward?) integration, the latter just a reset of the state taking care of all the hidden states like integrator buffers in the case of PIDs (maybe the reset components of this PR could help). Using time = 0 maybe is easier since the state could be gathered from the SDF of models and world, a reset to a given time would require the logger being enabled.

@chapulina
Copy link
Contributor

so far there's no System yet (including Physics) that use this feature.

That's true for live simulations, but the LogPlayback system supports it when playing back log files.

a C++ API is still missing

That's a valid point. Since time management happens outside of the ECM, I think a component approach would be tough to implement though. Probably an event like we have for pause would be more appropriate:

https://github.com/ignitionrobotics/ign-gazebo/blob/d7cd60a7ec8d5931f54d155894b66974dbcf78a2/src/SimulationRunner.cc#L103-L104

rolling back time (by issuing negative time steps) and resetting the state of the physics engine + aligning the ECM are two very different approaches that could be implemented separately

Fully agreed. The message interface already keeps those separate, with reset / rewind separate from seek.

@diegoferigo
Copy link
Contributor Author

xref #1107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
close the gap Features from Gazebo-classic enhancement New feature or request GUI Gazebo's graphical interface (not pure Ignition GUI) help wanted We accept pull requests! physics Involves Ignition Physics
Projects
None yet
Development

No branches or pull requests

4 participants