From 3f1f8d9d06ff26cc96893191d95da9bb3c3c008a Mon Sep 17 00:00:00 2001 From: ChenXL97 <908926798@qq.com> Date: Mon, 13 Nov 2023 10:32:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0AEM=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robowaiter/behavior_lib/act/ExploreEnv.py | 7 ++++++- .../cond/{HasMap.py => EnvExplored.py} | 18 ++++++++++++----- .../behavior_tree/ptml/ptmlTranslator.py | 1 - robowaiter/llm_client/data/test_questions.txt | 2 +- .../llm_client/data_raw/test_questions.csv | 1 + robowaiter/robot/Default.ptml | 7 +++---- robowaiter/robot/bracket_ptml.ptml | 4 +--- robowaiter/robot/robot.py | 2 ++ robowaiter/scene/tasks/AEM.py | 20 +++---------------- run_robowaiter.py | 2 +- sub_task.ptml | 4 ++-- 11 files changed, 33 insertions(+), 35 deletions(-) rename robowaiter/behavior_lib/cond/{HasMap.py => EnvExplored.py} (53%) diff --git a/robowaiter/behavior_lib/act/ExploreEnv.py b/robowaiter/behavior_lib/act/ExploreEnv.py index 17883a8..763fd7c 100644 --- a/robowaiter/behavior_lib/act/ExploreEnv.py +++ b/robowaiter/behavior_lib/act/ExploreEnv.py @@ -8,4 +8,9 @@ class ExploreEnv(Act): super().__init__(*args) def _update(self) -> ptree.common.Status: - return ptree.common.Status.SUCCESS + # explore algorithm + + + self.scene.state["condition_set"].add("EnvExplored()") + + return ptree.common.Status.RUNNING diff --git a/robowaiter/behavior_lib/cond/HasMap.py b/robowaiter/behavior_lib/cond/EnvExplored.py similarity index 53% rename from robowaiter/behavior_lib/cond/HasMap.py rename to robowaiter/behavior_lib/cond/EnvExplored.py index 8f77e74..a42471d 100644 --- a/robowaiter/behavior_lib/cond/HasMap.py +++ b/robowaiter/behavior_lib/cond/EnvExplored.py @@ -2,13 +2,21 @@ import py_trees as ptree from typing import Any from robowaiter.behavior_lib._base.Cond import Cond -class HasMap(Cond): +class EnvExplored(Cond): def __init__(self): super().__init__() def _update(self) -> ptree.common.Status: - # if self.scene.status? - if self.scene.state['map']['2d'] == None: - return ptree.common.Status.FAILURE - else: + arg_str = self.arg_str + + if f'EnvExplored()' not in self.scene.state["condition_set"]: return ptree.common.Status.SUCCESS + else: + return ptree.common.Status.FAILURE + + + # if self.scene.status? + # if self.scene.state['map']['2d'] == None: + # return ptree.common.Status.FAILURE + # else: + # return ptree.common.Status.SUCCESS diff --git a/robowaiter/behavior_tree/ptml/ptmlTranslator.py b/robowaiter/behavior_tree/ptml/ptmlTranslator.py index f39dcf1..188ee8f 100644 --- a/robowaiter/behavior_tree/ptml/ptmlTranslator.py +++ b/robowaiter/behavior_tree/ptml/ptmlTranslator.py @@ -98,7 +98,6 @@ class ptmlTranslator(ptmlListener): # # tag = "cond_" + short_uuid() if node_type == "cond" else "task_" + short_uuid() - print(f'create node: {name}({args})') node = eval(f"{name}({args})") node.set_scene(self.scene) diff --git a/robowaiter/llm_client/data/test_questions.txt b/robowaiter/llm_client/data/test_questions.txt index ae33199..823fa74 100644 --- a/robowaiter/llm_client/data/test_questions.txt +++ b/robowaiter/llm_client/data/test_questions.txt @@ -1 +1 @@ -{"测试VLM:做一杯咖啡": {"Answer": " 测试VLM:做一杯咖啡", "Goal": "{\"At(Coffee,Bar)\"}"}, "测试VLN:前往桌子": {"Answer": "测试VLN:前往桌子", "Goal": "{\"At(Robot,Table)\"}"}} +{"测试VLM:做一杯咖啡": {"Answer": "测试VLM:做一杯咖啡", "Goal": "{\"At(Coffee,Bar)\"}"}, "测试VLN:前往桌子": {"Answer": "测试VLN:前往桌子", "Goal": "{\"At(Robot,Table)\"}"}, "测试AEM": {"Answer": "测试AEM", "Goal": "{\"EnvExplored()\"}"}} diff --git a/robowaiter/llm_client/data_raw/test_questions.csv b/robowaiter/llm_client/data_raw/test_questions.csv index 3eaa9bd..7523658 100644 --- a/robowaiter/llm_client/data_raw/test_questions.csv +++ b/robowaiter/llm_client/data_raw/test_questions.csv @@ -1,3 +1,4 @@ Question,Answer,Goal VLMһ,VLMһ,"{""At(Coffee,Bar)""}" VLNǰ,VLNǰ,"{""At(Robot,Table)""}" +AEM,AEM,"{""EnvExplored()""}" diff --git a/robowaiter/robot/Default.ptml b/robowaiter/robot/Default.ptml index cabe285..38eb1f3 100644 --- a/robowaiter/robot/Default.ptml +++ b/robowaiter/robot/Default.ptml @@ -1,6 +1,6 @@ selector -// selector -// cond HasMap() +// sequence +// cond NeedExplore() // act ExploreEnv() sequence cond Chatting() @@ -8,5 +8,4 @@ selector sequence cond HasSubTask() sequence - act SubTaskPlaceHolder() - cond At(Talb,ea) \ No newline at end of file + act SubTaskPlaceHolder() \ No newline at end of file diff --git a/robowaiter/robot/bracket_ptml.ptml b/robowaiter/robot/bracket_ptml.ptml index ae237e0..03d28f0 100644 --- a/robowaiter/robot/bracket_ptml.ptml +++ b/robowaiter/robot/bracket_ptml.ptml @@ -10,6 +10,4 @@ selector cond HasSubTask() sequence { - act SubTaskPlaceHolder() - -} cond At(Talb,ea)}} \ No newline at end of file + act SubTaskPlaceHolder()}}} \ No newline at end of file diff --git a/robowaiter/robot/robot.py b/robowaiter/robot/robot.py index 1f46560..880d55b 100644 --- a/robowaiter/robot/robot.py +++ b/robowaiter/robot/robot.py @@ -73,6 +73,8 @@ class Robot(object): add={'At(Coffee,Bar)'}, del_set=set(), cost=1), Action(name='MoveTo(Table)', pre={'At(Robot,Bar)'}, add={'At(Robot,Table)'}, del_set=set(), cost=1), + Action(name='ExploreEnv()', pre={'At(Robot,Bar)'}, + add={'EnvExplored()'}, del_set=set(), cost=1), ] return action_list diff --git a/robowaiter/scene/tasks/AEM.py b/robowaiter/scene/tasks/AEM.py index c70bcb0..a0229f6 100644 --- a/robowaiter/scene/tasks/AEM.py +++ b/robowaiter/scene/tasks/AEM.py @@ -8,20 +8,6 @@ from robowaiter.scene.scene import Scene class SceneAEM(Scene): def __init__(self, robot): super().__init__(robot) - - # control.init_world(1, 3) - - def _reset(self): - self.add_object(0, 570, 1600, 85.5) # type与物品编号对应,具体参考README.md - self.add_object(1, 570, 1630, 85.5) - self.add_object(2, 570, 1660, 85.5) - self.add_object(3, 580, 1680, 85.5) - - # todo: 探索并获得语义地图 - print(self.status.objects) # 全部的物品信息,包括名称、位置等,与获得的语义地图进行对比 - - def _run(self): - pass - - def _step(self): - pass \ No newline at end of file + self.event_list = [ + (5, self.create_chat_event("测试AEM")), + ] diff --git a/run_robowaiter.py b/run_robowaiter.py index 8592471..52cbd1a 100644 --- a/run_robowaiter.py +++ b/run_robowaiter.py @@ -1,7 +1,7 @@ import os from robowaiter import Robot, task_map -TASK_NAME = 'VLN' +TASK_NAME = 'AEM' # create robot project_path = "./robowaiter" diff --git a/sub_task.ptml b/sub_task.ptml index 5829971..1b4d81e 100644 --- a/sub_task.ptml +++ b/sub_task.ptml @@ -1,7 +1,7 @@ selector{ -cond At(Robot,Table) +cond EnvExplored() selector{ cond At(Robot,Bar) -act MoveTo(Table) +act ExploreEnv() } }