Пример #1
0
def get_vis_gen(problem, max_attempts=25, base_range=(0.5, 1.5)):
    robot = problem.robot
    fixed = get_fixed_bodies(problem)
    base_joints = get_group_joints(robot, 'base')
    head_joints = get_group_joints(robot, 'head')

    def gen(o, p):
        # default_conf = arm_conf(a, g.carry)
        # joints = get_arm_joints(robot, a)
        # TODO: check collisions with fixed links
        target_point = point_from_pose(p.value)
        base_generator = visible_base_generator(robot, target_point,
                                                base_range)
        while True:
            for _ in range(max_attempts):
                set_pose(o, p.value)
                base_conf = next(base_generator)
                #set_base_values(robot, base_conf)
                set_joint_positions(robot, base_joints, base_conf)
                if any(pairwise_collision(robot, b) for b in fixed):
                    continue
                head_conf = inverse_visibility(robot, target_point)
                if head_conf is None:  # TODO: test if visible
                    continue
                #bq = Pose(robot, get_pose(robot))
                bq = Conf(robot, base_joints, base_conf)
                hq = Conf(robot, head_joints, head_conf)
                yield (bq, hq)
                break
            else:
                yield None

    return gen
Пример #2
0
def get_scan_gen(state, max_attempts=25, base_range=(0.5, 1.5)):
    task = state.task
    robot = task.robot
    base_joints = get_group_joints(robot, 'base')
    head_joints = get_group_joints(robot, 'head')
    vis_gen = get_vis_gen(task,
                          max_attempts=max_attempts,
                          base_range=base_range)
    tilt = np.pi / 6

    def gen(o, p):
        if o in task.rooms:
            #bq = Pose(robot, unit_pose())
            #bq = state.poses[robot]
            bq = Conf(robot, base_joints, np.zeros(len(base_joints)))
            #hq = Conf(robot, head_joints, np.zeros(len(head_joints)))
            #ht = create_trajectory(robot, head_joints, plan_pause_scan_path(robot, tilt=tilt))
            waypoints = plan_scan_path(task.robot, tilt=tilt)
            set_group_conf(robot, 'head', waypoints[0])
            path = plan_waypoints_joint_motion(robot,
                                               head_joints,
                                               waypoints[1:],
                                               obstacles=None,
                                               self_collisions=False)
            ht = create_trajectory(robot, head_joints, path)
            yield bq, ht.path[0], ht
        else:
            for bq, hq in vis_gen(o, p):
                ht = Trajectory([hq])
                yield bq, ht.path[0], ht

    return gen
Пример #3
0
def get_inverse_visibility_fn(task):
    robot = task.robot
    head_joints = get_group_joints(robot, 'head')

    def fn(o, p, bq):
        set_pose(o, p.value)  # p.assign()
        bq.assign()
        if o in task.rooms:
            waypoints = plan_scan_path(task.robot, tilt=ROOM_SCAN_TILT)
            set_group_conf(robot, 'head', waypoints[0])
            path = plan_waypoints_joint_motion(robot,
                                               head_joints,
                                               waypoints[1:],
                                               obstacles=None,
                                               self_collisions=False)
            if path is None:
                return None
            ht = create_trajectory(robot, head_joints, path)
            hq = ht.path[0]
        else:
            target_point = point_from_pose(p.value)
            head_conf = inverse_visibility(robot, target_point)
            if head_conf is None:  # TODO: test if visible
                return None
            hq = Conf(robot, head_joints, head_conf)
            ht = Trajectory([hq])
        return (hq, ht)

    return fn
Пример #4
0
def get_vis_base_gen(task, base_range):
    robot = task.robot
    fixed = get_fixed_bodies(task)
    base_joints = get_group_joints(robot, 'base')

    def gen(o, p):
        if o in task.rooms:  # TODO: predicate instead
            return
        # default_conf = arm_conf(a, g.carry)
        # joints = get_arm_joints(robot, a)
        # TODO: check collisions with fixed links
        target_point = point_from_pose(p.value)
        base_generator = visible_base_generator(robot, target_point,
                                                base_range)
        while True:
            set_pose(o, p.value)  # p.assign()
            bq = Conf(robot, base_joints, next(base_generator))
            # bq = Pose(robot, get_pose(robot))
            bq.assign()
            if any(pairwise_collision(robot, b) for b in fixed):
                yield None
            else:
                yield (bq, )

    # TODO: return list_fn & accelerated
    return gen
