Esempio n. 1
0
    def init_episode(self, index: int) -> List[str]:

        option = OPTIONS[index]

        conditions = [
            DetectedCondition(self.cup, self.success_sensor),
            NothingGrasped(self.robot.gripper)
        ]

        if option == 'left':
            self.waypoint0.set_position(
                self.left_initial_waypoint.get_position())
            self.waypoint1.set_position(
                self.left_close_waypoint.get_position())
            self.waypoint2.set_position(self.left_far_waypoint.get_position())
            self.waypoint6.set_position(
                self.place_cup_left_waypoint.get_position())
            conditions.append(JointCondition(self.left_joint, 0.06))
        else:
            conditions.append(JointCondition(self.right_joint, 0.06))
        self.register_success_conditions(conditions)

        return [
            'put cup in %s cabinet' % option,
            'put the mug away in the %s half of the cabinet' % option,
            'open the %s side of the cabinet and put the cup away in it' %
            option,
            'grasping the %s handle, open the cabinet, then pick up the cup'
            ' and set it down inside the cabinet' % option,
            'slide open the %s door on the cabinet and put away the mug' %
            option
        ]
Esempio n. 2
0
    def init_episode(self, index: int) -> List[str]:
        self.right_frame.set_dynamic(False)
        self.left_frame.set_dynamic(False)
        self.left_unlocked = False
        self.right_unlocked = False

        option = OPTIONS[index]

        if option == 'right':
            self.waypoint0.set_position(self.waypoint0_.get_position())
            self.waypoint1.set_position(self.waypoint1_.get_position())
            self.waypoint2.set_position(self.waypoint2_.get_position())
            self.waypoint2.set_orientation(self.waypoint2_.get_orientation())
            self.waypoint3.set_position(self.waypoint3_.get_position())
            self.waypoint3.set_orientation(self.waypoint3_.get_orientation())
            self.register_success_conditions(
                [JointCondition(Joint('right_window_joint'), np.deg2rad(50))])
        else:
            self.register_success_conditions(
                [JointCondition(Joint('left_window_joint'), np.deg2rad(50))])
        return [
            'open %s window' % option,
            'rotate the handle to unlock the %s window, then open it' % option,
            'push the %s window open' % option,
            'use the handle to open the %s window' % option
        ]
Esempio n. 3
0
 def init_task(self) -> None:
     self.door_main = Shape('door_main')
     self.door_main.set_dynamic(False)
     door_joint = Joint('door_frame_joint')
     handle_joint = Joint('door_handle_joint')
     self.register_success_conditions(
         [JointCondition(door_joint, np.deg2rad(25))])
     self.door_unlock_cond = JointCondition(handle_joint, np.deg2rad(25))
Esempio n. 4
0
 def init_task(self) -> None:
     cap_detector = ProximitySensor("cap_detector")
     self.joint = Joint('joint')
     self.force_sensor = ForceSensor('Force_sensor')
     self.cap = Shape('cap')
     self.register_success_conditions(
         [DetectedCondition(self.cap, cap_detector, negated=True)])
     self.cap_turned_condition = JointCondition(
         self.joint, np.deg2rad(150))
Esempio n. 5
0
 def init_task(self) -> None:
     self.tv = Shape('tv_frame')
     self.screen_on = Shape('tv_screen_on')
     self.screen_up = Shape('tv_screen_up')
     self.screen_down = Shape('tv_screen_down')
     self.remote = Shape('tv_remote')
     self.boundary = Shape('spawn_boundary')
     self.joint_conditions = [
         JointCondition(Joint('target_button_joint1'), 0.005),
         JointCondition(Joint('target_button_joint2'), 0.005)
     ]
Esempio n. 6
0
 def init_task(self) -> None:
     self._remote = Shape('tv_remote')
     self._joint_conditions = [
         JointCondition(Joint('target_button_joint1'), 0.003),
         JointCondition(Joint('target_button_joint2'), 0.003)
     ]
     self._w6 = Dummy('waypoint6')
     self._w6z = self._w6.get_position()[2]
     self.register_graspable_objects([self._remote])
     self._spawn_boundary = SpawnBoundary([Shape('spawn_boundary')])
     self._target_buttons = [
         Shape('target_button_wrap1'), Shape('target_button_wrap2')]
