<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 by P. Wawrzyński in
<aclass="reference external"href="http://staff.elka.pw.edu.pl/~pwawrzyn/pub-s/0812_LSCLRR.pdf">“A Cat-Like Robot Real-Time Learning to Run”</a>.
The HalfCheetah is a 2-dimensional robot consisting of 9 links and 8
joints connecting them (including two paws). The goal is to apply a torque
on the joints to make the cheetah run forward (right) as fast as possible,
with a positive reward allocated based on the distance moved forward and a
negative reward allocated for moving backward. The torso and head of the
cheetah are fixed, and the torque can only be applied on the other 6 joints
over the front and back thighs (connecting to the torso), shins
(connecting to the thighs) and feet (connecting to the shins).</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">(6,),</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 back thigh rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>bthigh</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 back shin rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>bshin</p></td>
<td><p>hinge</p></td>
<td><p>torque (N m)</p></td>
</tr>
<trclass="row-even"><td><p>2</p></td>
<td><p>Torque applied on the back foot rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>bfoot</p></td>
<td><p>hinge</p></td>
<td><p>torque (N m)</p></td>
</tr>
<trclass="row-odd"><td><p>3</p></td>
<td><p>Torque applied on the front thigh rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>fthigh</p></td>
<td><p>hinge</p></td>
<td><p>torque (N m)</p></td>
</tr>
<trclass="row-even"><td><p>4</p></td>
<td><p>Torque applied on the front shin rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>fshin</p></td>
<td><p>hinge</p></td>
<td><p>torque (N m)</p></td>
</tr>
<trclass="row-odd"><td><p>5</p></td>
<td><p>Torque applied on the front foot rotor</p></td>
<td><p>-1</p></td>
<td><p>1</p></td>
<td><p>ffoot</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
cheetah, 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 cheetah’s center of mass. 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 18 dimensions where the first dimension
represents the x-coordinate of the cheetah’s center of mass.
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">(17,)</span></code> where the elements correspond to the following:</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>z-coordinate of the front tip</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 front tip</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 second rotor</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>bthigh</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 second rotor</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>bshin</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-even"><td><p>4</p></td>
<td><p>velocity of the tip along the x-axis</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>bfoot</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 tip along the y-axis</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>fthigh</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-even"><td><p>6</p></td>
<td><p>angular velocity of front tip</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>fshin</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-odd"><td><p>7</p></td>
<td><p>angular velocity of second rotor</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>ffoot</p></td>
<td><p>hinge</p></td>
<td><p>angle (rad)</p></td>
</tr>
<trclass="row-even"><td><p>8</p></td>
<td><p>x-coordinate of the front tip</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-odd"><td><p>9</p></td>
<td><p>y-coordinate of the front tip</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-even"><td><p>10</p></td>
<td><p>angle of the front tip</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-odd"><td><p>11</p></td>
<td><p>angle of the second rotor</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>bthigh</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-even"><td><p>12</p></td>
<td><p>angle of the second rotor</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>bshin</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-odd"><td><p>13</p></td>
<td><p>velocity of the tip along the x-axis</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>bfoot</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-even"><td><p>14</p></td>
<td><p>velocity of the tip along the y-axis</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>fthigh</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-odd"><td><p>15</p></td>
<td><p>angular velocity of front tip</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>fshin</p></td>
<td><p>hinge</p></td>
<td><p>angular velocity (rad/s)</p></td>
</tr>
<trclass="row-even"><td><p>16</p></td>
<td><p>angular velocity of second rotor</p></td>
<td><p>-Inf</p></td>
<td><p>Inf</p></td>
<td><p>ffoot</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 two parts:</p>
<ulclass="simple">
<li><p><em>forward_reward</em>: A reward of moving 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 5), where the frametime is 0.01 - making the
default <em>dt = 5 * 0.01 = 0.05</em>. This reward would be positive if the cheetah
runs forward (right).</p></li>
<li><p><em>ctrl_cost</em>: A cost for penalising the cheetah 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.1</p></li>
</ul>
<p>The total reward returned is <em><strong>reward</strong></em><em>=</em><em>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, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,) with a noise added to the
initial state for stochasticity. As seen before, the first 8 values in the
state are positional and the last 9 values are velocity. 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>] is added to the positional values while a standard
normal noise with a mean of 0 and standard deviation of <codeclass="docutils literal notranslate"><spanclass="pre">reset_noise_scale</span></code> is added to the
initial velocity values of all zeros.</p>
</section>
<sectionid="episode-end">
<h2>Episode End<aclass="headerlink"href="#episode-end"title="Permalink to this heading">#</a></h2>
<p>The episode truncates when the episode length is greater than 1000.</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>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>