Skip to content

Acrobot-v1

Acrobot

Acrobot()

Bases: Environment[EnvState, EnvParams]

Swing the free end of a two-link pendulum above a target height.

JAX port of the Gymnasium Acrobot-v1 environment, implementing only its default "book" dynamics. Both joint angles and both angular velocities start at uniformly random values in [-0.1, 0.1].

  • Observation: Box of shape (6,) with the cosine and sine of the first joint angle, the cosine and sine of the second joint angle and the two angular velocities.
  • Actions: Discrete(3). The action indexes params.available_torque: by default 0 applies a torque of -1, 1 no torque and 2 a torque of +1.
  • Reward: -1 for every step, 0 for the step that reaches the target height.
  • Termination: the free end is above the target height, i.e. -cos(joint_angle1) - cos(joint_angle1 + joint_angle2) > 1.
  • Truncation: after params.max_steps_in_episode steps (500 by default).
References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the Acrobot environment.

Gravity is fixed at 9.8 in the dynamics and is not a parameter.

Attributes:

  • available_torque (Array) –

    Torque applied at the joint between the two links for each of the three actions.

  • dt (float) –

    Duration of one step, covered by a single Runge-Kutta step.

  • link_length_1 (float) –

    Length of the first link.

  • link_length_2 (float) –

    Length of the second link. Not used by the dynamics.

  • link_mass_1 (float) –

    Mass of the first link.

  • link_mass_2 (float) –

    Mass of the second link.

  • link_com_pos_1 (float) –

    Position of the centre of mass of the first link.

  • link_com_pos_2 (float) –

    Position of the centre of mass of the second link.

  • link_moi (float) –

    Moment of inertia, shared by both links.

  • max_vel_1 (float) –

    Maximum absolute angular velocity of the first joint.

  • max_vel_2 (float) –

    Maximum absolute angular velocity of the second joint.

  • torque_noise_max (float) –

    Half-width of the uniform noise added to the torque in every step. 0 disables the noise.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the Acrobot environment.

Attributes:

  • joint_angle1 (Array) –

    Angle of the first link in radians, wrapped to [-pi, pi). 0 is the link hanging straight down.

  • joint_angle2 (Array) –

    Angle of the second link relative to the first in radians, wrapped to [-pi, pi).

  • velocity_1 (Array) –

    Angular velocity of joint_angle1, clipped to [-params.max_vel_1, params.max_vel_1].

  • velocity_2 (Array) –

    Angular velocity of joint_angle2, clipped to [-params.max_vel_2, params.max_vel_2].

  • time (int) –

    Number of steps taken in the current episode.