def __init__(self, seed=None):
    self.screen = None
    self.params = parameters.Params()
    self.physics_eng = physics.PhysicsSim()

    # Ball XY positions can be between -1.5 and 1.5
    ball0_os = spaces.Box(low=np.array([-self.params.TABLE_SIZE[0]/2., -self.params.TABLE_SIZE[1]/2.]),
                          high=np.array([self.params.TABLE_SIZE[0] / 2., self.params.TABLE_SIZE[1] / 2.]))

    ball1_os = spaces.Box(low=np.array([-self.params.TABLE_SIZE[0]/2., -self.params.TABLE_SIZE[1]/2.]),
                          high=np.array([self.params.TABLE_SIZE[0]/2., self.params.TABLE_SIZE[1]/2.]))

    # Arm joint can have positons:
    # Joint 0: [-Pi/2, Pi/2]
    # Joint 1: [-Pi, Pi]
    joints_angle = spaces.Box(low=np.array([-np.pi / 2, -np.pi]), high=np.array([np.pi / 2, np.pi]))
    joints_vel = spaces.Box(low=np.array([-50, -50]), high=np.array([50, 50]))

    self.observation_space = spaces.Tuple([ball0_os, ball1_os, joints_angle, joints_vel])

    # Actions are torques on joints and open/close of arm grip.
    # Joint torques can be between [-1, 1]
    self.action_space = spaces.Box(low=np.array([-1., -1.]), high=np.array([1., 1.]))

    self.seed(seed)
Exemplo n.º 2
0
    def __init__(self, balls_pose=[[0, 0]], arm_position=None, params=None):
        if params is None:
            self.params = parameters.Params()
        else:
            self.params = params

        # pprint('Parameters: {}'.format(vars(self.params)))

        # Create physic simulator
        self.world = b2.b2World(gravity=(0, 0), doSleep=True)
        self.dt = self.params.TIME_STEP
        self.vel_iter = self.params.VEL_ITER
        self.pos_iter = self.params.POS_ITER
        self._create_table()
        self._create_balls(balls_pose)
        self._create_robotarm(arm_position)
        self._create_holes()
Exemplo n.º 3
0
    def __init__(self, seed=None, max_steps=500):
        """ Constructor
    :param seed: the random seed for the environment
    :param max_steps: the maximum number of steps the episode lasts
    :return:
    """
        self.screen = None
        self.params = parameters.Params()
        self.params.MAX_ENV_STEPS = max_steps
        self.physics_eng = physics.PhysicsSim()

        ## Ball XY positions can be between -1.5 and 1.5
        ## Arm joint can have positons:
        # Joint 0: [-Pi/2, Pi/2]
        # Joint 1: [-Pi, Pi]
        self.observation_space = spaces.Box(
            low=np.array([
                -self.params.TABLE_SIZE[0] / 2.,
                -self.params.TABLE_SIZE[1] / 2.,  # ball pose
                -np.pi / 2,
                -np.pi,  # joint angles
                -50,
                -50
            ]),  # joint vels
            high=np.array([
                self.params.TABLE_SIZE[0] / 2.,
                self.params.TABLE_SIZE[1] / 2.,  # ball pose
                np.pi / 2,
                np.pi,  # joint angles
                50,
                50
            ]),
            dtype=np.float32)  # joint vels

        ## Joint commands can be between [-1, 1]
        self.action_space = spaces.Box(low=np.array([-1., -1.]),
                                       high=np.array([1., 1.]),
                                       dtype=np.float32)

        self.goals = np.array(
            [hole['pose'] for hole in self.physics_eng.holes])
        self.goalRadius = [hole['radius'] for hole in self.physics_eng.holes]
        self.rew_area = None

        self.seed(seed)
Exemplo n.º 4
0
    def __init__(self, seed=None, max_steps=500):
        """ Constructor
    :param seed: the random seed for the environment
    :param max_steps: the maximum number of steps the episode lasts
    :return:
    """
        self.screen = None
        self.params = parameters.Params()
        self.physics_eng = physics.PhysicsSim()
        self.params.MAX_ENV_STEPS = max_steps

        ## Ball XY positions can be between -1.5 and 1.5
        ball0_os = spaces.Box(low=np.array(
            [-self.params.TABLE_SIZE[0] / 2.,
             -self.params.TABLE_SIZE[1] / 2.]),
                              high=np.array([
                                  self.params.TABLE_SIZE[0] / 2.,
                                  self.params.TABLE_SIZE[1] / 2.
                              ]))

        ball1_os = spaces.Box(low=np.array(
            [-self.params.TABLE_SIZE[0] / 2.,
             -self.params.TABLE_SIZE[1] / 2.]),
                              high=np.array([
                                  self.params.TABLE_SIZE[0] / 2.,
                                  self.params.TABLE_SIZE[1] / 2.
                              ]))

        ## Arm joint can have positons:
        # Joint 0: [-Pi/2, Pi/2]
        # Joint 1: [-Pi, Pi]
        joints_angle = spaces.Box(low=np.array([-np.pi / 2, -np.pi]),
                                  high=np.array([np.pi / 2, np.pi]))
        joints_vel = spaces.Box(low=np.array([-50, -50]),
                                high=np.array([50, 50]))

        self.observation_space = spaces.Tuple(
            [ball0_os, ball1_os, joints_angle, joints_vel])

        ## Joint commands can be between [-1, 1]
        self.action_space = spaces.Box(low=np.array([-1., -1.]),
                                       high=np.array([1., 1.]))

        self.seed(seed)
Exemplo n.º 5
0
    def __init__(self, balls_pose=[[0, 0]], arm_position=None, params=None):
        """
    Constructor
    :param balls_pose: Initial ball poses. Is a list of the ball poses [ball0, ball1, ...]
    :param arm_position: Initial arm position
    :param params: Parameters
    """
        if params is None:
            self.params = parameters.Params()
        else:
            self.params = params

        ## Physic simulator
        self.world = b2.b2World(gravity=(0, 0), doSleep=True)
        self.dt = self.params.TIME_STEP
        self.vel_iter = self.params.VEL_ITER
        self.pos_iter = self.params.POS_ITER
        self._create_table()
        self._create_balls(balls_pose)
        self._create_robotarm(arm_position)
        self._create_holes()