Skip to content

Commit

Permalink
General MuJoCo Env Documention Cleanup (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kallinteris-Andreas authored May 9, 2023
1 parent 54a268f commit 4ceb968
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 128 deletions.
25 changes: 12 additions & 13 deletions gymnasium/envs/mujoco/ant_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class AntEnv(MujocoEnv, utils.EzPickle):
| 7 | Torque applied on the rotor between the back left two links | -1 | 1 | angle_3 (back_leg) | hinge | torque (N m) |
## Observation Space
Observations consist of positional values of different body parts of the ant,
followed by the velocities of those individual parts (their derivatives) with all
the positions ordered before all the velocities.
Expand All @@ -54,8 +53,6 @@ class AntEnv(MujocoEnv, utils.EzPickle):
| Num | Observation | Min | Max | Name (in corresponding XML file) | Joint | Unit |
|-----|--------------------------------------------------------------|--------|--------|----------------------------------------|-------|--------------------------|
| excluded | x-coordinate of the torso (centre) | -Inf | Inf | torso | free | position (m) |
| excluded | y-coordinate of the torso (centre) | -Inf | Inf | torso | free | position (m) |
| 0 | z-coordinate of the torso (centre) | -Inf | Inf | torso | free | position (m) |
| 1 | x-orientation of the torso (centre) | -Inf | Inf | torso | free | angle (rad) |
| 2 | y-orientation of the torso (centre) | -Inf | Inf | torso | free | angle (rad) |
Expand Down Expand Up @@ -83,6 +80,8 @@ class AntEnv(MujocoEnv, utils.EzPickle):
| 24 | angular velocity of the angle between back left links | -Inf | Inf | ankle_3 (back_leg) | hinge | angle (rad) |
| 25 | angular velocity of angle between torso and back right link | -Inf | Inf | hip_4 (right_back_leg) | hinge | angle (rad) |
| 26 | angular velocity of the angle between back right links | -Inf | Inf | ankle_4 (right_back_leg) | hinge | angle (rad) |
| excluded | x-coordinate of the torso (centre) | -Inf | Inf | torso | free | position (m) |
| excluded | y-coordinate of the torso (centre) | -Inf | Inf | torso | free | position (m) |
If version < `v4` or `use_contact_forces` is `True` then the observation space is extended by 14*6 = 84 elements, which are contact forces
Expand All @@ -91,16 +90,16 @@ class AntEnv(MujocoEnv, utils.EzPickle):
| id (for `v2`, `v3`, `v4)` | body parts |
| --- | ------------ |
| 0 | worldBody (note: forces are always full of zeros) |
| 1 | torso |
| 2 | front_left_leg |
| 3 | aux_1 (front left leg) |
| 4 | ankle_1 (front left leg) |
| 5 | front_right_leg |
| 6 | aux_2 (front right leg) |
| 7 | ankle_2 (front right leg) |
| 8 | back_leg (back left leg) |
| 9 | aux_3 (back left leg) |
| 0 | worldbody (note: forces are always full of zeros) |
| 1 | torso |
| 2 | front_left_leg |
| 3 | aux_1 (front left leg) |
| 4 | ankle_1 (front left leg) |
| 5 | front_right_leg |
| 6 | aux_2 (front right leg) |
| 7 | ankle_2 (front right leg) |
| 8 | back_leg (back left leg) |
| 9 | aux_3 (back left leg) |
| 10 | ankle_3 (back left leg) |
| 11 | right_back_leg |
| 12 | aux_4 (back right leg) |
Expand Down
17 changes: 8 additions & 9 deletions gymnasium/envs/mujoco/half_cheetah_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
This environment is based on the work by P. Wawrzyński in
["A Cat-Like Robot Real-Time Learning to Run"](http://staff.elka.pw.edu.pl/~pwawrzyn/pub-s/0812_LSCLRR.pdf).
The HalfCheetah is a 2-dimensional robot consisting of 9 links and 8
The HalfCheetah is a 2-dimensional robot consisting of 9 body parts 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
Expand All @@ -28,7 +28,7 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
(connecting to the thighs) and feet (connecting to the shins).
## Action Space
The action space is a `Box(-1, 1, (6,), float32)`. An action represents the torques applied between *links*.
The action space is a `Box(-1, 1, (6,), float32)`. An action represents the torques applied at the hinge joints.
| Num | Action | Control Min | Control Max | Name (in corresponding XML file) | Joint | Unit |
| --- | --------------------------------------- | ----------- | ----------- | -------------------------------- | ----- | ------------ |
Expand All @@ -41,19 +41,17 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
## Observation Space
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.
By default, observations do not include the x-coordinate of the cheetah's center of mass. It may
By default, observations do not include the cheetah's `rootx`. It may
be included by passing `exclude_current_positions_from_observation=False` 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 `exclude_current_positions_from_observation` was set to true or false, the x-coordinate
In that case, the observation space will be a `Box(-Inf, Inf, (18,), float64)` where the first element
represents the `rootx`.
Regardless of whether `exclude_current_positions_from_observation` was set to true or false, the
will be returned in `info` with key `"x_position"`.
However, by default, the observation is a `ndarray` with shape `(17,)` where the elements correspond to the following:
However, by default, the observation is a `Box(-Inf, Inf, (17,), float64)` where the elements correspond to the following:
| Num | Observation | Min | Max | Name (in corresponding XML file) | Joint | Unit |
| --- | ------------------------------------ | ---- | --- | -------------------------------- | ----- | ------------------------ |
Expand All @@ -74,6 +72,7 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
| 14 | velocity of the tip along the y-axis | -Inf | Inf | fthigh | hinge | angular velocity (rad/s) |
| 15 | angular velocity of front tip | -Inf | Inf | fshin | hinge | angular velocity (rad/s) |
| 16 | angular velocity of second rotor | -Inf | Inf | ffoot | hinge | angular velocity (rad/s) |
| excluded | x-coordinate of the front tip | -Inf | Inf | rootx | slide | position (m) |
## Rewards
The reward consists of two parts:
Expand Down
34 changes: 17 additions & 17 deletions gymnasium/envs/mujoco/hopper_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
connecting the four body parts.
## Action Space
The action space is a `Box(-1, 1, (3,), float32)`. An action represents the torques applied between *links*
The action space is a `Box(-1, 1, (3,), float32)`. An action represents the torques applied at the hinge joints.
| Num | Action | Control Min | Control Max | Name (in corresponding XML file) | Joint | Unit |
|-----|------------------------------------|-------------|-------------|----------------------------------|-------|--------------|
Expand All @@ -37,34 +37,34 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
| 2 | Torque applied on the foot rotor | -1 | 1 | foot_joint | hinge | torque (N m) |
## Observation Space
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.
By default, observations do not include the x-coordinate of the hopper. It may
be included by passing `exclude_current_positions_from_observation=False` during construction.
In that case, the observation space will have 12 dimensions where the first dimension
In that case, the observation space will be `Box(-Inf, Inf, (12,), float64)` where the first observation
represents the x-coordinate of the hopper.
Regardless of whether `exclude_current_positions_from_observation` was set to true or false, the x-coordinate
will be returned in `info` with key `"x_position"`.
However, by default, the observation is a `ndarray` with shape `(11,)` where the elements
However, by default, the observation is a `Box(-Inf, Inf, (11,), float64)` where the elements
correspond to the following:
| Num | Observation | Min | Max | Name (in corresponding XML file) | Joint | Unit |
| --- | ------------------------------------------------ | ---- | --- | -------------------------------- | ----- | ------------------------ |
| 0 | z-coordinate of the top (height of hopper) | -Inf | Inf | rootz | slide | position (m) |
| 1 | angle of the top | -Inf | Inf | rooty | hinge | angle (rad) |
| 2 | angle of the thigh joint | -Inf | Inf | thigh_joint | hinge | angle (rad) |
| 3 | angle of the leg joint | -Inf | Inf | leg_joint | hinge | angle (rad) |
| 4 | angle of the foot joint | -Inf | Inf | foot_joint | hinge | angle (rad) |
| 5 | velocity of the x-coordinate of the top | -Inf | Inf | rootx | slide | velocity (m/s) |
| 6 | velocity of the z-coordinate (height) of the top | -Inf | Inf | rootz | slide | velocity (m/s) |
| 7 | angular velocity of the angle of the top | -Inf | Inf | rooty | hinge | angular velocity (rad/s) |
| 8 | angular velocity of the thigh hinge | -Inf | Inf | thigh_joint | hinge | angular velocity (rad/s) |
| 9 | angular velocity of the leg hinge | -Inf | Inf | leg_joint | hinge | angular velocity (rad/s) |
| 10 | angular velocity of the foot hinge | -Inf | Inf | foot_joint | hinge | angular velocity (rad/s) |
| Num | Observation | Min | Max | Name (in corresponding XML file) | Joint | Unit |
| --- | -------------------------------------------------- | ---- | --- | -------------------------------- | ----- | ------------------------ |
| 0 | z-coordinate of the torso (height of hopper) | -Inf | Inf | rootz | slide | position (m) |
| 1 | angle of the torso | -Inf | Inf | rooty | hinge | angle (rad) |
| 2 | angle of the thigh joint | -Inf | Inf | thigh_joint | hinge | angle (rad) |
| 3 | angle of the leg joint | -Inf | Inf | leg_joint | hinge | angle (rad) |
| 4 | angle of the foot joint | -Inf | Inf | foot_joint | hinge | angle (rad) |
| 5 | velocity of the x-coordinate of the torso | -Inf | Inf | rootx | slide | velocity (m/s) |
| 6 | velocity of the z-coordinate (height) of the torso | -Inf | Inf | rootz | slide | velocity (m/s) |
| 7 | angular velocity of the angle of the torso | -Inf | Inf | rooty | hinge | angular velocity (rad/s) |
| 8 | angular velocity of the thigh hinge | -Inf | Inf | thigh_joint | hinge | angular velocity (rad/s) |
| 9 | angular velocity of the leg hinge | -Inf | Inf | leg_joint | hinge | angular velocity (rad/s) |
| 10 | angular velocity of the foot hinge | -Inf | Inf | foot_joint | hinge | angular velocity (rad/s) |
| excluded | x-coordinate of the torso | -Inf | Inf | rootx | slide | position (m) |
## Rewards
Expand Down
Loading

0 comments on commit 4ceb968

Please sign in to comment.