I'm using PyBullet to basically reimplement some of the models provided by Roboschool. The reason for doing this is that I would need to be able to simulate the exact results of actions in order to have a gold standard model for planning. In other words, I need to be able to play an action and then undo it. Basically, this means being able to snapshot the current state of the simulation, then run it and restore it back.
Is there some way of accomplishing this? I didn't notice any direct API for this in PyBullet. Is this supported at the C++ layer and if so, can someone point me to the right hooks, so I can expose the functionality by patching PyBullet?
Saving and restoring full state?
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Saving and restoring full state?
That is good timing, I just implemented a first start of saveState and restoreState.
You can save the state to memory using saveState, or save the state to disk using saveBullet('filename')
THen you can restore the state using restoreState(stateId) or restoreState('filename')
Use the latest pybullet 1.7.7 or later (pip install pybullet or from github) and see this example:
https://github.com/bulletphysics/bullet ... reState.py
Make sure the number of objects/constraints etc in the world during restoreState is the same as during saveState.
You can save the state to memory using saveState, or save the state to disk using saveBullet('filename')
THen you can restore the state using restoreState(stateId) or restoreState('filename')
Use the latest pybullet 1.7.7 or later (pip install pybullet or from github) and see this example:
https://github.com/bulletphysics/bullet ... reState.py
Make sure the number of objects/constraints etc in the world during restoreState is the same as during saveState.
-
- Posts: 1
- Joined: Wed Sep 26, 2018 6:21 pm
Re: Saving and restoring full state?
I have used saveState to restore the environment to a previously saved state and it works well.
I was wondering if the environment's envStepCounter attribute is supposed to be resetted to match the saved state's counter?
Now if I reset it multiple times, the counter is not set back and the environment terminates, which is not what I need currently.
Should I save the counter value and re-assign it when restoring, or this would be an incorrect approach?
Thanks in advance!
I was wondering if the environment's envStepCounter attribute is supposed to be resetted to match the saved state's counter?
Now if I reset it multiple times, the counter is not set back and the environment terminates, which is not what I need currently.
Should I save the counter value and re-assign it when restoring, or this would be an incorrect approach?
Thanks in advance!
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Saving and restoring full state?
Where is 'envStepCounter'? If it is in Python, just reset it there.