RoboWaiter/robowaiter/behavior_lib/act/PickUp.py

37 lines
1.1 KiB
Python
Raw Normal View History

2023-11-13 23:36:12 +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
class PickUp(Act):
can_be_expanded = True
num_args = 1
2023-11-14 12:09:53 +08:00
valid_args = Act.all_object
2023-11-13 23:36:12 +08:00
def __init__(self, *args):
super().__init__(*args)
self.target_obj = self.args[0]
@classmethod
2023-11-14 12:09:53 +08:00
def get_info(cls,arg):
2023-11-13 23:36:12 +08:00
info = {}
info["pre"] = {f'At(Robot,{arg})','Holding(Nothing)'}
info["add"] = {f'Holding({arg})'}
2023-11-14 12:09:53 +08:00
info["del_set"] = {f'Holding(Nothing)'}
2023-11-14 23:16:48 +08:00
for place in Act.all_place:
info["del_set"] |= {f'On({arg},{place})'}
2023-11-13 23:36:12 +08:00
return info
def _update(self) -> ptree.common.Status:
# self.scene.test_move()
op_type=16
obj_id = 0
# 遍历场景里的所有物品,根据名字匹配位置最近的 obj-id
self.scene.op_task_execute(op_type, obj_id=obj_id)
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-13 23:36:12 +08:00
return Status.RUNNING