code: def reward(self, action):
          
          reward = 0
  
          t, d, cos = self._compute_orientation()
  
          # Right location and angle
          if d < 0.06 and t >= -0.12 and t <= 0.14 and cos > 0.95:
              reward = 1
  
          # use a shaping reward
          if self.reward_shaping:
              # reaching reward
              hole_pos = self.sim.data.body_xpos[self.hole_body_id]
              gripper_site_pos = self.sim.data.body_xpos[self.cyl_body_id]
              dist = np.linalg.norm(gripper_site_pos - hole_pos)
              reaching_reward = 1 - np.tanh(1.0 * dist)
              reward += reaching_reward
  
              # Orientation reward
              reward += 1 - np.tanh(d)
              reward += 1 - np.tanh(np.abs(t))
              reward += cos
  
          return reward
docs: Reward function for the task.
  
          The sparse reward is 0 if the peg is outside the hole, and 1 if it's inside.
          We enforce that it's inside at an appropriate angle (cos(theta) > 0.95).
  
          The dense reward has four components.
  
              Reaching: in [0, 1], to encourage the arms to get together.
              Perpendicular and parallel distance: in [0,1], for the same purpose.
              Cosine of the angle: in [0, 1], to encourage having the right orientation.