-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtest.py
81 lines (58 loc) · 1.92 KB
/
test.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from P_MAS_TG.ts import MotionFts, ActionModel, MotActModel
from P_MAS_TG.planner import ltl_planner
# export PYTHONPATH=$PYTHONPATH:/to/your/P_MAS_TG
import time
##############################
# motion FTS
ap = {'r1', 'r2', 'r3', 'r4', 'r5', 'r6', 'r', 'b'}
# +-----+-----+-----+
# | r4,r| r5,b| r6,b|
# +-----+-----+-----+
# | r1,r| r2,b| r3,r|
# +-----+-----+-----+
regions = { (0, 0, 1): set(['r1', 'r']),
(1, 0, 1): set(['r2', 'b']),
(2, 0, 1): set(['r3', 'r']),
(0, 1, 1): set(['r4', 'r']),
(1, 1, 1): set(['r5', 'b']),
(2, 1, 1): set(['r6', 'b']),
}
edges = [((0, 0, 1), (1, 0, 1)),
((1, 0, 1), (2, 0, 1)),
((0, 1, 1), (1, 1, 1)),
((1, 1, 1), (2, 1, 1)),
((0, 0, 1), (0, 1, 1)),
((1, 0, 1), (1, 1, 1)),
((2, 0, 1), (2, 1, 1)),
]
robot_motion = MotionFts(regions, ap, 'office' )
robot_motion.set_initial((0, 0, 1))
robot_motion.add_un_edges(edges, unit_cost = 0.1)
##############################
# action FTS
############# no action model
#action = dict()
############# with action
action = { 'pick': (100, 'r', set(['pick'])),
'drop': (50, 'b', set(['drop']))
}
robot_action = ActionModel(action)
##############################
# complete robot model
robot_model = MotActModel(robot_motion, robot_action)
##############################
# specify tasks
########## only hard
#hard_task = '<>(r1 && <> (r2 && <> r6)) && (<>[] r6)'
hard_task = '<>(r1 && <> (r2 && <> r6)) && ([]<> r6) && ([]<> r1) && [] <>(r1 -> X r5)'
soft_task = None
########## soft and hard
# hard_task = '(([]<> r3) && ([]<> r4))'
# soft_task = '([]! b)'
##############################
# set planner
robot_planner = ltl_planner(robot_model, hard_task, soft_task)
# synthesis
start = time.time()
robot_planner.optimal(10,'static')
print 'full construction and synthesis done within %.2fs \n' %(time.time()-start)