MCPcopy Create free account
hub / github.com/LeCAR-Lab/model-based-diffusion / reset

Method reset

mbd/envs/cartpole.py:25–38  ·  view source on GitHub ↗

Resets the environment to an initial state.

(self, rng: jax.Array)

Source from the content-addressed store, hash-verified

23 super().__init__(sys=sys, backend=backend, **kwargs)
24
25 def reset(self, rng: jax.Array) -> State:
26 """Resets the environment to an initial state."""
27 rng, rng1, rng2 = jax.random.split(rng, 3)
28
29 q = self.sys.init_q + jax.random.uniform(
30 rng1, (self.sys.q_size(),), minval=-0.01, maxval=0.01
31 ) + jp.array([0.0, jp.pi])
32 qd = jax.random.uniform(rng2, (self.sys.qd_size(),), minval=-0.01, maxval=0.01)
33 pipeline_state = self.pipeline_init(q, qd)
34 obs = self._get_obs(pipeline_state)
35 reward, done = jp.zeros(2)
36 metrics = {}
37
38 return State(pipeline_state, obs, reward, done, metrics)
39
40 def step(self, state: State, action: jax.Array) -> State:
41 """Run one timestep of the environment's dynamics."""

Callers

nothing calls this directly

Calls 2

_get_obsMethod · 0.95
StateClass · 0.85

Tested by

no test coverage detected