-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRobot.py
78 lines (69 loc) · 2.72 KB
/
Robot.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
# import std_msgs.msg
from unified_planning.shortcuts import Not, And
from AIROB.domain import PDDLObject
from AIROB.domain.decorators import PDDLEffect, PDDLPrecondition, PDDLPredicate, PDDLType, PDDLAction
# import rospy
@PDDLType
class Robot(PDDLObject):
def __init__(self):
super().__init__()
self.free = True
# self.free_sub = rospy.Subscriber("cobotta_free", std_msgs.msg.Bool, self.on_cobotta_free)
# self.pub = rospy.Publisher('pub', std_msgs.msg.String, queue_size=10)
def get_id(self) -> str:
return "Cobotta"
def on_cobotta_free(self, msg):
self.free = msg
@PDDLPredicate()
def free(self: 'Robot'):
return self.free
@PDDLPrecondition(lambda brush, robot:
And(Not(brush.picked()),
Not(brush.hasColor()),
brush.loaded(),
robot.free()))
@PDDLEffect(lambda brush: brush.picked(), True)
@PDDLEffect(lambda robot: robot.free(), False)
@PDDLAction()
def pickUpBrush(robot: 'Robot', brush: 'Brush'):
print(f"Picking up brush {brush.idx}")
brush.setPicked(True)
robot.free = False
# robot.pub.publish(brush.idx)
@PDDLPrecondition(lambda dryer, robot:
And(Not(dryer.picked()),
Not(dryer.turnedOn()),
dryer.loaded(),
robot.free()))
@PDDLEffect(lambda dryer: dryer.picked(), True)
@PDDLEffect(lambda robot: robot.free(), False)
@PDDLAction()
def pickUpDryer(robot: 'Robot', dryer: 'Dryer'):
print(f"Picking up dryer {dryer.idx}")
dryer.setPicked(True)
robot.free = False
@PDDLPrecondition(lambda brush, robot:
And(brush.picked(),
Not(brush.hasColor()),
brush.loaded(),
Not(robot.free())))
@PDDLEffect(lambda brush: brush.picked(), False)
@PDDLEffect(lambda robot: robot.free(), True)
@PDDLAction()
def putDownBrush(robot: 'Robot', brush: 'Brush'):
print(f"Putting down brush {brush.idx}")
brush.setPicked(False)
robot.free = True
@PDDLPrecondition(lambda dryer, robot:
And(
dryer.picked(),
Not(dryer.turnedOn()),
dryer.loaded(),
Not(robot.free())))
@PDDLEffect(lambda dryer: dryer.picked(), False)
@PDDLEffect(lambda robot: robot.free(), True)
@PDDLAction()
def putDownDryer(robot: 'Robot', dryer: 'Dryer'):
print(f"Putting down dryer {dryer.idx}")
dryer.setPicked(False)
robot.free = True