Пример #5
0
def pddlstream_from_problem(problem, teleport=False, movable_collisions=False):
    robot = problem.robot

    domain_pddl = read(get_file_path(__file__, 'domain.pddl'))
    stream_pddl = read(get_file_path(__file__, 'stream.pddl'))
    constant_map = {}

    #initial_bq = Pose(robot, get_pose(robot))
    initial_bq = Conf(robot, get_group_joints(robot, 'base'), get_group_conf(robot, 'base'))
    init = [
        ('CanMove',),
        ('BConf', initial_bq),
        ('AtBConf', initial_bq),
        Equal(('PickCost',), scale_cost(1)),
        Equal(('PlaceCost',), scale_cost(1)),
    ] + [('Sink', s) for s in problem.sinks] + \
           [('Stove', s) for s in problem.stoves] + \
           [('Connected', b, d) for b, d in problem.buttons] + \
           [('Button', b) for b, _ in problem.buttons]
    for arm in ARM_NAMES:
    #for arm in problem.arms:
        joints = get_arm_joints(robot, arm)
        conf = Conf(robot, joints, get_joint_positions(robot, joints))
        init += [('Arm', arm), ('AConf', arm, conf), ('HandEmpty', arm), ('AtAConf', arm, conf)]
        if arm in problem.arms:
            init += [('Controllable', arm)]
    for body in problem.movable:
        pose = Pose(body, get_pose(body))
        init += [('Graspable', body), ('Pose', body, pose),
                 ('AtPose', body, pose)]
        for surface in problem.surfaces:
            init += [('Stackable', body, surface)]
            if is_placement(body, surface):
                init += [('Supported', body, pose, surface)]

    goal = [AND]
    if problem.goal_conf is not None:
        goal_conf = Pose(robot, problem.goal_conf)
        init += [('BConf', goal_conf)]
        goal += [('AtBConf', goal_conf)]
    goal += [('Holding', a, b) for a, b in problem.goal_holding] + \
                     [('On', b, s) for b, s in problem.goal_on] + \
                     [('Cleaned', b)  for b in problem.goal_cleaned] + \
                     [('Cooked', b)  for b in problem.goal_cooked]

    stream_map = {
        'sample-pose': get_stable_gen(problem),
        'sample-grasp': from_list_fn(get_grasp_gen(problem)),
        'inverse-kinematics': from_gen_fn(get_ik_ir_gen(problem, teleport=teleport)),
        'plan-base-motion': from_fn(get_motion_gen(problem, teleport=teleport)),
        'MoveCost': move_cost_fn,
        'TrajPoseCollision': fn_from_constant(False),
        'TrajArmCollision': fn_from_constant(False),
        'TrajGraspCollision': fn_from_constant(False),
    }
    if USE_SYNTHESIZERS:
        stream_map['plan-base-motion'] = empty_gen(),
    # get_press_gen(problem, teleport=teleport)

    return domain_pddl, constant_map, stream_pddl, stream_map, init, goal
Пример #6
0
    def apply(self, state, **kwargs):
        # TODO: identify surface automatically
        with LockRenderer():
            cone = get_viewcone(color=apply_alpha(RED, 0.5))
            set_pose(cone, get_link_pose(self.robot, self.link))
            wait_for_duration(1e-2)
        wait_for_duration(self._duration)  # TODO: don't sleep if no viewer?
        remove_body(cone)
        wait_for_duration(1e-2)

        if self.detect:
            # TODO: the collision geometries are being visualized
            # TODO: free the renderer
            head_joints = get_group_joints(self.robot, 'head')
            exclude_links = set(
                get_link_subtree(self.robot,
                                 child_link_from_joint(head_joints[-1])))
            detections = get_visual_detections(
                self.robot,
                camera_link=self.camera_frame,
                exclude_links=exclude_links,
            )
            #color=apply_alpha(RED, 0.5))
            print('Detections:', detections)
            for body, dist in state.b_on.items():
                obs = (body in detections) and (is_center_stable(
                    body, self.surface))
                if obs or (self.surface not in state.task.rooms):
                    # TODO: make a command for scanning a room instead?
                    dist.obsUpdate(get_observation_fn(self.surface), obs)
            #state.localized.update(detections)
        # TODO: pose for each object that can be real or fake
        yield
