2023-11-09 08:47:57 +08:00
|
|
|
import py_trees as ptree
|
|
|
|
from typing import Any
|
|
|
|
from robowaiter.behavior_lib._base.Act import Act
|
|
|
|
from robowaiter.behavior_lib._base.Behavior import Status
|
|
|
|
|
2023-11-13 14:53:00 +08:00
|
|
|
class Make(Act):
|
|
|
|
can_be_expanded = True
|
|
|
|
num_args = 1
|
|
|
|
valid_args = (
|
2023-11-13 22:14:55 +08:00
|
|
|
"Coffee","Water","Dessert"
|
2023-11-13 14:53:00 +08:00
|
|
|
)
|
2023-11-09 08:47:57 +08:00
|
|
|
|
|
|
|
def __init__(self, *args):
|
|
|
|
super().__init__(*args)
|
2023-11-13 14:53:00 +08:00
|
|
|
self.target_obj = self.args[0]
|
2023-11-13 23:36:12 +08:00
|
|
|
self.op_type = 1
|
|
|
|
if self.target_obj=="Coffee":
|
|
|
|
self.op_type = 1
|
|
|
|
elif self.target_obj=="Water":
|
|
|
|
self.op_type = 2
|
|
|
|
elif self.target_obj=="Dessert":
|
|
|
|
self.op_type = 3
|
2023-11-13 14:53:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_info(cls,arg):
|
2023-11-13 22:14:55 +08:00
|
|
|
info = {}
|
|
|
|
info["pre"]= {f'Holding(Nothing)'}
|
2023-11-14 12:09:53 +08:00
|
|
|
info['del_set'] = set()
|
2023-11-14 23:16:48 +08:00
|
|
|
info['add'] = {f'Exist({arg})'}
|
2023-11-13 14:53:00 +08:00
|
|
|
if arg == "Coffee":
|
2023-11-14 23:16:48 +08:00
|
|
|
info["add"] |= {f'On(Coffee,CoffeeTable)'}
|
2023-11-13 22:14:55 +08:00
|
|
|
elif arg == "Water":
|
2023-11-14 23:16:48 +08:00
|
|
|
info["add"] |= {f'On(Water,WaterTable)'}
|
2023-11-13 22:14:55 +08:00
|
|
|
elif arg == "Dessert":
|
2023-11-14 23:16:48 +08:00
|
|
|
info["add"] |= {f'On(Dessert,Bar)'}
|
2023-11-13 14:53:00 +08:00
|
|
|
return info
|
2023-11-13 21:52:15 +08:00
|
|
|
|
2023-11-09 08:47:57 +08:00
|
|
|
def _update(self) -> ptree.common.Status:
|
2023-11-13 23:36:12 +08:00
|
|
|
|
|
|
|
self.scene.move_task_area(self.op_type)
|
|
|
|
self.scene.op_task_execute(self.op_type)
|
|
|
|
|
2023-11-14 23:16:48 +08:00
|
|
|
# self.scene.gen_obj(type=40)
|
|
|
|
|
2023-11-13 22:14:55 +08:00
|
|
|
self.scene.state["condition_set"].union(self.info["add"])
|
2023-11-14 12:09:53 +08:00
|
|
|
self.scene.state["condition_set"] -= self.info["del_set"]
|
2023-11-09 08:47:57 +08:00
|
|
|
return Status.RUNNING
|