def init_task(self) -> None:
     self.lid = Shape('saucepan_lid_grasp_point')
     success_detector = ProximitySensor('success')
     self.register_graspable_objects([self.lid])
     cond_set = ConditionSet([
         GraspedCondition(self.robot.gripper, self.lid),
         DetectedCondition(self.lid, success_detector)
     ])
     self.register_success_conditions([cond_set])
 def init_task(self) -> None:
     knife = Shape('knife')
     success = ProximitySensor('success')
     self.knife_block = Shape('knife_block')
     self.chopping_board = Shape('chopping_board')
     self.register_graspable_objects([knife])
     cond_set = ConditionSet([DetectedCondition(knife, success),
                              NothingGrasped(self.robot.gripper)],
                             order_matters=True)
     self.register_success_conditions([cond_set])
     self.boundary = SpawnBoundary([Shape('boundary')])
Beispiel #3
0
 def init_task(self) -> None:
     self.square_ring = Shape('hannoi_square_ring')
     self.success_centre = Dummy('success_centre')
     success_detectors = [
         ProximitySensor('success_detector%d' % i) for i in range(4)
     ]
     self.register_graspable_objects([self.square_ring])
     success_condition = ConditionSet([
         DetectedCondition(self.square_ring, sd) for sd in success_detectors
     ])
     self.register_success_conditions([success_condition])
Beispiel #4
0
    def init_task(self) -> None:
        screw_driver = Shape('screw_driver')
        self.block = Shape('block')
        self.register_graspable_objects([screw_driver])
        screw_joint = Joint('screw_joint')

        cond_set = ConditionSet([
            GraspedCondition(self.robot.gripper, screw_driver),
            JointCondition(screw_joint, 1.4)],  # about 90 degrees
            order_matters=True)
        self.register_success_conditions([cond_set])
Beispiel #5
0
    def init_task(self) -> None:
        queue = Shape('queue')
        success_sensor = ProximitySensor('success')
        ball = Shape('ball')
        self.register_graspable_objects([queue])

        cond_set = ConditionSet([
            GraspedCondition(self.robot.gripper, queue),
            DetectedCondition(ball, success_sensor)
        ],
                                order_matters=True)
        self.register_success_conditions([cond_set])
    def init_task(self) -> None:
        self.block = Shape('pick_and_lift_target')
        self.register_graspable_objects([self.block])
        self.boundary = SpawnBoundary([Shape('pick_and_lift_boundary')])
        self.success_detector = ProximitySensor('pick_and_lift_success')

        cond_set = ConditionSet([
            GraspedCondition(self.robot.gripper, self.block),
            DetectedCondition(self.block, self.success_detector)
        ])
        self.register_success_conditions([cond_set])

        self.target = Shape('target')
Beispiel #7
0
    def init_episode(self, index: int) -> List[str]:
        self._variation_index = index
        self.bin_objects = sample_procedural_objects(self.get_base(), 3)
        self.bin_objects_not_done = list(self.bin_objects)
        self.register_graspable_objects(self.bin_objects)
        self.spawn_boundary.clear()
        for ob in self.bin_objects:
            ob.set_position([0.0, 0.0, 0.2],
                            relative_to=self.large_container,
                            reset_dynamics=False)
            self.spawn_boundary.sample(ob,
                                       ignore_collisions=True,
                                       min_distance=0.05)
        target_pos = [-5.9605e-8, -2.5005e-1, +1.7e-1]
        conditions = []
        target_color_name, target_color_rgb = colors[index]
        color_choice = np.random.choice(list(range(index)) +
                                        list(range(index + 1, len(colors))),
                                        size=1,
                                        replace=False)[0]
        _, distractor_color_rgb = colors[color_choice]
        if index % 2 == 0:
            self.target_container0.set_color(target_color_rgb)
            self.target_container1.set_color(distractor_color_rgb)
            for ob in self.bin_objects:
                conditions.append(DetectedCondition(ob,
                                                    self.success_detector0))
        else:
            self.target_container1.set_color(target_color_rgb)
            self.target_container0.set_color(distractor_color_rgb)
            for ob in self.bin_objects:
                conditions.append(DetectedCondition(ob,
                                                    self.success_detector1))
            target_pos[1] = -target_pos[1]
        self.target_waypoint.set_position(target_pos,
                                          relative_to=self.large_container,
                                          reset_dynamics=True)
        self.register_success_conditions(
            [ConditionSet(conditions, simultaneously_met=True)])

        return [
            'empty the container in the to %s container' % target_color_name,
            'clear all items from the large tray and put them in the %s '
            'tray' % target_color_name,
            'move all objects from the large container and drop them into '
            'the smaller %s one' % target_color_name,
            'remove whatever you find in the big box in the middle and '
            'leave them in the %s one' % target_color_name,
            'grasp and move all objects into the %s container' %
            target_color_name
        ]