Esempio n. 7
0
 def init_task(self) -> None:
     bottle_detector = ProximitySensor("bottle_detector")
     cap_detector = ProximitySensor("cap_detector")
     bottle = Shape('bottle')
     self.joint = Joint('joint')
     self.cap = Shape('cap')
     self.register_success_conditions(
         [DetectedCondition(bottle, bottle_detector),
          DetectedCondition(self.cap, cap_detector, negated=True),
          NothingGrasped(self.robot.gripper)])
     self.cap_turned_condition = JointCondition(
         self.joint, np.deg2rad(150))
Esempio n. 8
0
class OpenWineBottle(Task):

    def init_task(self) -> None:
        bottle_detector = ProximitySensor("bottle_detector")
        cap_detector = ProximitySensor("cap_detector")
        bottle = Shape('bottle')
        self.joint = Joint('joint')
        self.force_sensor = ForceSensor('Force_sensor')
        self.cap = Shape('cap')
        self.register_success_conditions(
            [DetectedCondition(bottle, bottle_detector),
             DetectedCondition(self.cap, cap_detector, negated=True),
             NothingGrasped(self.robot.gripper)])
        self.cap_turned_condition = JointCondition(
            self.joint, np.deg2rad(150))

    def init_episode(self, index: int) -> List[str]:
        self.cap.set_parent(self.force_sensor)
        self.cap_turned = False
        return ['open wine bottle',
                'screw open the wine bottle',
                'unscrew the bottle cap then remove it from the wine bottle']

    def variation_count(self) -> int:
        return 1

    def step(self) -> None:
        if not self.cap_turned:
            self.cap_turned = self.cap_turned_condition.condition_met()[0]
            if self.cap_turned:
                self.cap.set_parent(self.joint)

    def cleanup(self):
        self.cap.set_parent(self.force_sensor)
Esempio n. 9
0
class PushButton(Task):
    def init_task(self):
        self.target_button = Shape('push_button_target')
        self.target_topPlate = Shape('target_button_topPlate')
        self.joint = Joint('target_button_joint')
        self.target_wrap = Shape('target_button_wrap')
        self.goal_condition = JointCondition(self.joint, 0.005)

    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 variation_count(self) -> int:
        return len(colors)

    def step(self) -> None:
        if self.goal_condition.condition_met() == (True, True):
            self.target_topPlate.set_color([0.0, 1.0, 0.0])
            self.target_wrap.set_color([0.0, 1.0, 0.0])
Esempio n. 10
0
 def init_task(self) -> None:
     cup = Shape('cup')
     self.register_graspable_objects([cup])
     self.register_success_conditions([
         JointCondition(Joint('joint'), np.deg2rad(1)),
         DetectedCondition(cup, ProximitySensor('success'))
     ])
Esempio n. 11
0
class OpenDoor(Task):
    def init_task(self) -> None:
        self._door_joint = Joint('door_frame_joint')
        self.register_success_conditions(
            [JointCondition(self._door_joint, np.deg2rad(25))])
        self.door_unlock_cond = JointCondition(Joint('door_handle_joint'),
                                               np.deg2rad(25))

    def init_episode(self, index: int) -> List[str]:
        self._door_unlocked = False
        self._door_joint.set_motor_locked_at_zero_velocity(True)
        return [
            'open the door', 'grip the handle and push the door open',
            'use the handle to open the door'
        ]

    def variation_count(self) -> int:
        return 1

    def step(self) -> None:
        if not self._door_unlocked:
            self._door_unlocked = self.door_unlock_cond.condition_met()[0]
            if self._door_unlocked:
                self._door_joint.set_motor_locked_at_zero_velocity(False)

    def base_rotation_bounds(self) -> Tuple[List[float], List[float]]:
        return [0, 0, -3.14 / 4.], [0, 0, 3.14 / 4.]

    def boundary_root(self) -> Object:
        return Shape('boundary_root')
