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 Clean(Act):
|
|
|
|
can_be_expanded = True
|
|
|
|
num_args = 1
|
|
|
|
valid_args = (
|
|
|
|
'Table1','Floor','Chairs'
|
|
|
|
)
|
|
|
|
|
|
|
|
def __init__(self, *args):
|
|
|
|
super().__init__(*args)
|
|
|
|
self.target_obj = self.args[0]
|
|
|
|
self.op_type = 5
|
|
|
|
if self.target_obj=="Table1":
|
|
|
|
self.op_type = 5
|
|
|
|
elif self.target_obj=="Floor":
|
|
|
|
self.op_type = 4
|
|
|
|
elif self.target_obj=="Chairs":
|
|
|
|
self.op_type = 7
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_info(cls,arg):
|
|
|
|
info = {}
|
2023-11-16 21:05:54 +08:00
|
|
|
info["pre"]= {f'Holding(Nothing)',f'Is(HallLight,On)'}
|
2023-11-13 23:36:12 +08:00
|
|
|
if arg == "Table1":
|
|
|
|
info["add"]= {f'Is(Table1,Clean)'}
|
2023-11-14 12:09:53 +08:00
|
|
|
info["del_set"] = {f'Is(Table1,Dirty)'}
|
2023-11-13 23:36:12 +08:00
|
|
|
elif arg == "Floor":
|
|
|
|
info["add"] = {f'Is(Floor,Clean)'}
|
2023-11-14 12:09:53 +08:00
|
|
|
info["del_set"] = {f'Is(Floor,Dirty)'}
|
2023-11-13 23:36:12 +08:00
|
|
|
elif arg == "Chairs":
|
|
|
|
info["add"] = {f'Is(Chairs,Clean)'}
|
2023-11-14 12:09:53 +08:00
|
|
|
info["del_set"] = {f'Is(Chairs,Dirty)'}
|
2023-11-13 23:36:12 +08:00
|
|
|
return info
|
|
|
|
|
|
|
|
def _update(self) -> ptree.common.Status:
|
|
|
|
|
|
|
|
self.scene.move_task_area(self.op_type)
|
|
|
|
self.scene.op_task_execute(self.op_type)
|
|
|
|
|
2023-11-15 12:04:49 +08:00
|
|
|
self.scene.state["condition_set"] |= (self.info["add"])
|
2023-11-14 12:09:53 +08:00
|
|
|
self.scene.state["condition_set"] -= self.info["del_set"]
|
2023-11-20 11:12:36 +08:00
|
|
|
self.scene.get_obstacle_point(self.scene.db, self.status, map_ratio=self.scene.map_ratio)
|
2023-11-16 21:05:54 +08:00
|
|
|
|
|
|
|
# print("After Clean condition_set:",self.scene.state["condition_set"] )
|
|
|
|
return Status.RUNNING
|