MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / initialize_episode

Method initialize_episode

dm_control/suite/quadruped.py:426–445  ·  view source on GitHub ↗

Sets the state of the environment at the start of each episode. Args: physics: An instance of `Physics`.

(self, physics)

Source from the content-addressed store, hash-verified

424 """A quadruped task solved by bringing a ball to the origin."""
425
426 def initialize_episode(self, physics):
427 """Sets the state of the environment at the start of each episode.
428
429 Args:
430 physics: An instance of `Physics`.
431
432 """
433 # Initial configuration, random azimuth and horizontal position.
434 azimuth = self.random.uniform(0, 2*np.pi)
435 orientation = np.array((np.cos(azimuth/2), 0, 0, np.sin(azimuth/2)))
436 spawn_radius = 0.9 * physics.named.model.geom_size['floor', 0]
437 x_pos, y_pos = self.random.uniform(-spawn_radius, spawn_radius, size=(2,))
438 _find_non_contacting_height(physics, orientation, x_pos, y_pos)
439
440 # Initial ball state.
441 physics.named.data.qpos['ball_root'][:2] = self.random.uniform(
442 -spawn_radius, spawn_radius, size=(2,))
443 physics.named.data.qpos['ball_root'][2] = 2
444 physics.named.data.qvel['ball_root'][:2] = 5*self.random.randn(2)
445 super().initialize_episode(physics)
446
447 def get_observation(self, physics):
448 """Returns an observation to the agent."""

Callers

nothing calls this directly

Calls 2

initialize_episodeMethod · 0.45

Tested by

no test coverage detected