Esempio n. 12
0
    def init_task(self):
        self.waypoint0 = Dummy('waypoint0')
        self.waypoint1 = Dummy('waypoint1')
        self.waypoint2 = Dummy('waypoint2')
        self.waypoint3 = Dummy('waypoint3')

        self.waypoint0_ = Dummy('waypoint0_')
        self.waypoint1_ = Dummy('waypoint1_')
        self.waypoint2_ = Dummy('waypoint2_')
        self.waypoint3_ = Dummy('waypoint3_')

        self.right_unlocked_cond = JointCondition(Joint('right_handle_joint'),
                                                  np.deg2rad(60))
        self.left_unlocked_cond = JointCondition(Joint('left_handle_joint'),
                                                 np.deg2rad(60))
        self.right_frame = Shape('right_frame')
        self.left_frame = Shape('left_frame')
Esempio n. 13
0
    def init_episode(self, index: int) -> List[str]:
        option = OPTIONS[index]
        if option == 'right':
            self.left_start.set_position(self.right_start.get_position())
            self.left_start.set_orientation(self.right_start.get_orientation())
            self.left_end.set_position(self.right_end.get_position())
            self.left_end.set_orientation(self.right_end.get_orientation())
            self.register_success_conditions(
                [JointCondition(self.right_joint, 1.57)])
        else:
            self.register_success_conditions(
                [JointCondition(self.left_joint, 1.57)])

        return [
            'turn %s tap' % option,
            'rotate the %s tap' % option,
            'grasp the %s tap and turn it' % option
        ]
Esempio n. 14
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])
Esempio n. 15
0
 def init_episode(self, index: int) -> List[str]:
     option = self.options[index]
     self.waypoint1.set_position(self.anchors[index].get_position())
     self.register_success_conditions(
         [JointCondition(self.joints[index], 0.15)])
     return [
         'open %s drawer' % option,
         'grip the %s handle and pull the %s drawer open' %
         (option, option),
         'slide the %s drawer open' % option
     ]
Esempio n. 16
0
    def init_episode(self, index: int) -> List[str]:
        option = OPTIONS[index]
        self.joints[index].set_joint_position(0.1)
        self.register_success_conditions(
            [JointCondition(self.joints[index], 0.06)])
        x, y, z = self.waypoint0.get_position()
        _, _, target_z = self.anchors[index].get_position()
        self.waypoint0.set_position([x, y, target_z])

        return ['close %s drawer' % (option,),
                'shut the %s drawer' % (option,),
                'slide the %s drawer shut' % (option,)]
Esempio n. 17
0
class GetIceFromFridge(Task):
    def init_task(self) -> None:
        self.drops = []
        self.success_sensor = ProximitySensor('success')
        self.cup = Shape('cup')
        self.register_graspable_objects([self.cup])
        self.tongue_condition = JointCondition(Joint('joint'), np.deg2rad(1))

    def init_episode(self, index: int) -> List[str]:
        self.register_success_conditions(
            [DetectedCondition(self.robot.gripper, self.success_sensor)])
        self.tongued = False
        self.tonguedOnce = False
        return [
            'get ice from fridge', 'use the cup to get ice from the fridge',
            'pick up the cup and fill it with ice from the fridge',
            'push the cup up against the tongue of the ice dispenser to '
            'retrieve ice from the fridge'
        ]

    def variation_count(self) -> int:
        return 1

    def step(self) -> None:
        if not self.tongued:
            self.tongued = self.tongue_condition.condition_met()[0]
            if self.tongued and not self.tonguedOnce:
                for i in range(ICE_NUM):
                    drop = Shape.create(PrimitiveShape.CUBOID,
                                        mass=0.0001,
                                        size=[0.005, 0.005, 0.005])
                    drop.set_color([0.1, 0.1, 0.9])
                    pos = list(np.random.normal(0, 0.0005, size=(3, )))
                    drop.set_position(pos, relative_to=self.cup)
                    self.drops.append(drop)
                self.register_success_conditions([
                    DetectedCondition(self.drops[i], self.success_sensor)
                    for i in range(ICE_NUM)
                ])
                self.tonguedOnce = True

    def cleanup(self) -> None:
        for d in self.drops:
            d.remove()
        self.drops = []

    def boundary_root(self) -> Object:
        return Shape('fridge_root')

    def base_rotation_bounds(
            self
    ) -> Tuple[Tuple[float, float, float], Tuple[float, float, float]]:
        return (0.0, 0.0, -3.14 / 2), (0.0, 0.0, 3.14 / 2)