Пример #7
0
def plan_head_traj(robot, head_conf):
    # head_conf = get_joint_positions(robot, head_joints)
    # head_path = [head_conf, hq.values]
    head_joints = get_group_joints(robot, 'head')
    head_path = plan_direct_joint_motion(robot,
                                         head_joints,
                                         head_conf,
                                         obstacles=None,
                                         self_collisions=False)
    assert (head_path is not None)
    return create_trajectory(robot, head_joints, head_path)
Пример #8
0
def plan_head_traj(task, head_conf):
    robot = task.robot
    obstacles = get_fixed_bodies(task)  # TODO: movable objects
    # head_conf = get_joint_positions(robot, head_joints)
    # head_path = [head_conf, hq.values]
    head_joints = get_group_joints(robot, 'head')
    head_path = plan_direct_joint_motion(robot,
                                         head_joints,
                                         head_conf,
                                         obstacles=obstacles,
                                         self_collisions=SELF_COLLISIONS)
    assert (head_path is not None)
    return create_trajectory(robot, head_joints, head_path)
Пример #9
0
 def gen(objective):
     base_joints = get_group_joints(robot, 'base')
     head_joints = get_group_joints(robot, 'head')
     target_point = get_point(objective)
     base_generator = visible_base_generator(robot, target_point,
                                             base_range)
     lower_limits, upper_limits = get_custom_limits(robot, base_joints,
                                                    custom_limits)
     while True:
         base_conf = next(base_generator)
         if not all_between(lower_limits, base_conf, upper_limits):
             continue
         bq = Conf(robot, base_joints, base_conf)
         bq.assign()
         if any(pairwise_collision(robot, b) for b in fixed):
             continue
         head_conf = inverse_visibility(robot, target_point)
         if head_conf is None:  # TODO: test if visible
             continue
         hq = Conf(robot, head_joints, head_conf)
         y = None
         yield (bq, hq, y)
Пример #10
0
 def gen(rock):
     base_joints = get_group_joints(rover, 'base')
     x, y, _ = get_point(rock)
     lower_limits, upper_limits = get_custom_limits(rover, base_joints,
                                                    custom_limits)
     while True:
         theta = np.random.uniform(-np.pi, np.pi)
         base_conf = [x, y, theta]
         if not all_between(lower_limits, base_conf, upper_limits):
             continue
         bq = Conf(rover, base_joints, base_conf)
         bq.assign()
         if any(pairwise_collision(rover, b) for b in fixed):
             continue
         yield (bq, )
Пример #11
0
def move_look_trajectory(task,
                         trajectory,
                         max_tilt=np.pi / 6):  # max_tilt=INF):
    # TODO: implement a minimum distance instead of max_tilt
    # TODO: pr2 movement restrictions
    #base_path = [pose.to_base_conf() for pose in trajectory.path]
    base_path = trajectory.path
    if not base_path:
        return trajectory
    obstacles = get_fixed_bodies(task)  # TODO: movable objects
    robot = base_path[0].body
    target_path = get_target_path(trajectory)
    waypoints = []
    index = 0
    with BodySaver(robot):
        #current_conf = base_values_from_pose(get_pose(robot))
        for i, conf in enumerate(base_path):  # TODO: just do two loops?
            conf.assign()
            while index < len(target_path):
                if i < index:
                    # Don't look at past or current conf
                    target_point = target_path[index]
                    head_conf = inverse_visibility(
                        robot, target_point)  # TODO: this is slightly slow
                    #print(index, target_point, head_conf)
                    if (head_conf is not None) and (head_conf[1] < max_tilt):
                        break
                index += 1
            else:
                head_conf = get_group_conf(robot, 'head')
            set_group_conf(robot, 'head', head_conf)
            #print(i, index, conf.values, head_conf) #, get_pose(robot))
            waypoints.append(np.concatenate([conf.values, head_conf]))
    joints = tuple(base_path[0].joints) + tuple(get_group_joints(
        robot, 'head'))
    #joints = get_group_joints(robot, 'base') + get_group_joints(robot, 'head')
    #set_pose(robot, unit_pose())
    #set_group_conf(robot, 'base', current_conf)
    path = plan_waypoints_joint_motion(robot,
                                       joints,
                                       waypoints,
                                       obstacles=obstacles,
                                       self_collisions=SELF_COLLISIONS)
    return create_trajectory(robot, joints, path)
