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

Class Humanoid

dm_control/suite/humanoid.py:132–207  ·  view source on GitHub ↗

A humanoid task.

Source from the content-addressed store, hash-verified

130
131
132class Humanoid(base.Task):
133 """A humanoid task."""
134
135 def __init__(self, move_speed, pure_state, random=None):
136 """Initializes an instance of `Humanoid`.
137
138 Args:
139 move_speed: A float. If this value is zero, reward is given simply for
140 standing up. Otherwise this specifies a target horizontal velocity for
141 the walking task.
142 pure_state: A bool. Whether the observations consist of the pure MuJoCo
143 state or includes some useful features thereof.
144 random: Optional, either a `numpy.random.RandomState` instance, an
145 integer seed for creating a new `RandomState`, or None to select a seed
146 automatically (default).
147 """
148 self._move_speed = move_speed
149 self._pure_state = pure_state
150 super().__init__(random=random)
151
152 def initialize_episode(self, physics):
153 """Sets the state of the environment at the start of each episode.
154
155 Args:
156 physics: An instance of `Physics`.
157
158 """
159 # Find a collision-free random initial configuration.
160 penetrating = True
161 while penetrating:
162 randomizers.randomize_limited_and_rotational_joints(physics, self.random)
163 # Check for collisions.
164 physics.after_reset()
165 penetrating = physics.data.ncon > 0
166 super().initialize_episode(physics)
167
168 def get_observation(self, physics):
169 """Returns either the pure state or a set of egocentric features."""
170 obs = collections.OrderedDict()
171 if self._pure_state:
172 obs['position'] = physics.position()
173 obs['velocity'] = physics.velocity()
174 else:
175 obs['joint_angles'] = physics.joint_angles()
176 obs['head_height'] = physics.head_height()
177 obs['extremities'] = physics.extremities()
178 obs['torso_vertical'] = physics.torso_vertical_orientation()
179 obs['com_velocity'] = physics.center_of_mass_velocity()
180 obs['velocity'] = physics.velocity()
181 return obs
182
183 def get_reward(self, physics):
184 """Returns a reward to the agent."""
185 standing = rewards.tolerance(physics.head_height(),
186 bounds=(_STAND_HEIGHT, float('inf')),
187 margin=_STAND_HEIGHT/4)
188 upright = rewards.tolerance(physics.torso_upright(),
189 bounds=(0.9, float('inf')), sigmoid='linear',

Callers 4

standFunction · 0.70
walkFunction · 0.70
runFunction · 0.70
run_pure_stateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…