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

Method step

dm_control/rl/control.py:99–127  ·  view source on GitHub ↗

Updates the environment using the action and returns a `TimeStep`.

(self, action)

Source from the content-addressed store, hash-verified

97 observation=observation)
98
99 def step(self, action):
100 """Updates the environment using the action and returns a `TimeStep`."""
101
102 if self._reset_next_step:
103 return self.reset()
104
105 self._task.before_step(action, self._physics)
106 self._physics.step(self._n_sub_steps)
107 self._task.after_step(self._physics)
108
109 reward = self._task.get_reward(self._physics)
110 observation = self._task.get_observation(self._physics)
111 if self._flat_observation:
112 observation = flatten_observation(observation)
113
114 self._step_count += 1
115 if self._step_count >= self._step_limit:
116 discount = 1.0
117 else:
118 discount = self._task.get_termination(self._physics)
119
120 episode_over = discount is not None
121
122 if episode_over:
123 self._reset_next_step = True
124 return dm_env.TimeStep(
125 dm_env.StepType.LAST, reward, discount, observation)
126 else:
127 return dm_env.TimeStep(dm_env.StepType.MID, reward, 1.0, observation)
128
129 def action_spec(self):
130 """Returns the action specification for this environment."""

Callers 13

test_timeoutMethod · 0.95
test3DDetectionMethod · 0.95
test2DDetectionMethod · 0.95
testActivationMethod · 0.95
test_contactMethod · 0.95
test_ghost_propMethod · 0.95

Calls 8

resetMethod · 0.95
flatten_observationFunction · 0.85
before_stepMethod · 0.45
stepMethod · 0.45
after_stepMethod · 0.45
get_rewardMethod · 0.45
get_observationMethod · 0.45
get_terminationMethod · 0.45

Tested by 13

test_timeoutMethod · 0.76
test3DDetectionMethod · 0.76
test2DDetectionMethod · 0.76
testActivationMethod · 0.76
test_contactMethod · 0.76
test_ghost_propMethod · 0.76