Пример #12
0
def inspect_trajectory(trajectory):
    if not trajectory.path:
        return
    robot = trajectory.path[0].body
    # TODO: minimum distance of some sort (to prevent from looking at the bottom)
    # TODO: custom lower limit as well
    head_waypoints = []
    for target_point in get_target_path(trajectory):
        head_conf = inverse_visibility(robot, target_point)
        # TODO: could also draw the sequence of inspected points as the head moves
        if head_conf is None:
            continue
        head_waypoints.append(head_conf)
    head_joints = get_group_joints(robot, 'head')
    #return create_trajectory(robot, head_joints, head_waypoints)
    head_path = plan_waypoints_joint_motion(robot,
                                            head_joints,
                                            head_waypoints,
                                            obstacles=None,
                                            self_collisions=False)
    assert (head_path is not None)
    return create_trajectory(robot, head_joints, head_path)
Пример #13
0
def pddlstream_from_state(state, teleport=False):
    task = state.task
    robot = task.robot
    # TODO: infer open world from task

    domain_pddl = read(get_file_path(__file__, 'domain.pddl'))
    stream_pddl = read(get_file_path(__file__, 'stream.pddl'))
    constant_map = {
        'base': 'base',
        'left': 'left',
        'right': 'right',
        'head': 'head',
    }

    #base_conf = state.poses[robot]
    base_conf = Conf(robot, get_group_joints(robot, 'base'),
                     get_group_conf(robot, 'base'))
    scan_cost = 1
    init = [
        ('BConf', base_conf),
        ('AtBConf', base_conf),
        Equal(('MoveCost', ), 1),
        Equal(('PickCost', ), 1),
        Equal(('PlaceCost', ), 1),
        Equal(('ScanCost', ), scan_cost),
        Equal(('RegisterCost', ), 1),
    ]
    holding_arms = set()
    holding_bodies = set()
    for attach in state.attachments.values():
        holding_arms.add(attach.arm)
        holding_bodies.add(attach.body)
        init += [('Grasp', attach.body, attach.grasp),
                 ('AtGrasp', attach.arm, attach.body, attach.grasp)]
    for arm in ARM_NAMES:
        joints = get_arm_joints(robot, arm)
        conf = Conf(robot, joints, get_joint_positions(robot, joints))
        init += [('Arm', arm), ('AConf', arm, conf), ('AtAConf', arm, conf)]
        if arm in task.arms:
            init += [('Controllable', arm)]
        if arm not in holding_arms:
            init += [('HandEmpty', arm)]
    for body in task.get_bodies():
        if body in holding_bodies:
            continue
        # TODO: no notion whether observable actually corresponds to the correct thing
        pose = state.poses[body]
        init += [
            ('Pose', body, pose),
            ('AtPose', body, pose),
            ('Observable', pose),
        ]

    init += [('Scannable', body) for body in task.rooms + task.surfaces]
    init += [('Registerable', body) for body in task.movable]
    init += [('Graspable', body) for body in task.movable]
    for body in task.get_bodies():
        supports = task.get_supports(body)
        if supports is None:
            continue
        for surface in supports:
            p_obs = state.b_on[body].prob(surface)
            cost = revisit_mdp_cost(0, scan_cost,
                                    p_obs)  # TODO: imperfect observation model
            init += [('Stackable', body, surface),
                     Equal(('LocalizeCost', surface, body), clip_cost(cost))]
            #if is_placement(body, surface):
            if is_center_stable(body, surface):
                if body in holding_bodies:
                    continue
                pose = state.poses[body]
                init += [('Supported', body, pose, surface)]

    for body in task.get_bodies():
        if state.is_localized(body):
            init.append(('Localized', body))
        else:
            init.append(('Uncertain', body))
        if body in state.registered:
            init.append(('Registered', body))

    goal = And(*[('Holding', a, b) for a, b in task.goal_holding] + \
           [('On', b, s) for b, s in task.goal_on] + \
           [('Localized', b) for b in task.goal_localized] + \
           [('Registered', b) for b in task.goal_registered])

    stream_map = {
        'sample-pose':
        get_stable_gen(task),
        'sample-grasp':
        from_list_fn(get_grasp_gen(task)),
        'inverse-kinematics':
        from_gen_fn(get_ik_ir_gen(task, teleport=teleport)),
        'plan-base-motion':
        from_fn(get_motion_gen(task, teleport=teleport)),
        'test-vis-base':
        from_test(get_in_range_test(task, VIS_RANGE)),
        'test-reg-base':
        from_test(get_in_range_test(task, REG_RANGE)),
        'sample-vis-base':
        accelerate_list_gen_fn(from_gen_fn(get_vis_base_gen(task, VIS_RANGE)),
                               max_attempts=25),
        'sample-reg-base':
        accelerate_list_gen_fn(from_gen_fn(get_vis_base_gen(task, REG_RANGE)),
                               max_attempts=25),
        'inverse-visibility':
        from_fn(get_inverse_visibility_fn(task)),
    }

    return PDDLProblem(domain_pddl, constant_map, stream_pddl, stream_map,
                       init, goal)