Esempio n. 18
0
    def init_task(self) -> None:
        self.buttons_pushed = 0
        self.color_variation_index = 0
        self.target_buttons = [Shape('push_buttons_target%d' % i)
                               for i in range(3)]
        self.target_topPlates = [Shape('target_button_topPlate%d' % i)
                                 for i in range(3)]
        self.target_joints = [Joint('target_button_joint%d' % i)
                              for i in range(3)]
        self.target_wraps = [Shape('target_button_wrap%d' % i)
                             for i in range(3)]
        self.boundaries = Shape('push_buttons_boundary')
        # goal_conditions merely state joint conditions for push action for
        # each button regardless of whether the task involves pushing it
        self.goal_conditions = [JointCondition(self.target_joints[n], 0.005)
                                for n in range(3)]

        self.register_waypoint_ability_start(0, self._move_above_next_target)
        self.register_waypoints_should_repeat(self._repeat)
Esempio n. 19
0
class TvOn(Task):
    def init_task(self) -> None:
        self.tv = Shape('tv_frame')
        self.screen_on = Shape('tv_screen_on')
        self.remote = Shape('tv_remote')
        self.boundary = Shape('spawn_boundary')
        self.condition = JointCondition(Joint('target_button_joint0'), 0.005)

    def init_episode(self, index: int) -> List[str]:
        self.register_success_conditions([self.condition])
        self.register_graspable_objects([self.remote])
        b = SpawnBoundary([self.boundary])
        b.sample(self.remote)
        return [
            'turn on the TV',
            'point the remote control at the television and turn on the '
            'television',
            'pick up the remote and rotate it such that the front of the '
            'remote is pointed straight at the television, then set the '
            'remote down and press the power button down in order to switch'
            ' on the TV',
            'find the power button at the top of the remote, ensure the '
            'remote is pointed at the tv, then turn the tv on'
        ]

    def variation_count(self) -> int:
        return 1

    def step(self) -> None:
        if self.condition.condition_met() == (True, True):
            self.screen_on.set_position(
                [0, -2.3597 * 10**(-2), 5.2194 * 10**(-4)],
                relative_to=self.tv,
                reset_dynamics=False)

    def base_rotation_bounds(
            self
    ) -> Tuple[Tuple[float, float, float], Tuple[float, float, float]]:
        return (0.0, 0.0, -0.5 * np.pi), (0.0, 0.0, +0.5 * np.pi)
Esempio n. 20
0
class LampOff(Task):
    def init_task(self) -> None:
        self.bulb_glass_visual = Shape('bulb')
        self.bulb_glass_visual.set_color([1, 1, 1])
        self.joint = Joint('target_button_joint')
        self.condition = JointCondition(self.joint, 0.005)

    def init_episode(self, index: int) -> List[str]:
        self.bulb_glass_visual.set_color([1, 1, 1])
        self.register_success_conditions([self.condition])
        return [
            'turn off the light', 'press the button to turn off the lamp',
            'press the light switch', 'turn the lamp off',
            'close the gripper and press on the button until the light '
            'turns off'
        ]

    def variation_count(self) -> int:
        return 1

    def step(self) -> None:
        if self.condition.condition_met() == (True, True):
            self.bulb_glass_visual.set_color([0, 0, 0])
Esempio n. 21
0
 def init_task(self) -> None:
     self._remote = Shape('tv_remote')
     self._spawn_boundary = SpawnBoundary([Shape('spawn_boundary')])
     self.register_graspable_objects([self._remote])
     self.register_success_conditions(
         [JointCondition(Joint('target_button_joint0'), 0.003)])
Esempio n. 22
0
 def init_task(self) -> None:
     self.bulb_glass_visual = Shape('bulb')
     self.bulb_glass_visual.set_color([0, 0, 0])
     self.joint = Joint('target_button_joint')
     self.condition = JointCondition(self.joint, 0.005)
Esempio n. 23
0
 def init_task(self) -> None:
     self.tv = Shape('tv_frame')
     self.screen_on = Shape('tv_screen_on')
     self.remote = Shape('tv_remote')
     self.boundary = Shape('spawn_boundary')
     self.condition = JointCondition(Joint('target_button_joint0'), 0.003)
