forked from drwiner/PyDPOCL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (50 loc) · 2.83 KB
/
Copy pathmain.py
File metadata and controls
59 lines (50 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
from PyPOCL.PyDPOCL import POCLPlanner
from PyPOCL.worldmodel import load_domain_and_problem
from PyPOCL.plan_utility import check_plan, plan_to_json, plan_to_yaml, visualize_plan, plan_to_dot
LOG = 1
if __name__ == '__main__':
num_args = len(sys.argv)
if num_args == 2:
test_i = sys.argv[1]
domain_file = 'domains/manipulation-domain/manipulation-domain.pddl'
problem_file = f'domains/manipulation-domain-batch/test_{test_i}_problem.pddl'
worldmodel_file = f'domains/manipulation-domain-batch/test_{test_i}_worldmodel.json'
elif num_args > 2:
domain_file = sys.argv[1]
problem_file = sys.argv[2]
if num_args > 3:
worldmodel_file = sys.argv[2]
else:
#domain_file = 'domains/ark-domain/ark-domain.pddl'
#problem_file = 'domains/ark-domain/ark-problem.pddl'
#worldmodel_file = None # ark problem has no geometric variables
#domain_file = 'tests/domains/test-domain.pddl'
#problem_file = 'tests/domains/test-problem.pddl'
#worldmodel_file = 'tests/domains/test-worldmodel.json'
#domain_file = 'domains/manipulation-domain/manipulation-domain.pddl'
#problem_file = 'domains/manipulation-domain/manipulation-problem3.pddl'
#worldmodel_file = 'domains/manipulation-domain/manipulation-worldmodel3.json'
test_i = 5
domain_file = 'domains/manipulation-domain/manipulation-domain.pddl'
problem_file = f'domains/manipulation-domain-batch/test_{test_i}_problem.pddl'
worldmodel_file = f'domains/manipulation-domain-batch/test_{test_i}_worldmodel.json'
# benchmarks
#domain_file = 'tests/benchmarks/manipulation-domain-geometric-threats/domain.pddl'
#problem_file = 'tests/benchmarks/manipulation-domain-geometric-threats/problem.pddl'
#worldmodel_file = 'tests/benchmarks/manipulation-domain-geometric-threats/worldmodel.json'
domain, problem = load_domain_and_problem(domain_file, problem_file, worldmodel_file)
plangraph_name = f"plans/{domain.name}/{problem.name}-plangraph"
planner = POCLPlanner(domain, problem, LOG, plangraph_name=plangraph_name)
plans, _ = planner.solve(k=1, cutoff=0)
for i in range(len(plans)):
plan = plans[i]
if not check_plan(plan):
print("Error: plan is not valid")
else:
print("Plan is valid")
visualize_plan(plan, filepath=f"plans/{domain.name}/{problem.name}-plan_{i}.png")
plan_to_dot(plan, filepath_dot=f"plans/{domain.name}/{problem.name}-plan_{i}.dot", filepath_svg=f"plans/{domain.name}/{problem.name}-plan_{i}.svg")
plan_to_json(plan, f"plans/{domain.name}/{problem.name}-plan_{i}.json")
#if domain.name == "manipulation-domain":
# plan_to_yaml(plan, f"plans/{domain.name}/{problem.name}-executable_plan_{i}.yaml")