Page 1 of 1

Reset gym environment with an observation

Posted: Tue Oct 16, 2018 3:10 pm
by i14d4
Hi everyone !

I would like to create a controller for the gym Hopper environment. Therefore I would like to create a state/dynamics equation to use afterwards finite difference. This dynamic function should have an observation and action as input and the next state as output, so somewhat similar to this pseudo-code:

Code: Select all

def state_equation(observation, action):
	env.set_state(observation) #THIS function is missing..
	next_state, _, _, _ = env.step(action)
	return next_state
Therefore it is necessary to reset the environment with a given observation (and change the observations/state to calculate the derivative..). And this is the problem: I cannot find a solution to set the environment to a specific state given an observation.

I know that I can use following commands to save and restore a state but this doesn't help since I want to set the environment to a state given any observation without visiting and saving it before..

Code: Select all

 stateId = p.saveState() 
 p.restoreState(stateId) 
So in the end my question is: Is there any way to realize the dynamics function ? Or a solution to reset the environment with a given observation? Or any other advice to solve my problem?

Thank you very much in advance for any advice and kind regards !

Re: Reset gym environment with an observation

Posted: Tue Nov 06, 2018 4:59 am
by Erwin Coumans
You will have to manually reset the state for all objects. See resetJointState and resetBasePositionAndOrientation, resetBaseVelocity in the PyBullet Quickstart Guide.