Пример #14
0
def pddlstream_from_problem(problem, collisions=True, teleport=False):
    #rovers = problem.rovers

    domain_pddl = read(get_file_path(__file__, 'domain.pddl'))
    stream_pddl = read(get_file_path(__file__, 'stream.pddl'))
    constant_map = {}

    camera = 'RGBD'
    mode = 'color'  # highres | lowres | color | depth

    init = []
    goal_literals = [
        #('Calibrated', camera, problem.rovers[0])
        #('Analyzed', problem.rovers[0], problem.rocks[0])
        #('ReceivedAnalysis', problem.rocks[0])
    ]

    init += [('Lander', l) for l in problem.landers]
    init += [('Camera', camera), ('Supports', camera, mode), ('Mode', mode)]
    for rover in problem.rovers:
        base_joints = get_group_joints(rover, 'base')
        bq0 = Conf(rover, base_joints)
        head_joints = get_group_joints(rover, 'head')
        hq0 = Conf(rover, head_joints)
        init += [('Rover', rover), ('OnBoard', camera, rover),
                 ('BConf', bq0), ('AtBConf', rover, bq0),
                 ('HConf', hq0), ('AtHConf', rover, hq0)]
    for name in problem.stores:
        init += [('Store', name)]
        init += [('Free', rover, name) for rover in problem.rovers]
    for name in problem.objectives:
        init += [('Objective', name)]
        #initial_atoms += [IsClass(name, cl) for cl in CLASSES if cl in name]
        goal_literals += [('ReceivedImage', name, mode)]
    for name in problem.rocks + problem.soils:
        # pose = Pose(name, get_pose(env.GetKinBody(name)))
        init += [('Rock', name)]  # , IsPose(name, pose), AtPose(name, pose)]
        #init += [('IsClass', name, cl) for cl in CLASSES if cl in name]

    #if problem.rocks:
    #    goal_literals.append(Exists(['?rock'], And(('Rock', '?rock'),
    #                                               ('ReceivedAnalysis', '?rock'))))
    #if problem.soils:
    #    goal_literals.append(Exists(['?soil'], And(('Soil', '?soil'),
    #                                               ('ReceivedAnalysis', '?soil')))) # TODO: soil class
    goal_formula = And(*goal_literals)

    custom_limits = {}
    if problem.limits is not None:
        for rover in problem.rovers:
            custom_limits.update(get_base_custom_limits(rover, problem.limits))

    stream_map = {
        'test-reachable': from_test(get_reachable_test(problem)),
        'obj-inv-visible': from_gen_fn(get_inv_vis_gen(problem, custom_limits=custom_limits)),
        'com-inv-visible': from_gen_fn(get_inv_com_gen(problem, custom_limits=custom_limits)),
        'sample-above': from_gen_fn(get_above_gen(problem, custom_limits=custom_limits)),
        'sample-base-motion': from_fn(get_base_motion_fn(problem, custom_limits=custom_limits, teleport=teleport)),
        'sample-head-motion': from_fn(get_head_motion_fn(problem, teleport=teleport)),
    }
    #stream_map = 'debug'

    return PDDLProblem(domain_pddl, constant_map, stream_pddl, stream_map, init, goal_formula)