Beispiel #8
0
 def init_episode(self, index: int) -> List[str]:
     self._variation_index = index
     self.target_topPlate.set_color([1.0, 0.0, 0.0])
     self.target_wrap.set_color([1.0, 0.0, 0.0])
     self.variation_index = index
     button_color_name, button_rgb = colors[index]
     self.target_button.set_color(button_rgb)
     self.register_success_conditions(
         [ConditionSet([self.goal_condition], True, False)])
     return [
         'push the %s button' % button_color_name,
         'push down the %s button' % button_color_name,
         'press the button with the %s base' % button_color_name,
         'press the %s button' % button_color_name
     ]
    def init_episode(self, index: int) -> List[str]:
        target_index = (index + 1) % self.variation_count()
        source_name, source_rgb = colors[index]
        target_name, target_rgb = colors[target_index]

        self.cup_source_visual.set_color(source_rgb)
        self.cup_target_visual.set_color(target_rgb)

        options = (list(range(index)) + list(range(index + 1, len(colors))))
        options.remove(target_index)

        color_choices = np.random.choice(options, size=3, replace=False)
        for obj, color_index in zip(self.distractors_vis, color_choices):
            _, rgb = colors[color_index]
            obj.set_color(rgb)

        b = SpawnBoundary([Shape('boundary')])
        b.sample(self.cup_source, min_distance=0.12)
        b.sample(self.cup_target, min_distance=0.12)
        [b.sample(d, min_distance=0.12) for d in self.distractors]

        # Make the waypoints always be the same orientation
        self.cup_target_base.set_orientation([0.] * 3)

        self.drops = []
        conditions = []
        for i in range(LIQUID_BALLS):
            drop = Shape.create(PrimitiveShape.SPHERE,
                                mass=0.0001,
                                size=[0.005, 0.005, 0.005])
            drop.set_parent(self.cup_source)
            drop.set_color([0.1, 0.1, 0.9])
            drop.set_position(list(np.random.normal(0, 0.0005, size=(3, ))),
                              relative_to=self.cup_source)
            self.drops.append(drop)
            conditions.append(DetectedCondition(drop, self.success_detector))
        self.register_success_conditions([ConditionSet(conditions)])

        return [
            'pour liquid from the %s cup to the %s cup' %
            (source_name, target_name),
            'pour liquid from the %s mug to the %s mug' %
            (source_name, target_name),
            'pour the contents of the %s mug into the %s one' %
            (source_name, target_name),
            'pick up the %s cup and pour the liquid into the %s one' %
            (source_name, target_name)
        ]
Beispiel #10
0
    def init_task(self) -> None:
        plate = Shape('plate')
        self.dish_rack = Shape('dish_rack')
        self.plate_stand = Shape('plate_stand')
        self.success_sensor = ProximitySensor('success')
        self.success_poses = [Dummy('success_pos%d' % i) for i in range(3)]
        self.pillars = [Shape('dish_rack_pillar%d' % i) for i in range(6)]

        self.boundary = SpawnBoundary([Shape('boundary')])
        self.register_graspable_objects([plate])
        cond_set = ConditionSet([
            DetectedCondition(plate, self.success_sensor),
            NothingGrasped(self.robot.gripper)
        ],
                                order_matters=True)
        self.register_success_conditions([cond_set])
    def init_task(self) -> None:
        self.target_block = Shape('pick_and_lift_target')
        self.target = Shape("success_visual")
        self.target.set_renderable(False)
        self.register_graspable_objects([self.target_block])
        self.boundary = SpawnBoundary([Shape('pick_and_lift_boundary')])
        self.success_detector = ProximitySensor('pick_and_lift_success')
        self.front_camera_exists = Object.exists('cam_front')
        if self.front_camera_exists:
            self.front_camera = VisionSensor('cam_front')
            self.init_front_camera_position = self.front_camera.get_position()
            self.init_front_camera_orientation = self.front_camera.get_orientation(
            )
            self.panda_base = Shape("Panda_link0_visual")

        cond_set = ConditionSet([
            GraspedCondition(self.robot.gripper, self.target_block),
            DetectedCondition(self.target_block, self.success_detector)
        ])
        self.register_success_conditions([cond_set])
