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

Method __init__

mbd/envs/car2d.py:44–71  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

42
43class Car2d:
44 def __init__(self):
45 self.dt = 0.1
46 self.H = 50
47 r_obs = 0.3
48 self.obs_center = jnp.array(
49 [
50 [-r_obs * 3, r_obs * 2],
51 [-r_obs * 2, r_obs * 2],
52 [-r_obs * 1, r_obs * 2],
53 [0.0, r_obs * 2],
54 [0.0, r_obs * 1],
55 [0.0, 0.0],
56 [0.0, -r_obs * 1],
57 [-r_obs * 3, -r_obs * 2],
58 [-r_obs * 2, -r_obs * 2],
59 [-r_obs * 1, -r_obs * 2],
60 [0.0, -r_obs * 2],
61 ]
62 )
63 self.obs_radius = r_obs # Radius of the obstacle
64 self.x0 = jnp.array([-0.5, 0.0, jnp.pi*3/2])
65 self.xg = jnp.array([0.5, 0.0, 0.0])
66 self.xref = jnp.load(f"{mbd.__path__[0]}/assets/car2d_xref.npy")
67 # self.xref = jnp.load(f"{mbd.__path__[0]}/../figure/car2d_xref.npy")
68 xref_diff = jnp.diff(self.xref, axis=0)
69 theta = jnp.arctan2(xref_diff[:, 0], xref_diff[:, 1])
70 self.thetaref = jnp.append(theta, theta[-1])
71 self.rew_xref = jax.vmap(self.get_reward)(self.xref).mean()
72
73 def reset(self, rng: jax.Array):
74 """Resets the environment to an initial state."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected