Пример #1
0
    def __init__(self,
                 table_full_size=(0.8, 0.8, 0.8),
                 table_friction=(1, 0.005, 0.0001),
                 num_squares=(10, 10)):
        """
        Args:
            table_full_size: full dimensions of the table
            friction: friction parameters of the table
            num_squares: number of squares in each dimension of the table top
        """
        super().__init__(xml_path_completion("arenas/tactile_table_arena.xml"))

        self.table_full_size = np.array(table_full_size)
        self.table_half_size = self.table_full_size / 2
        self.table_friction = table_friction

        self.num_squares = np.array(num_squares)

        self.floor = self.worldbody.find("./geom[@name='floor']")
        self.table_body = self.worldbody.find("./body[@name='table']")
        self.table_collision = self.table_body.find(
            "./geom[@name='table_collision']")
        self.table_visual = self.table_body.find(
            "./geom[@name='table_visual']")
        self.table_top = self.table_body.find("./site[@name='table_top']")

        self.configure_location()
Пример #2
0
    def __init__(self,
                 table_height_full_size=(0.8, 0.8, 0.8, 0.8),
                 table_friction=(1, 0.005, 0.0001)):
        """
        Args:
            table_full_size: full dimensions of the table height: x, y, height scale over the surface, box depth from the min
            friction: friction parameters of the table
        """
        super().__init__(xml_path_completion("arenas/height_table_arena.xml"))

        self.table_height_full_size = np.array(table_height_full_size)
        self.table_half_size = np.array([
            self.table_height_full_size[0], self.table_height_full_size[1],
            self.table_height_full_size[3]
        ]) / 2

        self.table_friction = table_friction

        self.floor = self.worldbody.find("./geom[@name='floor']")
        self.table_body = self.worldbody.find("./geom[@name='table_hf_geom']")
        self.table_top_abs = self.worldbody.find(
            "./geom[@name='table_hf_geom']")
        self.table_asset = self.asset.find("./hfield[@name='table_hf']")

        self.sensor_sites = {}

        self.configure_location()
Пример #3
0
    def __init__(self, xml_path="robots/panda/robot.xml"):
        super().__init__(xml_path_completion(xml_path))

        self.bottom_offset = np.array([0, 0, -0.913])
        self.set_joint_damping()
        self._model_name = "panda"
        # Careful of init_qpos -- certain init poses cause ik controller to go unstable (e.g: pi/4 instead of -pi/4
        # for the final joint angle)
        self._init_qpos = np.array([
            0, np.pi / 16.0, 0.00, -np.pi / 2.0 - np.pi / 3.0, 0.00,
            np.pi - 0.2, -np.pi / 4
        ])
    def __init__(self,
                 table_full_size=(0.8, 0.8, 0.8),
                 table_friction=(0.01, 0.005, 0.0001),
                 num_squares=(10, 10),
                 prob_sensor=1.0,
                 rotation_x=0,
                 rotation_y=0,
                 draw_line=True,
                 num_sensors=10,
                 table_friction_std=0,
                 line_width=0.02,
                 two_clusters=False):
        """
        Args:
            table_full_size: full dimensions of the table
            friction: friction parameters of the table
            num_squares: number of squares in each dimension of the table top
        """
        super().__init__(
            xml_path_completion("arenas/wipe_force_table_arena.xml"))

        self.table_full_size = np.array(table_full_size)
        self.table_half_size = self.table_full_size / 2
        self.table_friction = table_friction
        self.table_friction_std = table_friction_std
        self.line_width = line_width

        self.num_squares = np.array(num_squares)

        self.sensor_names = []
        self.sensor_site_names = {}

        self.floor = self.worldbody.find("./geom[@name='floor']")
        self.table_body = self.worldbody.find("./body[@name='table']")
        self.table_collision = self.table_body.find(
            "./geom[@name='table_collision']")
        self.table_visual = self.table_body.find(
            "./geom[@name='table_visual']")
        self.table_top = self.table_body.find("./site[@name='table_top']")

        self.coverage_factor = 1.0  #How much of the table surface we cover

        self.prob_sensor = prob_sensor

        self.rotation_x = rotation_x
        self.rotation_y = rotation_y

        self.draw_line = draw_line
        self.num_sensors = num_sensors
        self.two_clusters = two_clusters

        self.configure_location()
Пример #5
0
    def __init__(self,
                 table_full_size=(0.39, 0.49, 0.82),
                 table_friction=(1, 0.005, 0.0001)):
        """
        Args:
            table_full_size: full dimensions of the table
            friction: friction parameters of the table
        """
        super().__init__(xml_path_completion("arenas/bins_arena.xml"))

        self.table_full_size = np.array(table_full_size)
        self.table_half_size = self.table_full_size / 2
        self.table_friction = table_friction

        self.floor = self.worldbody.find("./geom[@name='floor']")
        self.bin1_body = self.worldbody.find("./body[@name='bin1']")
        self.bin2_body = self.worldbody.find("./body[@name='bin2']")

        self.configure_location()
Пример #6
0
 def __init__(self):
     super().__init__(xml_path_completion("objects/door_small.xml"))
Пример #7
0
 def __init__(self):
     super().__init__(xml_path_completion("objects/round-nut.xml"))
Пример #8
0
 def __init__(self):
     super().__init__(xml_path_completion("objects/bread.xml"))
Пример #9
0
 def __init__(self):
     super().__init__(
         xml_path_completion("objects/plate-with-round-hole.xml"))
Пример #10
0
 def __init__(self):
     super().__init__(xml_path_completion("grippers/panda_vices_gripper.xml"))
Пример #11
0
    def configure_location(self):
        self.bottom_pos = np.array([0, 0, 0])
        self.floor.set("pos", array_to_string(self.bottom_pos))

        self.center_pos = self.bottom_pos + np.array(
            [0, 0, 2 * self.table_half_size[2]])
        self.table_body.set("pos", array_to_string(self.center_pos))
        self.table_asset.set("size",
                             array_to_string(self.table_height_full_size))
        self.table_body.set("friction", array_to_string(self.table_friction))

        height_img = imageio.imread(xml_path_completion(
            self.table_asset.get("file")),
                                    as_gray=True)

        total_pixels = height_img.shape[0] * height_img.shape[1]

        #TODO: the number of sensors affects the performance. Do not increse over 500
        #800 sensors -> mujoco steps up to 0.25sec per policy step!
        num_sensors = min(500, total_pixels)

        sample_rate = np.floor(total_pixels / num_sensors)

        #Random Sampling:
        used_pairs = []
        sensor_counter = 0
        while sensor_counter < num_sensors:
            i = np.random.randint(0, high=height_img.shape[0])
            j = np.random.randint(0, high=height_img.shape[1])

            if (
                    i, j
            ) not in used_pairs:  # We could add additional constraints like that sensors should be appart from each other

                self.mujoco_objects = OrderedDict()
                square = BallObject(size=[0.01],
                                    rgba=[0, 0, 1, 1],
                                    density=500,
                                    friction=0.05)
                square_name = 'contact_' + str(i) + "_" + str(j)
                collision_b = square.get_collision(name=square_name, site=True)

                x_pos = 0
                if height_img.shape[0] % 2 == 0:
                    x_pos = -(np.floor(height_img.shape[0] / 2) - 0.5 -
                              i) * 2 * self.table_height_full_size[
                                  0] / height_img.shape[0]
                else:
                    x_pos = (i - np.floor(height_img.shape[0] / 2)
                             ) * 2 * self.table_height_full_size[
                                 0] / height_img.shape[0]

                y_pos = 0
                if height_img.shape[1] % 2 == 0:
                    y_pos = -(np.floor(height_img.shape[1] / 2) - 0.5 -
                              j) * 2 * self.table_height_full_size[
                                  1] / height_img.shape[1]
                else:
                    y_pos = (j - np.floor(height_img.shape[1] / 2)
                             ) * 2 * self.table_height_full_size[
                                 1] / height_img.shape[1]

                #Compute mean of pixel value and neighbors -> better for low dim images
                acc = 0
                mean_ctr = 1
                pixel_value = height_img[i, j]

                # DO NOT DELETE! The following code helps for low dimensional pictures because the interpolation "buries" some sensors
                # if i+1< height_img.shape[0]:
                #     if height_img[i+1,j] > pixel_value:
                #         acc += height_img[i+1,j]
                #         mean_ctr += 1
                # if i-1<=0:
                #     if height_img[i-1,j] > pixel_value:
                #         acc += height_img[i-1,j]
                #         mean_ctr += 1
                # if j+1< height_img.shape[0]:
                #     if height_img[i,j+1] > pixel_value:
                #         acc += height_img[i,j+1]
                #         mean_ctr += 1
                # if j-1<=0:
                #     if height_img[i,j-1] > pixel_value:
                #         acc += height_img[i,j-1]
                #         mean_ctr += 1

                acc += height_img[i, j]
                z_pos = self.table_height_full_size[
                    3] + self.table_height_full_size[2] * (
                        acc / float(mean_ctr)) / np.max(height_img) + 0.005

                position_sensor = [y_pos, x_pos, z_pos]
                position_sensor[1] = -position_sensor[1]

                collision_b.find("site").set("pos",
                                             array_to_string(position_sensor))
                self.worldbody.append(collision_b.find("site"))
                self.sensor_sites[sensor_counter] = position_sensor

                # Add this pixel to the list of used pixels
                used_pairs += [(i, j)]

                # Add sensor linked to the sensor site
                ET.SubElement(self.sensor,
                              "touch",
                              attrib={
                                  "name": square_name + "_sensor",
                                  "site": square_name
                              })  # + "_site"})
                sensor_counter += 1
Пример #12
0
 def __init__(self):
     super().__init__(
         xml_path_completion("grippers/left_two_finger_gripper.xml"))
Пример #13
0
 def __init__(self):
     super().__init__(xml_path_completion("arenas/empty_arena.xml"))
     self.floor = self.worldbody.find("./geom[@name='floor']")
Пример #14
0
 def __init__(self):
     super().__init__(xml_path_completion("base.xml"))
Пример #15
0
 def __init__(self):
     super().__init__(xml_path_completion("objects/cereal-visual.xml"))
Пример #16
0
 def __init__(self):
     super().__init__(xml_path_completion("grippers/robotiq_gripper.xml"))
Пример #17
0
 def __init__(self):
     super().__init__(xml_path_completion('grippers/wiping_gripper.xml'))