def get_state(self): """Serializes the qpos and qvel state of the MuJoCo emulator. :return: ([float]) state """ state = MujocoState.from_mjdata(self.sim.data).flatten() return state
def set_state(self, x, forward=True): """Restores qpos and qvel, calling forward() to derive other values. :param forward (bool) whether to call forward on the environment. """ state = MujocoState.from_flattened(x, self.sim) state.set_mjdata(self.sim.data) if forward: self.sim.model.forward() # put mjData in consistent state
def __init__(self, env): if hasattr(env, '_max_episode_steps'): # We step multiple times, then reset to a previous state. # Timestep limit doesn't make much sense at this level. # (Instead, apply it outside of the controller.) raise TypeError("Environment must not have a timestep limit.") self.env = env self.sim = getattr_unwrapped(env, 'sim') state = MujocoState.from_mjdata(self.sim.data).flatten() self._state_size = len(state) self._action_size = reduce(lambda x, y: x * y, env.action_space.shape)
def set_state(self, x): state = MujocoState.from_flattened(x, self.sim) state.set_mjdata(self.sim.data) self.sim.forward() # put mjData in consistent state
def get_state(self): return MujocoState.from_mjdata(self.sim.data).flatten()
def set_state(self, x): """Restores qpos and qvel, calling forward() to derive other values.""" state = MujocoState.from_flattened(x, self.sim) state.set_mjdata(self.sim.data) self.sim.forward() # put mjData in consistent state
def get_state(self): """Serializes the qpos and qvel state of the MuJoCo emulator.""" return MujocoState.from_mjdata(self.sim.data).flatten()