Skip to content

Reacher-misc

Reacher

Reacher(num_joints: int = 2)

Bases: Environment[EnvState, EnvParams]

Move the tip of a planar arm to a goal position by applying joint torques.

The arm consists of num_joints links of unit length. The action, scaled by params.torque_scale, sets the angular acceleration of every link, which is integrated with step size params.dt. The tip position is the sum of the link vectors (cos(angle), sin(angle)). At every reset the angles are sampled uniformly in [-pi, pi], the angular velocities in [-1, 1] and both goal coordinates in [-num_joints, num_joints]. The goal stays fixed for the whole episode. Supports differentiable transitions via with_transition_gradients().

  • Observation: Box of shape (3 * num_joints + 2,) with the cosines and sines of the angles, the angular velocities and the goal position.
  • Actions: Box of shape (num_joints,) with bounds [-1, 1]. The torque applied to each joint.
  • Reward: exp(-d**2), where d is the distance between the tip of the arm and the goal after the step.
  • Termination: never.
  • Truncation: after params.max_steps_in_episode steps (100 by default).

Parameters:

  • num_joints (int, default: 2 ) –

    Number of joints of the arm. Only the default of 2 is supported; other values fail when the observation is built.

References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the Reacher environment.

Attributes:

  • torque_scale (float) –

    Factor by which the action is scaled to obtain the angular accelerations.

  • dt (float) –

    Duration of one step, used for Euler integration.

  • max_steps_in_episode (int) –

    Number of steps after which the episode is truncated.

EnvState

Bases: EnvState

State of the Reacher environment.

Attributes:

  • angles (Array) –

    Array of shape (num_joints,) with the angle of each link, in radians.

  • angle_vels (Array) –

    Array of shape (num_joints,) with the angular velocity of each link.

  • goal_xy (Array) –

    Position of the goal as (x, y).

  • time (float) –

    Number of steps taken in the current episode.