Skip to content

Hopper

Hopper

Bases: EnvType

This class represents the Hopper environment.

__init__(algo=Algo.PPO, algo_param={'policy': 'MlpPolicy', 'verbose': 0, 'device': 'cpu'}, prompt={'Goal': "Control the Hopper to move in the forward direction, take care to don't fall, make the highest jump", 'Observation Space': 'Box(-inf, inf, (11,), float64)\n\nThe observation space consists of the following parts (in order):\nqpos (5 elements by default): Position values of the robot’s body parts.\nqvel (6 elements): The velocities of these individual body parts (their derivatives).\nthe x- and y-coordinates are returned in info with the keys "x_position" and "y_position", respectively.\n\n| Num | Observation | Min | Max | Type |\n|----------|--------------------------------------------------|-------|------|---------------------|\n| 0 | z-coordinate of the torso (height of hopper) | -Inf | Inf | position (m) |\n| 1 | angle of the torso | -Inf | Inf | angle (rad) |\n| 2 | angle of the thigh joint | -Inf | Inf | angle (rad) |\n| 3 | angle of the leg joint | -Inf | Inf | angle (rad) |\n| 4 | angle of the foot joint | -Inf | Inf | angle (rad) |\n| 5 | velocity of the x-coordinate of the torso | -Inf | Inf | velocity (m/s) |\n| 6 | velocity of the z-coordinate (height) of torso | -Inf | Inf | velocity (m/s) |\n| 7 | angular velocity of the angle of the torso | -Inf | Inf | angular velocity (rad/s) |\n| 8 | angular velocity of the thigh hinge | -Inf | Inf | angular velocity (rad/s) |\n| 9 | angular velocity of the leg hinge | -Inf | Inf | angular velocity (rad/s) |\n| 10 | angular velocity of the foot hinge | -Inf | Inf | angular velocity (rad/s) |\n| excluded | x-coordinate of the torso | -Inf | Inf | position (m) |\n\t\t"Action Space": The action space is a Box(-1, 1, (3,), float32). An action represents the torques applied at the hinge joints.\n| Num | Action | Control Min | Control Max | Name (in corresponding XML file) | Joint | Type |\n|-----|---------------------------------|-------------|-------------|-----------------------------------|--------|--------------|\n| 0 | Torque applied on the thigh rotor | -1 | 1 | thigh_joint | hinge | torque (N m) |\n| 1 | Torque applied on the leg rotor | -1 | 1 | leg_joint | hinge | torque (N m) |\n| 2 | Torque applied on the foot rotor | -1 | 1 | foot_joint | hinge | torque (N m) |\n\n'})

Constructor for the Hopper environment.

Parameters:

Name Type Description Default
algo Algo

The algorithm to be used for training. Defaults to Algo.PPO.

PPO
algo_param dict

The parameters for the algorithm. Defaults to {"policy": "MlpPolicy", "verbose": 0, "device": "cpu"}.

{'policy': 'MlpPolicy', 'verbose': 0, 'device': 'cpu'}
prompt dict

The prompt for the environment. Defaults to {"Goal": "Control the Hopper to move in the forward direction, take care to don't fall, make the highest jump", "Observation Space": [...]

{'Goal': "Control the Hopper to move in the forward direction, take care to don't fall, make the highest jump", 'Observation Space': 'Box(-inf, inf, (11,), float64)\n\nThe observation space consists of the following parts (in order):\nqpos (5 elements by default): Position values of the robot’s body parts.\nqvel (6 elements): The velocities of these individual body parts (their derivatives).\nthe x- and y-coordinates are returned in info with the keys "x_position" and "y_position", respectively.\n\n| Num | Observation | Min | Max | Type |\n|----------|--------------------------------------------------|-------|------|---------------------|\n| 0 | z-coordinate of the torso (height of hopper) | -Inf | Inf | position (m) |\n| 1 | angle of the torso | -Inf | Inf | angle (rad) |\n| 2 | angle of the thigh joint | -Inf | Inf | angle (rad) |\n| 3 | angle of the leg joint | -Inf | Inf | angle (rad) |\n| 4 | angle of the foot joint | -Inf | Inf | angle (rad) |\n| 5 | velocity of the x-coordinate of the torso | -Inf | Inf | velocity (m/s) |\n| 6 | velocity of the z-coordinate (height) of torso | -Inf | Inf | velocity (m/s) |\n| 7 | angular velocity of the angle of the torso | -Inf | Inf | angular velocity (rad/s) |\n| 8 | angular velocity of the thigh hinge | -Inf | Inf | angular velocity (rad/s) |\n| 9 | angular velocity of the leg hinge | -Inf | Inf | angular velocity (rad/s) |\n| 10 | angular velocity of the foot hinge | -Inf | Inf | angular velocity (rad/s) |\n| excluded | x-coordinate of the torso | -Inf | Inf | position (m) |\n\t\t"Action Space": The action space is a Box(-1, 1, (3,), float32). An action represents the torques applied at the hinge joints.\n| Num | Action | Control Min | Control Max | Name (in corresponding XML file) | Joint | Type |\n|-----|---------------------------------|-------------|-------------|-----------------------------------|--------|--------------|\n| 0 | Torque applied on the thigh rotor | -1 | 1 | thigh_joint | hinge | torque (N m) |\n| 1 | Torque applied on the leg rotor | -1 | 1 | leg_joint | hinge | torque (N m) |\n| 2 | Torque applied on the foot rotor | -1 | 1 | foot_joint | hinge | torque (N m) |\n\n'}

__repr__()

Returns the string representation of the Hopper environment.

Returns:

Name Type Description
str

The string representation of the Hopper environment.

objective_metric(states)

Objective metric for the CartPole environment. Calculates a score for the given state on a particular observation of the CartPole environment.

:param state: The state of the CartPole environment. :return: a table of tuples containing the string name of the metric and the value of the metric.

success_func(env, info)

Hopper success_fun

Parameters:

Name Type Description Default
env Env
required
info dict
required

Returns:

Type Description
tuple[bool | bool]

tuple[bool|bool]: is_success, is_failure tuple