<liclass="toctree-l1 current has-children"><aclass="reference internal"href="../">MuJoCo</a><inputchecked=""class="toctree-checkbox"id="toctree-checkbox-6"name="toctree-checkbox-6"role="switch"type="checkbox"/><labelfor="toctree-checkbox-6"><divclass="visually-hidden">Toggle child pages in navigation</div><iclass="icon"><svg><usehref="#svg-arrow-right"></use></svg></i></label><ulclass="current">
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/Farama-Foundation/Gymnasium/blob/main/docs/README.md">Contribute to the Docs</a></li>
<h2>Description<aclass="headerlink"href="#description"title="Permalink to this heading">#</a></h2>
<p>This environment is based on the work done by Erez, Tassa, and Todorov in
<aclass="reference external"href="http://www.roboticsproceedings.org/rss07/p10.pdf">“Infinite Horizon Model Predictive Control for Nonlinear Periodic Tasks”</a>. The environment aims to
increase the number of independent state and control variables as compared to
the classic control environments. The hopper is a two-dimensional
one-legged figure that consist of four main body parts - the torso at the
top, the thigh in the middle, the leg in the bottom, and a single foot on
which the entire body rests. The goal is to make hops that move in the
forward (right) direction by applying torques on the three hinges
connecting the four body parts.</p>
</section>
<sectionid="action-space">
<h2>Action Space<aclass="headerlink"href="#action-space"title="Permalink to this heading">#</a></h2>
<p>The action space is a <codeclass="docutils literal notranslate"><spanclass="pre">Box(-1,</span><spanclass="pre">1,</span><spanclass="pre">(3,),</span><spanclass="pre">float32)</span></code>. An action represents the torques applied between <em>links</em></p>
<thclass="head"><p>Name (in corresponding XML file)</p></th>
<thclass="head"><p>Joint</p></th>
<thclass="head"><p>Unit</p></th>
</tr>
</thead>
<tbody>
<trclass="row-even"><td><p>0</p></td>
<td><p>Torque applied on the thigh rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>thigh_joint</p></td>
<td><p>hinge</p></td>
<td><p>torque (N m)</p></td>
</tr>
<trclass="row-odd"><td><p>1</p></td>
<td><p>Torque applied on the leg rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>leg_joint</p></td>
<td><p>hinge</p></td>
<td><p>torque (N m)</p></td>
</tr>
<trclass="row-even"><td><p>3</p></td>
<td><p>Torque applied on the foot rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>foot_joint</p></td>
<td><p>hinge</p></td>
<td><p>torque (N m)</p></td>
</tr>
</tbody>
</table>
</div>
</section>
<sectionid="observation-space">
<h2>Observation Space<aclass="headerlink"href="#observation-space"title="Permalink to this heading">#</a></h2>
<p>Observations consist of positional values of different body parts of the
hopper, followed by the velocities of those individual parts
(their derivatives) with all the positions ordered before all the velocities.</p>
<p>By default, observations do not include the x-coordinate of the hopper. It may
be included by passing <codeclass="docutils literal notranslate"><spanclass="pre">exclude_current_positions_from_observation=False</span></code> during construction.
In that case, the observation space will have 12 dimensions where the first dimension
represents the x-coordinate of the hopper.
Regardless of whether <codeclass="docutils literal notranslate"><spanclass="pre">exclude_current_positions_from_observation</span></code> was set to true or false, the x-coordinate
will be returned in <codeclass="docutils literal notranslate"><spanclass="pre">info</span></code> with key <codeclass="docutils literal notranslate"><spanclass="pre">"x_position"</span></code>.</p>
<p>However, by default, the observation is a <codeclass="docutils literal notranslate"><spanclass="pre">ndarray</span></code> with shape <codeclass="docutils literal notranslate"><spanclass="pre">(11,)</span></code> where the elements
<thclass="head"><p>Name (in corresponding XML file)</p></th>
<thclass="head"><p>Joint</p></th>
<thclass="head"><p>Unit</p></th>
</tr>
</thead>
<tbody>
<trclass="row-even"><td><p>0</p></td>
<td><p>z-coordinate of the top (height of hopper)</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>rootz</p></td>
<td><p>slide</p></td>
<td><p>position (m)</p></td>
</tr>
<trclass="row-odd"><td><p>1</p></td>
<td><p>angle of the top</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>rooty</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-even"><td><p>2</p></td>
<td><p>angle of the thigh joint</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>thigh_joint</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-odd"><td><p>3</p></td>
<td><p>angle of the leg joint</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>leg_joint</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-even"><td><p>4</p></td>
<td><p>angle of the foot joint</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>foot_joint</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-odd"><td><p>5</p></td>
<td><p>velocity of the x-coordinate of the top</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>rootx</p></td>
<td><p>slide</p></td>
<td><p>velocity (m/s)</p></td>
</tr>
<trclass="row-even"><td><p>6</p></td>
<td><p>velocity of the z-coordinate (height) of the top</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>rootz</p></td>
<td><p>slide</p></td>
<td><p>velocity (m/s)</p></td>
</tr>
<trclass="row-odd"><td><p>7</p></td>
<td><p>angular velocity of the angle of the top</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>rooty</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-even"><td><p>8</p></td>
<td><p>angular velocity of the thigh hinge</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>thigh_joint</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-odd"><td><p>9</p></td>
<td><p>angular velocity of the leg hinge</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>leg_joint</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-even"><td><p>10</p></td>
<td><p>angular velocity of the foot hinge</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>foot_joint</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
</tbody>
</table>
</div>
</section>
<sectionid="rewards">
<h2>Rewards<aclass="headerlink"href="#rewards"title="Permalink to this heading">#</a></h2>
<p>The reward consists of three parts:</p>
<ulclass="simple">
<li><p><em>healthy_reward</em>: Every timestep that the hopper is healthy (see definition in section “Episode Termination”), it gets a reward of fixed value <codeclass="docutils literal notranslate"><spanclass="pre">healthy_reward</span></code>.</p></li>
<li><p><em>forward_reward</em>: A reward of hopping forward which is measured
as <em><codeclass="docutils literal notranslate"><spanclass="pre">forward_reward_weight</span></code> * (x-coordinate before action - x-coordinate after action)/dt</em>. <em>dt</em> is
the time between actions and is dependent on the frame_skip parameter
(fixed to 4), where the frametime is 0.002 - making the
default <em>dt = 4 * 0.002 = 0.008</em>. This reward would be positive if the hopper
hops forward (positive x direction).</p></li>
<li><p><em>ctrl_cost</em>: A cost for penalising the hopper if it takes
actions that are too large. It is measured as <em><codeclass="docutils literal notranslate"><spanclass="pre">ctrl_cost_weight</span></code> *
sum(action<sup>2</sup>)</em> where <em><codeclass="docutils literal notranslate"><spanclass="pre">ctrl_cost_weight</span></code></em> is a parameter set for the
control and has a default value of 0.001</p></li>
</ul>
<p>The total reward returned is <em><strong>reward</strong></em><em>=</em><em>healthy_reward + forward_reward - ctrl_cost</em> and <codeclass="docutils literal notranslate"><spanclass="pre">info</span></code> will also contain the individual reward terms</p>
</section>
<sectionid="starting-state">
<h2>Starting State<aclass="headerlink"href="#starting-state"title="Permalink to this heading">#</a></h2>
<p>All observations start in state
(0.0, 1.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) with a uniform noise
in the range of [-<codeclass="docutils literal notranslate"><spanclass="pre">reset_noise_scale</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">reset_noise_scale</span></code>] added to the values for stochasticity.</p>
</section>
<sectionid="episode-end">
<h2>Episode End<aclass="headerlink"href="#episode-end"title="Permalink to this heading">#</a></h2>
<p>The hopper is said to be unhealthy if any of the following happens:</p>
<olclass="arabic simple">
<li><p>An element of <codeclass="docutils literal notranslate"><spanclass="pre">observation[1:]</span></code> (if <codeclass="docutils literal notranslate"><spanclass="pre">exclude_current_positions_from_observation=True</span></code>, else <codeclass="docutils literal notranslate"><spanclass="pre">observation[2:]</span></code>) is no longer contained in the closed interval specified by the argument <codeclass="docutils literal notranslate"><spanclass="pre">healthy_state_range</span></code></p></li>
<li><p>The height of the hopper (<codeclass="docutils literal notranslate"><spanclass="pre">observation[0]</span></code> if <codeclass="docutils literal notranslate"><spanclass="pre">exclude_current_positions_from_observation=True</span></code>, else <codeclass="docutils literal notranslate"><spanclass="pre">observation[1]</span></code>) is no longer contained in the closed interval specified by the argument <codeclass="docutils literal notranslate"><spanclass="pre">healthy_z_range</span></code> (usually meaning that it has fallen)</p></li>
<li><p>The angle (<codeclass="docutils literal notranslate"><spanclass="pre">observation[1]</span></code> if <codeclass="docutils literal notranslate"><spanclass="pre">exclude_current_positions_from_observation=True</span></code>, else <codeclass="docutils literal notranslate"><spanclass="pre">observation[2]</span></code>) is no longer contained in the closed interval specified by the argument <codeclass="docutils literal notranslate"><spanclass="pre">healthy_angle_range</span></code></p></li>
</ol>
<p>If <codeclass="docutils literal notranslate"><spanclass="pre">terminate_when_unhealthy=True</span></code> is passed during construction (which is the default),
the episode ends when any of the following happens:</p>
<olclass="arabic simple">
<li><p>Truncation: The episode duration reaches a 1000 timesteps</p></li>
<li><p>Termination: The hopper is unhealthy</p></li>
</ol>
<p>If <codeclass="docutils literal notranslate"><spanclass="pre">terminate_when_unhealthy=False</span></code> is passed, the episode is ended only when 1000 timesteps are exceeded.</p>
</section>
<sectionid="arguments">
<h2>Arguments<aclass="headerlink"href="#arguments"title="Permalink to this heading">#</a></h2>
<p>No additional arguments are currently supported in v2 and lower.</p>
<p>v3 and v4 take <codeclass="docutils literal notranslate"><spanclass="pre">gymnasium.make</span></code> kwargs such as <codeclass="docutils literal notranslate"><spanclass="pre">xml_file</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">ctrl_cost_weight</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">reset_noise_scale</span></code>, etc.</p>
<td><p>The elements of <codeclass="docutils literal notranslate"><spanclass="pre">observation[1:]</span></code> (if <codeclass="docutils literal notranslate"><spanclass="pre">exclude_current_positions_from_observation=True</span></code>, else <codeclass="docutils literal notranslate"><spanclass="pre">observation[2:]</span></code>) must be in this range for the hopper to be considered healthy</p></td>
<td><p>The angle given by <codeclass="docutils literal notranslate"><spanclass="pre">observation[1]</span></code> (if <codeclass="docutils literal notranslate"><spanclass="pre">exclude_current_positions_from_observation=True</span></code>, else <codeclass="docutils literal notranslate"><spanclass="pre">observation[2]</span></code>) must be in this range for the hopper to be considered healthy</p></td>
<td><p>Whether or not to omit the x-coordinate from observations. Excluding the position can serve as an inductive bias to induce position-agnostic behavior in policies</p></td>
</tr>
</tbody>
</table>
</div>
</section>
<sectionid="version-history">
<h2>Version History<aclass="headerlink"href="#version-history"title="Permalink to this heading">#</a></h2>
<ulclass="simple">
<li><p>v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3</p></li>
<li><p>v3: support for <codeclass="docutils literal notranslate"><spanclass="pre">gymnasium.make</span></code> kwargs such as <codeclass="docutils literal notranslate"><spanclass="pre">xml_file</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">ctrl_cost_weight</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">reset_noise_scale</span></code>, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)</p></li>
<li><p>v2: All continuous control environments now use mujoco_py >= 1.50</p></li>
<li><p>v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.</p></li>