Esempio n. 1
0
    def setUp(self):

        domain_fname = '../domains/namo_domain/namo.domain'
        d_c = main.parse_file_to_dict(domain_fname)
        domain = parse_domain_config.ParseDomainConfig.parse(d_c)
        hls = hl_solver.FFSolver(d_c)

        def get_plan(p_fname, plan_str=None):
            p_c = main.parse_file_to_dict(p_fname)
            problem = parse_problem_config.ParseProblemConfig.parse(p_c, domain)
            abs_problem = hls.translate_problem(problem)
            if plan_str is not None:
                return hls.get_plan(plan_str, domain, problem)
            return hls.solve(abs_problem, domain, problem)

        self.move_no_obs = get_plan('../domains/namo_domain/namo_probs/move_no_obs.prob')
        self.move_w_obs = get_plan('../domains/namo_domain/namo_probs/move_w_obs.prob')
        self.move_grasp = get_plan('../domains/namo_domain/namo_probs/move_grasp.prob')
        self.move_grasp_moveholding = get_plan('../domains/namo_domain/namo_probs/moveholding.prob')
        self.place = get_plan('../domains/namo_domain/namo_probs/place.prob')
        self.putaway = get_plan('../domains/namo_domain/namo_probs/putaway.prob')
        self.putaway3 = get_plan('../domains/namo_domain/namo_probs/putaway3.prob')
        self.putaway2 = get_plan('../domains/namo_domain/namo_probs/putaway2.prob', ['0: MOVETO PR2 ROBOT_INIT_POSE PDP_TARGET2',
                                                                                     '1: GRASP PR2 CAN0 TARGET0 PDP_TARGET2 PDP_TARGET0 GRASP0',
                                                                                     '2: MOVETOHOLDING PR2 PDP_TARGET0 PDP_TARGET2 CAN0 GRASP0',
                                                                                     '3: PUTDOWN PR2 CAN0 TARGET2 PDP_TARGET2 ROBOT_END_POSE GRASP0'])
Esempio n. 2
0
    def setUp(self):
        domain_fname, problem_fname = '../domains/namo_domain/namo.domain', '../domains/namo_domain/namo_probs/namo_1234_1.prob'
        self.d_c = main.parse_file_to_dict(domain_fname)
        self.domain = parse_domain_config.ParseDomainConfig.parse(self.d_c)

        self.p_c = main.parse_file_to_dict(problem_fname)
        self.hls = hl_solver.FFSolver(self.d_c)
Esempio n. 3
0
def load_environment(domain_file, problem_file):
    domain_fname = domain_file
    d_c = main.parse_file_to_dict(domain_fname)
    domain = parse_domain_config.ParseDomainConfig.parse(d_c)
    p_fname = problem_file
    p_c = main.parse_file_to_dict(p_fname)
    problem = parse_problem_config.ParseProblemConfig.parse(p_c, domain)
    params = problem.init_state.params
    hls = hl_solver.FFSolver(d_c)
    plan = hls.get_plan(
        ['0: GRASP BAXTER CAN0 TARGET0 PDP_TARGET0 EE_TARGET0 ROBOT_END_POSE'],
        domain, problem)
    return domain, problem, params, plan
Esempio n. 4
0
def main():
    d_c = parse_file_to_dict(domain_fname)
    domain = parse_domain_config.ParseDomainConfig.parse(d_c)
    hls = hl_solver.FFSolver(d_c)

    p_c = parse_file_to_dict(problem_fname)
    problem = parse_problem_config.ParseProblemConfig.parse(p_c, domain)

    plan = hls.get_plan(PLAN_SWAP_STR, domain, problem)
    _test_plan(plan,
               'SQP',
               plot=False,
               animate=False,
               verbose=True,
               early_converge=True)