Esempio n. 24
0
 def init_task(self):
     self.target_button = Shape('push_button_target')
     self.target_topPlate = Shape('target_button_topPlate')
     self.joint = Joint('target_button_joint')
     self.target_wrap = Shape('target_button_wrap')
     self.goal_condition = JointCondition(self.joint, 0.005)
Esempio n. 25
0
 def init_task(self) -> None:
     joint = Joint('toilet_seat_up_revolute_joint')
     self.register_success_conditions([JointCondition(joint, 1.7)])
Esempio n. 26
0
 def init_task(self):
     top_joint = Joint('top_joint')
     self.register_success_conditions(
         [JointCondition(top_joint, np.deg2rad(30))])
Esempio n. 27
0
 def init_task(self) -> None:
     laptop_joint = Joint('joint')
     self.register_success_conditions([JointCondition(laptop_joint, 1.79)])
Esempio n. 28
0
 def init_task(self) -> None:
     self.register_success_conditions(
         [JointCondition(Joint('microwave_door_joint'), np.deg2rad(80))])
Esempio n. 29
0
class OpenWindow(Task):
    def init_task(self):
        self.waypoint0 = Dummy('waypoint0')
        self.waypoint1 = Dummy('waypoint1')
        self.waypoint2 = Dummy('waypoint2')
        self.waypoint3 = Dummy('waypoint3')

        self.waypoint0_ = Dummy('waypoint0_')
        self.waypoint1_ = Dummy('waypoint1_')
        self.waypoint2_ = Dummy('waypoint2_')
        self.waypoint3_ = Dummy('waypoint3_')

        self.right_unlocked_cond = JointCondition(Joint('right_handle_joint'),
                                                  np.deg2rad(60))
        self.left_unlocked_cond = JointCondition(Joint('left_handle_joint'),
                                                 np.deg2rad(60))
        self.right_frame = Shape('right_frame')
        self.left_frame = Shape('left_frame')

    def init_episode(self, index: int) -> List[str]:
        self.right_frame.set_dynamic(False)
        self.left_frame.set_dynamic(False)
        self.left_unlocked = False
        self.right_unlocked = False

        option = OPTIONS[index]

        if option == 'right':
            self.waypoint0.set_position(self.waypoint0_.get_position())
            self.waypoint1.set_position(self.waypoint1_.get_position())
            self.waypoint2.set_position(self.waypoint2_.get_position())
            self.waypoint2.set_orientation(self.waypoint2_.get_orientation())
            self.waypoint3.set_position(self.waypoint3_.get_position())
            self.waypoint3.set_orientation(self.waypoint3_.get_orientation())
            self.register_success_conditions(
                [JointCondition(Joint('right_window_joint'), np.deg2rad(50))])
        else:
            self.register_success_conditions(
                [JointCondition(Joint('left_window_joint'), np.deg2rad(50))])
        return [
            'open %s window' % option,
            'rotate the handle to unlock the %s window, then open it' % option,
            'push the %s window open' % option,
            'use the handle to open the %s window' % option
        ]

    def variation_count(self) -> int:
        return 2

    def step(self) -> None:
        if not self.left_unlocked:
            self.left_unlocked = self.left_unlocked_cond.condition_met()[0]
            if self.left_unlocked:
                self.left_frame.set_dynamic(True)

        if not self.right_unlocked:
            self.right_unlocked = self.right_unlocked_cond.condition_met()[0]
            if self.right_unlocked:
                self.right_frame.set_dynamic(True)

    def base_rotation_bounds(self) -> Tuple[List[float], List[float]]:
        return [0, 0, -3.14 / 4.], [0, 0, 3.14 / 4.]

    def boundary_root(self) -> Object:
        return Shape('boundary_root')
Esempio n. 30
0
 def init_task(self) -> None:
     self._door_joint = Joint('door_frame_joint')
     self.register_success_conditions(
         [JointCondition(self._door_joint, np.deg2rad(25))])
     self.door_unlock_cond = JointCondition(Joint('door_handle_joint'),
                                            np.deg2rad(25))