Reset gym environment with an observation

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
i14d4
Posts: 1
Joined: Tue Oct 16, 2018 2:36 pm

Reset gym environment with an observation

Post by i14d4 » Tue Oct 16, 2018 3:10 pm

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 !

User avatar
Erwin Coumans
Site Admin
Posts: 4141
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Reset gym environment with an observation

Post by Erwin Coumans » Tue Nov 06, 2018 4:59 am

You will have to manually reset the state for all objects. See resetJointState and resetBasePositionAndOrientation, resetBaseVelocity in the PyBullet Quickstart Guide.

Post Reply