Esempio n. 5
0
    def setUp(self):
        domain_fname = '../domains/can_domain/can.domain'
        d_c = main.parse_file_to_dict(domain_fname)
        domain = parse_domain_config.ParseDomainConfig.parse(d_c)
        hls = hl_solver.FFSolver(d_c)

        def get_plan(p_fname, plan_str=None):
            p_c = main.parse_file_to_dict(p_fname)
            problem = parse_problem_config.ParseProblemConfig.parse(
                p_c, domain)
            abs_problem = hls.translate_problem(problem)
            if plan_str is not None:
                return hls.get_plan(plan_str, domain, problem)
            # view = OpenRAVEViewer()
            # robot = problem.init_state.params['pr2']
            # table = problem.init_state.params['table']
            # cans = []
            # for param_name, param in problem.init_state.params.iteritems():
            #     if "can" in param_name:
            #         cans.append(param)
            # objs = [robot, table]
            # objs.extend(cans)
            # view.draw(objs, 0, 0.7)
            return hls.solve(abs_problem, domain, problem)

        self.bmove = get_plan(
            '../domains/can_domain/can_probs/can_1234_0.prob')

        # self.move_obs = get_plan('../domains/can_domain/can_probs/move_obs.prob')

        # self.move_no_obs = get_plan('../domains/can_domain/can_probs/move.prob')
        # self.move_no_obs = get_plan('../domains/can_domain/can_probs/can_1234_0.prob')
        # self.grasp = get_plan('../domains/can_domain/can_probs/grasp.prob')
        # self.grasp = get_plan('../domains/can_domain/can_probs/grasp_rot.prob')
        # self.grasp_gen = get_plan('../domains/can_domain/can_probs/can_grasp_1234_0.prob')
        # self.moveholding = get_plan('../domains/can_domain/can_probs/can_1234_0.prob', ['0: MOVETOHOLDING PR2 ROBOT_INIT_POSE ROBOT_END_POSE CAN0'])
        # # self.moveholding = get_plan('../domains/can_domain/can_probs/can_1234_0.prob')
        # self.gen_plan = get_plan('../domains/can_domain/can_probs/can_1234_0.prob')
        # self.grasp_obstructs1 = get_plan('../domains/can_domain/can_probs/can_grasp_1234_1.prob', ['0: GRASP PR2 CAN0 TARGET0 PDP_TARGET0 EE_TARGET0 PDP_TARGET0'])
        # self.grasp_obstructs0 = get_plan('../domains/can_domain/can_probs/can_grasp_1234_0.prob', ['0: GRASP PR2 CAN0 TARGET0 PDP_TARGET0 EE_TARGET0 PDP_TARGET0'])

        # self.grasp_obstructs = get_plan('../domains/can_domain/can_probs/can_grasp_1234_4.prob', ['0: GRASP PR2 CAN0 TARGET0 PDP_TARGET0 EE_TARGET0 PDP_TARGET0'])

        if VIEWER:
            self.viewer = OpenRAVEViewer.create_viewer()
        else:
            self.viewer = None
Esempio n. 6
0
    def test_realistic_training(self):
        domain_fname = '../domains/baxter_domain/baxter.domain'
        d_c = main.parse_file_to_dict(domain_fname)
        domain = parse_domain_config.ParseDomainConfig.parse(d_c)
        hls = hl_solver.FFSolver(d_c)

        def get_plan(p_fname, plan_str=None):
            p_c = main.parse_file_to_dict(p_fname)
            problem = parse_problem_config.ParseProblemConfig.parse(
                p_c, domain)
            abs_problem = hls.translate_problem(problem)
            if plan_str is not None:
                return hls.get_plan(plan_str, domain, problem)
            return hls.solve(abs_problem, domain, problem)

        result = []
        #8 doesn't work
        plan_list = [1, 2, 3]
        for i in [1]:
            print "Generating plan_{}".format(i)
            prob_file = '../domains/baxter_domain/baxter_training_probs/grasp_training_4321_{}.prob'.format(
                i)

            plan_str = [
                '0: MOVETO BAXTER ROBOT_INIT_POSE PDP_TARGET0',
                '1: GRASP BAXTER CAN0 TARGET0 PDP_TARGET0 EE_TARGET0 PDP_TARGET1',
                '2: MOVETOHOLDING BAXTER PDP_TARGET1 ROBOT_END_POSE CAN0'
            ]

            plan = get_plan(prob_file, plan_str)

            geom = plan.params['can0'].geom
            plan.params['can0'].geom = GreenCan(geom.radius, geom.height)

            solver = robot_ll_solver.RobotLLSolver()

            def viewer():
                return OpenRAVEViewer.create_viewer(plan.env)

            timesteps = solver.solve(plan,
                                     callback=viewer,
                                     n_resamples=5,
                                     verbose=False)
Esempio n. 7
0
def test_prg(self, prob_file):

    domain_fname = '../domains/namo_domain/namo.domain'
    problem_fname = prob_file
    d_c = main.parse_file_to_dict(domain_fname)
    p_c = main.parse_file_to_dict(problem_fname)
    s_c = {'LLSolver': 'NAMOSolver', 'HLSolver': 'FFSolver'}
    domain = parse_domain_config.ParseDomainConfig.parse(d_c)
    hls = hl_solver.FFSolver(d_c)
    # """
    # Initialize Suggester
    # """
    # import ipdb; ipdb.set_trace()
    # suggester = PostLearner({}, "prg_testing", space = "CONFIG")
    # if not suggester.trained:
    #     feature_function = None
    #     suggester.train(domain, problem, feature_function)
    # """
    # End of Suggester
    # """
    plan, msg = pr_graph.p_mod_abs(d_c, p_c, s_c,suggester = None, debug=True)
    self.assertEqual(len(plan.get_failed_preds()), 0)