Пример #15
0
def pddlstream_from_problem(problem, teleport=False, movable_collisions=False):
    robot = problem.robot

    domain_pddl = read(get_file_path(__file__, 'domain.pddl'))
    stream_pddl = read(get_file_path(__file__, 'stream.pddl'))
    constant_map = {
        'world': 'world',
    }

    world = 'world'
    #initial_bq = Pose(robot, get_pose(robot))
    initial_bq = Conf(robot, get_group_joints(robot, 'base'),
                      get_group_conf(robot, 'base'))
    init = [
        ('CanMove',),
        ('BConf', initial_bq), # TODO: could make pose as well...
        ('AtBConf', initial_bq),
        ('AtAConf', world, None),
        ('AtPose', world, world, None),
    ] + [('Sink', s) for s in problem.sinks] + \
           [('Stove', s) for s in problem.stoves] + \
           [('Connected', b, d) for b, d in problem.buttons] + \
           [('Button', b) for b, _ in problem.buttons]
    #for arm in ARM_JOINT_NAMES:
    for arm in problem.arms:
        joints = get_arm_joints(robot, arm)
        conf = Conf(robot, joints, get_joint_positions(robot, joints))
        init += [('Arm', arm), ('AConf', arm, conf), ('HandEmpty', arm),
                 ('AtAConf', arm, conf), ('AtPose', arm, arm, None)]
        if arm in problem.arms:
            init += [('Controllable', arm)]
    for body in problem.movable:
        pose = Pose(body, get_pose(body))
        init += [('Graspable', body), ('Pose', body, pose),
                 ('AtPose', world, body, pose)]
        for surface in problem.surfaces:
            init += [('Stackable', body, surface)]
            if is_placement(body, surface):
                init += [('Supported', body, pose, surface)]

    goal = ['and']
    if problem.goal_conf is not None:
        goal_conf = Pose(robot, problem.goal_conf)
        init += [('BConf', goal_conf)]
        goal += [('AtBConf', goal_conf)]
    goal += [('Holding', a, b) for a, b in problem.goal_holding] + \
                     [('On', b, s) for b, s in problem.goal_on] + \
                     [('Cleaned', b)  for b in problem.goal_cleaned] + \
                     [('Cooked', b)  for b in problem.goal_cooked]

    stream_map = {
        'sample-pose':
        get_stable_gen(problem),
        'sample-grasp':
        from_list_fn(get_grasp_gen(problem)),
        'inverse-kinematics':
        from_gen_fn(get_ik_ir_gen(problem, teleport=teleport)),
        'plan-base-motion':
        from_fn(get_motion_gen(problem, teleport=teleport)),
        #'plan-base-motion': empty_gen(),
        'BTrajCollision':
        fn_from_constant(False),
    }
    # get_press_gen(problem, teleport=teleport)

    return domain_pddl, constant_map, stream_pddl, stream_map, init, goal