Beispiel #12
0
    def init_task(self) -> None:
        self.blocks = [Shape('block_pyramid_block%d' % i) for i in range(6)]
        self.distractors = [
            Shape('block_pyramid_distractor_block%d' % i) for i in range(6)
        ]
        success_detectors = [
            ProximitySensor('block_pyramid_success_block%d' % i)
            for i in range(3)
        ]

        cond_set = ConditionSet([
            DetectedSeveralCondition(self.blocks, success_detectors[0], 3),
            DetectedSeveralCondition(self.blocks, success_detectors[1], 2),
            DetectedSeveralCondition(self.blocks, success_detectors[2], 1),
            NothingGrasped(self.robot.gripper)
        ])
        self.register_success_conditions([cond_set])
        self.register_graspable_objects(self.blocks + self.distractors)
        self.spawn_boundary = SpawnBoundary(
            [Shape('block_pyramid_boundary%d' % i) for i in range(4)])
Beispiel #13
0
    def init_episode(self, index: int) -> List[str]:
        for tp in self.target_topPlates:
            tp.set_color([1.0, 0.0, 0.0])
        for w in self.target_wraps:
            w.set_color([1.0, 0.0, 0.0])
        # For each color permutation, we want to have 1, 2 or 3 buttons pushed
        color_index = int(index / MAX_TARGET_BUTTONS)
        self.buttons_to_push = 1 + index % MAX_TARGET_BUTTONS
        button_colors = color_permutations[color_index]

        self.color_names = []
        self.color_rgbs = []
        self.chosen_colors = []
        i = 0
        for b in self.target_buttons:
            color_name, color_rgb = button_colors[i]
            self.color_names.append(color_name)
            self.color_rgbs.append(color_rgb)
            self.chosen_colors.append((color_name, color_rgb))
            b.set_color(color_rgb)
            i += 1

        # for task success, all button to push must have green color RGB
        self.success_conditions = []
        for i in range(self.buttons_to_push):
            self.success_conditions.append(self.goal_conditions[i])

        self.register_success_conditions(
            [ConditionSet(self.success_conditions, True, False)])

        rtn0 = 'push the %s button' % self.color_names[0]
        rtn1 = 'press the %s button' % self.color_names[0]
        rtn2 = 'push down the button with the %s base' % self.color_names[0]
        for i in range(self.buttons_to_push):
            if i == 0:
                continue
            else:
                rtn0 += ', then push the %s button' % self.color_names[i]
                rtn1 += ', then press the %s button' % self.color_names[i]
                rtn2 += ', then the %s one' % self.color_names[i]

        b = SpawnBoundary([self.boundaries])
        for button in self.target_buttons:
            b.sample(button, min_distance=0.1)

        num_non_targets = 3 - self.buttons_to_push
        spare_colors = list(
            set(colors) -
            set([self.chosen_colors[i] for i in range(self.buttons_to_push)]))

        spare_color_rgbs = []
        for i in range(len(spare_colors)):
            _, rgb = spare_colors[i]
            spare_color_rgbs.append(rgb)

        color_choice_indexes = np.random.choice(range(len(spare_colors)),
                                                size=num_non_targets,
                                                replace=False)
        non_target_index = 0
        for i, button in enumerate(self.target_buttons):
            if i in range(self.buttons_to_push):
                pass
            else:
                _, rgb = spare_colors[color_choice_indexes[non_target_index]]
                button.set_color(rgb)
                non_target_index += 1

        return [rtn0, rtn1, rtn2]