Пример #16
0
def pddlstream_from_problem(problem,
                            base_limits=None,
                            collisions=True,
                            teleport=False):
    robot = problem.robot

    domain_pddl = read(get_file_path(__file__, 'domain.pddl'))
    stream_pddl = read(get_file_path(__file__, 'stream.pddl'))
    constant_map = {
        '@sink': 'sink',
        '@stove': 'stove',
    }

    #initial_bq = Pose(robot, get_pose(robot))
    initial_bq = Conf(robot, get_group_joints(robot, 'base'),
                      get_group_conf(robot, 'base'))
    init = [
        ('CanMove',),
        ('BConf', initial_bq),
        ('AtBConf', initial_bq),
        Equal(('PickCost',), 1),
        Equal(('PlaceCost',), 1),
    ] + [('Sink', s) for s in problem.sinks] + \
           [('Stove', s) for s in problem.stoves] + \
           [('Connected', b, d) for b, d in problem.buttons] + \
           [('Button', b) for b, _ in problem.buttons]
    for arm in ARM_NAMES:
        #for arm in problem.arms:
        joints = get_arm_joints(robot, arm)
        conf = Conf(robot, joints, get_joint_positions(robot, joints))
        init += [('Arm', arm), ('AConf', arm, conf), ('HandEmpty', arm),
                 ('AtAConf', arm, conf)]
        if arm in problem.arms:
            init += [('Controllable', arm)]
    for body in problem.movable:
        pose = Pose(body, get_pose(body), init=True)  # TODO: supported here
        init += [('Graspable', body), ('Pose', body, pose),
                 ('AtPose', body, pose), ('Stackable', body, None)]
        for surface in problem.surfaces:
            if is_placement(body, surface):
                init += [('Supported', body, pose, surface)]
    for body, ty in problem.body_types:
        init += [('Type', body, ty)]

    bodies_from_type = get_bodies_from_type(problem)
    goal_literals = []
    if problem.goal_conf is not None:
        goal_conf = Conf(robot, get_group_joints(robot, 'base'),
                         problem.goal_conf)
        init += [('BConf', goal_conf)]
        goal_literals += [('AtBConf', goal_conf)]
    for ty, s in problem.goal_on:
        bodies = bodies_from_type[get_parameter_name(ty)] if is_parameter(
            ty) else [ty]
        init += [('Stackable', b, s) for b in bodies]
        goal_literals += [('On', ty, s)]
    goal_literals += [('Holding', a, b) for a, b in problem.goal_holding] + \
                     [('Cleaned', b)  for b in problem.goal_cleaned] + \
                     [('Cooked', b)  for b in problem.goal_cooked]
    goal_formula = []
    for literal in goal_literals:
        parameters = [a for a in get_args(literal) if is_parameter(a)]
        if parameters:
            type_literals = [('Type', p, get_parameter_name(p))
                             for p in parameters]
            goal_formula.append(
                Exists(parameters, And(literal, *type_literals)))
        else:
            goal_formula.append(literal)
    goal_formula = And(*goal_formula)

    custom_limits = {}
    if base_limits is not None:
        custom_limits.update(get_custom_limits(robot, problem.base_limits))

    stream_map = {
        'sample-pose':
        from_gen_fn(get_stable_gen(problem, collisions=collisions)),
        'sample-grasp':
        from_list_fn(get_grasp_gen(problem, collisions=collisions)),
        #'sample-grasp': from_gen_fn(get_grasp_gen(problem, collisions=collisions)),
        'inverse-kinematics':
        from_gen_fn(
            get_ik_ir_gen(problem,
                          custom_limits=custom_limits,
                          collisions=collisions,
                          teleport=teleport)),
        'plan-base-motion':
        from_fn(
            get_motion_gen(problem,
                           custom_limits=custom_limits,
                           collisions=collisions,
                           teleport=teleport)),
        'test-cfree-pose-pose':
        from_test(get_cfree_pose_pose_test(collisions=collisions)),
        'test-cfree-approach-pose':
        from_test(get_cfree_approach_pose_test(problem,
                                               collisions=collisions)),
        'test-cfree-traj-pose':
        from_test(get_cfree_traj_pose_test(robot, collisions=collisions)),
        #'test-cfree-traj-grasp-pose': from_test(get_cfree_traj_grasp_pose_test(problem, collisions=collisions)),

        #'MoveCost': move_cost_fn,
        'Distance':
        distance_fn,
    }
    #stream_map = DEBUG

    return PDDLProblem(domain_pddl, constant_map, stream_pddl, stream_map,
                       init, goal_formula)