From 900ec490e95019bb3c385b86ead9a9195c9fb911 Mon Sep 17 00:00:00 2001 From: ChenXL97 <908926798@qq.com> Date: Tue, 14 Nov 2023 20:08:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=BE=E4=B8=8D=E5=88=B0su?= =?UTF-8?q?b=5Ftask=5Fseq=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robowaiter/behavior_lib/_base/Behavior.py | 9 +- .../obtea/OptimalBTExpansionAlgorithm.py | 2 +- robowaiter/behavior_tree/obtea/tools.py | 2 +- robowaiter/llm_client/ask_llm.py | 6 +- robowaiter/llm_client/data/test_questions.txt | 2 +- .../llm_client/data_raw/test_questions.csv | 2 +- robowaiter/robot/robot.py | 17 +- robowaiter/scene/tasks/VLN.py | 2 +- robowaiter/utils/bt/draw.py | 4 +- run_robowaiter.py | 2 +- sub_task.ptml | 1069 +---------------- .../OptimalBTExpansionAlgorithm.py | 2 +- zoo/opt_bt_expansion/tools.py | 2 +- 13 files changed, 27 insertions(+), 1094 deletions(-) diff --git a/robowaiter/behavior_lib/_base/Behavior.py b/robowaiter/behavior_lib/_base/Behavior.py index f3cb579..e9e84af 100644 --- a/robowaiter/behavior_lib/_base/Behavior.py +++ b/robowaiter/behavior_lib/_base/Behavior.py @@ -36,15 +36,10 @@ class Bahavior(ptree.behaviour.Behaviour): return ins_name def __init__(self,*args): - self.name = Bahavior.get_ins_name(*args) - #get valid args - # self.valid_arg_list = [] - # lines = self.valid_params.strip().splitlines() - # for line in lines: - # self.valid_arg_list.append((x.strip for x in line.split(","))) + ins_name = self.__class__.get_ins_name(*args) self.args = args - super().__init__(self.name) + super().__init__(ins_name) def _update(self) -> ptree.common.Status: print("this is just a _base behavior node.") diff --git a/robowaiter/behavior_tree/obtea/OptimalBTExpansionAlgorithm.py b/robowaiter/behavior_tree/obtea/OptimalBTExpansionAlgorithm.py index fba4325..c0212df 100644 --- a/robowaiter/behavior_tree/obtea/OptimalBTExpansionAlgorithm.py +++ b/robowaiter/behavior_tree/obtea/OptimalBTExpansionAlgorithm.py @@ -187,7 +187,7 @@ class OptBTExpAlgorithm: self.ptml_string += c_set_str elif child.type == 'act': if '(' not in child.content.name: - self.ptml_string += 'act '+child.content.name+"()\n" + self.ptml_string += 'act ' + child.content.name + "()\n" else: self.ptml_string += 'act ' + child.content.name + "\n" elif isinstance(child, ControlBT): diff --git a/robowaiter/behavior_tree/obtea/tools.py b/robowaiter/behavior_tree/obtea/tools.py index 8506b7c..c705ce5 100644 --- a/robowaiter/behavior_tree/obtea/tools.py +++ b/robowaiter/behavior_tree/obtea/tools.py @@ -10,7 +10,7 @@ import time def print_action_data_table(goal,start,actions): data = [] for a in actions: - data.append([a.name ,a.pre ,a.add ,a.del_set ,a.cost]) + data.append([a.name , a.pre , a.add , a.del_set , a.cost]) data.append(["Goal" ,goal ," " ,"Start" ,start]) print(tabulate(data, headers=["Name", "Pre", "Add" ,"Del" ,"Cost"], tablefmt="fancy_grid")) # grid plain simple github fancy_grid diff --git a/robowaiter/llm_client/ask_llm.py b/robowaiter/llm_client/ask_llm.py index 0193af5..d746cd5 100644 --- a/robowaiter/llm_client/ask_llm.py +++ b/robowaiter/llm_client/ask_llm.py @@ -20,8 +20,10 @@ with open(file_path,'r',encoding="utf-8") as f: def ask_llm(question): if question in test_questions_dict: - return test_questions_dict[question] - ans = single_round(question) + ans = test_questions_dict[question] + else: + ans = single_round(question) + print(f"大模型输出: {ans}") return ans diff --git a/robowaiter/llm_client/data/test_questions.txt b/robowaiter/llm_client/data/test_questions.txt index 44b4914..1e62a74 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)\"}"}, "测试VLM:前往桌子2": {"Answer": " 测试VLM:前往桌子2", "Goal": "{\"At(Robot,Table2)\"}"}, "测试AEM": {"Answer": "测试AEM", "Goal": "{\"EnvExplored()\"}"}, "测试VLM:倒一杯水": {"Answer": "测试VLM:倒一杯水", "Goal": "{\"On(Water,WaterTable)\"}"}, "测试VLM:开空调": {"Answer": "测试VLM:开空调", "Goal": "{\"Is(AC,On)\"}"}, "测试VLM:关空调": {"Answer": "测试VLM:关空调", "Goal": "{\"Is(AC,Off)\"}"}, "测试VLM:关大厅灯": {"Answer": "测试VLM:关大厅灯", "Goal": "{\"Is(HallLight,Off)\"}"}, "测试VLM:开大厅灯": {"Answer": "测试VLM:开大厅灯", "Goal": "{\"Is(HallLight,On)\"}"}, "测试VLM:关筒灯": {"Answer": "测试VLM:关筒灯", "Goal": "{\"Is(TubeLight,Off)\"}"}, "测试VLM:开筒灯": {"Answer": "测试VLM:开筒灯", "Goal": "{\"Is(TubeLight,On)\"}"}, "测试VLM:关窗帘": {"Answer": "测试VLM:关窗帘", "Goal": "{\"Is(Curtain,Off)\"}"}, "测试VLM:开窗帘": {"Answer": "测试VLM:开窗帘", "Goal": "{\"Is(Curtain,On)\"}"}, "测试VLM:拖地": {"Answer": "测试VLM:拖地", "Goal": "{\"Is(Floor,Clean)\"}"}, "测试VLM:擦桌子": {"Answer": "测试VLM:擦桌子", "Goal": "{\"Is(Table1,Clean)\"}"}, "测试VLM:整理椅子": {"Answer": "测试VLM:整理椅子", "Goal": "{\"Is(Chairs,Clean)\"}"}, "测试VLM:把冰红茶放到Table2": {"Answer": "测试VLM:把冰红茶放到Table2", "Goal": "{\"On(BottledDrink,Table2)\"}"}} +{"测试VLM:做一杯咖啡": {"Answer": "测试VLM:做一杯咖啡", "Goal": "{\"At(Coffee,Bar)\"}"}, "测试VLN:前往2号桌": {"Answer": " 测试VLN:前往2号桌", "Goal": "{\"At(Robot,Table2)\"}"}, "测试AEM": {"Answer": "测试AEM", "Goal": "{\"EnvExplored()\"}"}, "测试VLM:倒一杯水": {"Answer": "测试VLM:倒一杯水", "Goal": "{\"On(Water,WaterTable)\"}"}, "测试VLM:开空调": {"Answer": "测试VLM:开空调", "Goal": "{\"Is(AC,On)\"}"}, "测试VLM:关空调": {"Answer": "测试VLM:关空调", "Goal": "{\"Is(AC,Off)\"}"}, "测试VLM:关大厅灯": {"Answer": "测试VLM:关大厅灯", "Goal": "{\"Is(HallLight,Off)\"}"}, "测试VLM:开大厅灯": {"Answer": "测试VLM:开大厅灯", "Goal": "{\"Is(HallLight,On)\"}"}, "测试VLM:关筒灯": {"Answer": "测试VLM:关筒灯", "Goal": "{\"Is(TubeLight,Off)\"}"}, "测试VLM:开筒灯": {"Answer": "测试VLM:开筒灯", "Goal": "{\"Is(TubeLight,On)\"}"}, "测试VLM:关窗帘": {"Answer": "测试VLM:关窗帘", "Goal": "{\"Is(Curtain,Off)\"}"}, "测试VLM:开窗帘": {"Answer": "测试VLM:开窗帘", "Goal": "{\"Is(Curtain,On)\"}"}, "测试VLM:拖地": {"Answer": "测试VLM:拖地", "Goal": "{\"Is(Floor,Clean)\"}"}, "测试VLM:擦桌子": {"Answer": "测试VLM:擦桌子", "Goal": "{\"Is(Table1,Clean)\"}"}, "测试VLM:整理椅子": {"Answer": "测试VLM:整理椅子", "Goal": "{\"Is(Chairs,Clean)\"}"}, "测试VLM:把冰红茶放到Table2": {"Answer": "测试VLM:把冰红茶放到Table2", "Goal": "{\"On(BottledDrink,Table2)\"}"}} diff --git a/robowaiter/llm_client/data_raw/test_questions.csv b/robowaiter/llm_client/data_raw/test_questions.csv index 9313d61..ab3243e 100644 --- a/robowaiter/llm_client/data_raw/test_questions.csv +++ b/robowaiter/llm_client/data_raw/test_questions.csv @@ -1,6 +1,6 @@ Question,Answer,Goal VLMһ,VLMһ,"{""At(Coffee,Bar)""}" -VLMǰ2, VLMǰ2,"{""At(Robot,Table2)""}" +VLNǰ2,VLNǰ2,"{""At(Robot,Table2)""}" AEM,AEM,"{""EnvExplored()""}" VLMһˮ,VLMһˮ,"{""On(Water,WaterTable)""}" VLMյ,VLMյ,"{""Is(AC,On)""}" diff --git a/robowaiter/robot/robot.py b/robowaiter/robot/robot.py index ec2dadd..c19f929 100644 --- a/robowaiter/robot/robot.py +++ b/robowaiter/robot/robot.py @@ -32,7 +32,8 @@ class Robot(object): def load_BT(self): self.bt = load_bt_from_ptml(self.scene, self.ptml_path,self.behavior_lib_path) - sub_task_place_holder = find_node_by_name(self.bt.root,"SubTaskPlaceHolder") + sub_task_place_holder = find_node_by_name(self.bt.root,"SubTaskPlaceHolder()") + print(sub_task_place_holder) if sub_task_place_holder: sub_task_seq = sub_task_place_holder.parent sub_task_seq.children.pop() @@ -44,12 +45,13 @@ class Robot(object): def expand_sub_task_tree(self,goal): if self.action_list is None: - self.action_list = self.collect_action_nodes() print("\n--------------------") - print(f"首次运行行为树扩展算法,收集到{len(self.action_list)}个有效动作:") - for a in self.action_list: - if "Turn" in a.name: - print(a.name) + print(f"首次运行行为树扩展算法") + self.action_list = self.collect_action_nodes() + print(f"共收集到{len(self.action_list)}个实例化动作:") + # for a in self.action_list: + # if "Turn" in a.name: + # print(a.name) print("--------------------\n") @@ -85,6 +87,7 @@ class Robot(object): behavior_dict = load_behavior_tree_lib() for cls in behavior_dict["act"].values(): if cls.can_be_expanded: + print(f"可扩展动作:{cls.__name__}, 存在{len(cls.valid_args)}个有效论域组合") if cls.num_args == 0: action_list.append(Action(name=cls.get_ins_name(),**cls.get_info())) if cls.num_args == 1: @@ -94,7 +97,7 @@ class Robot(object): for args in cls.valid_args: action_list.append(Action(name=cls.get_ins_name(*args),**cls.get_info(*args))) - print(action_list) + # print(action_list) # action_list = [ # Action(name='MakeCoffee', pre={'At(Robot,CoffeeMachine)'}, # add={'At(Coffee,Bar)'}, del_set=set(), cost=1), diff --git a/robowaiter/scene/tasks/VLN.py b/robowaiter/scene/tasks/VLN.py index cae79af..3db8533 100644 --- a/robowaiter/scene/tasks/VLN.py +++ b/robowaiter/scene/tasks/VLN.py @@ -22,7 +22,7 @@ class SceneVLN(Scene): super().__init__(robot) # 在这里加入场景中发生的事件, (事件发生的时间,事件函数) self.event_list = [ - (5, self.create_chat_event("测试VLN:前往桌子")), + (5, self.create_chat_event("测试VLN:前往2号桌")), ] def _reset(self): diff --git a/robowaiter/utils/bt/draw.py b/robowaiter/utils/bt/draw.py index 4ab4852..f983e3a 100644 --- a/robowaiter/utils/bt/draw.py +++ b/robowaiter/utils/bt/draw.py @@ -129,7 +129,7 @@ def dot_tree( root_name = str(root.id) node_root = pydot.Node( name=root_name, - label=get_node_label(root.name, root), + label=get_node_label(root.ins_name, root), shape=node_shape, style="filled", fillcolor=node_colour, @@ -319,7 +319,7 @@ def render_dot_tree(root: behaviour.Behaviour, root, visibility_level, collapse_decorators, with_blackboard_variables=with_blackboard_variables, with_qualified_names=with_qualified_names) - filename_wo_extension_to_convert = root.name if name is None else name + filename_wo_extension_to_convert = root.ins_name if name is None else name filename_wo_extension = utilities.get_valid_filename(filename_wo_extension_to_convert) filenames = {} for extension, writer in {"dot": graph.write, "png": graph.write_png, "svg": graph.write_svg}.items(): diff --git a/run_robowaiter.py b/run_robowaiter.py index 1c11b81..8592471 100644 --- a/run_robowaiter.py +++ b/run_robowaiter.py @@ -1,7 +1,7 @@ import os from robowaiter import Robot, task_map -TASK_NAME = 'VLM' +TASK_NAME = 'VLN' # create robot project_path = "./robowaiter" diff --git a/sub_task.ptml b/sub_task.ptml index 2b7fc48..7b7a602 100644 --- a/sub_task.ptml +++ b/sub_task.ptml @@ -1,1071 +1,4 @@ selector{ -cond At(Coffee,Bar) -sequence{ -cond Holding(Coffee) - cond At(Robot,Bar) -act PutDown(Coffee,Bar) -} -sequence{ -cond Holding(Coffee) -act MoveTo(Bar) -} -sequence{ -cond Holding(Nothing) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PickUp(Coffee) -} -sequence{ -cond Holding(Nothing) - cond At(Robot,Coffee) -act PickUp(Coffee) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Water) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Water,CoffeeTable) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Water,Table1) -} -sequence{ -cond Holding(Water) - cond At(Robot,Bar) - cond At(Robot,Coffee) - cond At(Robot,Bar2) -act PutDown(Water,Bar2) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Water,Table3) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table2) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Water,Table2) -} -sequence{ -cond Holding(Water) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Water,Bar) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Softdrink) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Softdrink,CoffeeTable) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Softdrink,Table1) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Bar) - cond At(Robot,Coffee) - cond At(Robot,Bar2) -act PutDown(Softdrink,Bar2) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Softdrink,Table3) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table2) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Softdrink,Table2) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Softdrink,Bar) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Milk) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Milk,CoffeeTable) -} -sequence{ -cond Holding(Milk) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Milk,Table1) -} -sequence{ -cond At(Robot,Coffee) - cond Holding(Milk) - cond At(Robot,Bar2) - cond At(Robot,Bar) -act PutDown(Milk,Bar2) -} -sequence{ -cond Holding(Milk) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Milk,Table3) -} -sequence{ cond At(Robot,Table2) - cond Holding(Milk) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Milk,Table2) -} -sequence{ -cond Holding(Milk) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Milk,Bar) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,CoffeeTable) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Yogurt,CoffeeTable) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Yogurt,Table1) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Coffee) - cond At(Robot,Bar2) - cond At(Robot,Bar) -act PutDown(Yogurt,Bar2) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Yogurt,Table3) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table2) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Yogurt,Table2) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(Yogurt,Bar) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,CoffeeTable) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(MilkDrink,CoffeeTable) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(MilkDrink,Table1) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Coffee) - cond At(Robot,Bar2) - cond At(Robot,Bar) -act PutDown(MilkDrink,Bar2) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(MilkDrink,Table3) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table2) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(MilkDrink,Table2) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(MilkDrink,Bar) -} -sequence{ -cond At(Robot,CoffeeTable) - cond At(Robot,Bar) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,CoffeeTable) -} -sequence{ -cond At(Robot,Bar) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Table1) -} -sequence{ -cond At(Robot,Coffee) - cond Holding(VacuumCup) - cond At(Robot,Bar2) - cond At(Robot,Bar) -act PutDown(VacuumCup,Bar2) -} -sequence{ -cond At(Robot,Bar) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Table3) -} -sequence{ -cond At(Robot,Coffee) - cond At(Robot,Table2) - cond Holding(VacuumCup) - cond At(Robot,Bar) -act PutDown(VacuumCup,Table2) -} -sequence{ -cond At(Robot,Bar) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Bar) -} -sequence{ -cond At(Robot,CoffeeTable) - cond At(Robot,Coffee) - cond Holding(Dessert) - cond At(Robot,Bar) -act PutDown(Dessert,CoffeeTable) -} -sequence{ -cond At(Robot,Coffee) - cond At(Robot,Table1) - cond Holding(Dessert) - cond At(Robot,Bar) -act PutDown(Dessert,Table1) -} -sequence{ -cond At(Robot,Coffee) - cond Holding(Dessert) - cond At(Robot,Bar2) - cond At(Robot,Bar) -act PutDown(Dessert,Bar2) -} -sequence{ -cond At(Robot,Coffee) - cond At(Robot,Table3) - cond Holding(Dessert) - cond At(Robot,Bar) -act PutDown(Dessert,Table3) -} -sequence{ -cond At(Robot,Coffee) - cond At(Robot,Table2) - cond Holding(Dessert) - cond At(Robot,Bar) -act PutDown(Dessert,Table2) -} -sequence{ -cond At(Robot,Coffee) - cond Holding(Dessert) - cond At(Robot,Bar) -act PutDown(Dessert,Bar) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(ADMilk) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(ADMilk,CoffeeTable) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(ADMilk,Table1) -} -sequence{ -cond At(Robot,Coffee) - cond Holding(ADMilk) - cond At(Robot,Bar2) - cond At(Robot,Bar) -act PutDown(ADMilk,Bar2) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(ADMilk,Table3) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table2) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(ADMilk,Table2) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(ADMilk,Bar) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(BottledDrink) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(BottledDrink,CoffeeTable) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table1) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(BottledDrink,Table1) -} -sequence{ -cond At(Robot,Coffee) - cond Holding(BottledDrink) - cond At(Robot,Bar2) - cond At(Robot,Bar) -act PutDown(BottledDrink,Bar2) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table3) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(BottledDrink,Table3) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table2) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(BottledDrink,Table2) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Coffee) - cond At(Robot,Bar) -act PutDown(BottledDrink,Bar) -} -sequence{ -cond Holding(Nothing) -act MoveTo(Coffee) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Water) - cond At(Robot,Coffee) -act PutDown(Water,CoffeeTable) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table1) - cond At(Robot,Coffee) -act PutDown(Water,Table1) -} -sequence{ -cond Holding(Water) - cond At(Robot,Coffee) - cond At(Robot,Bar2) -act PutDown(Water,Bar2) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table3) - cond At(Robot,Coffee) -act PutDown(Water,Table3) -} -sequence{ -cond Holding(Water) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(Water,Table2) -} -sequence{ -cond Holding(Water) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(Water,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Softdrink) - cond At(Robot,Coffee) -act PutDown(Softdrink,CoffeeTable) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table1) - cond At(Robot,Coffee) -act PutDown(Softdrink,Table1) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Coffee) - cond At(Robot,Bar2) -act PutDown(Softdrink,Bar2) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table3) - cond At(Robot,Coffee) -act PutDown(Softdrink,Table3) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(Softdrink,Table2) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(Softdrink,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond At(Robot,Coffee) - cond Holding(Milk) -act PutDown(Milk,CoffeeTable) -} -sequence{ -cond At(Robot,Table1) - cond At(Robot,Coffee) - cond Holding(Milk) -act PutDown(Milk,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond At(Robot,Coffee) - cond Holding(Milk) -act PutDown(Milk,Bar2) -} -sequence{ -cond At(Robot,Table3) - cond At(Robot,Coffee) - cond Holding(Milk) -act PutDown(Milk,Table3) -} -sequence{ -cond At(Robot,Table2) - cond At(Robot,Coffee) - cond Holding(Milk) -act PutDown(Milk,Table2) -} -sequence{ -cond At(Robot,WaterTable) - cond At(Robot,Coffee) - cond Holding(Milk) -act PutDown(Milk,WaterTable) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,CoffeeTable) - cond At(Robot,Coffee) -act PutDown(Yogurt,CoffeeTable) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table1) - cond At(Robot,Coffee) -act PutDown(Yogurt,Table1) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Bar2) - cond At(Robot,Coffee) -act PutDown(Yogurt,Bar2) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table3) - cond At(Robot,Coffee) -act PutDown(Yogurt,Table3) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(Yogurt,Table2) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(Yogurt,WaterTable) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,CoffeeTable) - cond At(Robot,Coffee) -act PutDown(MilkDrink,CoffeeTable) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table1) - cond At(Robot,Coffee) -act PutDown(MilkDrink,Table1) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Bar2) - cond At(Robot,Coffee) -act PutDown(MilkDrink,Bar2) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table3) - cond At(Robot,Coffee) -act PutDown(MilkDrink,Table3) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(MilkDrink,Table2) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(MilkDrink,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,CoffeeTable) -} -sequence{ -cond At(Robot,Table1) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Bar2) -} -sequence{ -cond At(Robot,Table3) - cond At(Robot,Coffee) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Table3) -} -sequence{ -cond Holding(VacuumCup) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(VacuumCup,Table2) -} -sequence{ -cond Holding(VacuumCup) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(VacuumCup,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Dessert) - cond At(Robot,Coffee) -act PutDown(Dessert,CoffeeTable) -} -sequence{ -cond Holding(Dessert) - cond At(Robot,Table1) - cond At(Robot,Coffee) -act PutDown(Dessert,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond Holding(Dessert) - cond At(Robot,Coffee) -act PutDown(Dessert,Bar2) -} -sequence{ -cond Holding(Dessert) - cond At(Robot,Table3) - cond At(Robot,Coffee) -act PutDown(Dessert,Table3) -} -sequence{ -cond Holding(Dessert) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(Dessert,Table2) -} -sequence{ -cond Holding(Dessert) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(Dessert,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(ADMilk) - cond At(Robot,Coffee) -act PutDown(ADMilk,CoffeeTable) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table1) - cond At(Robot,Coffee) -act PutDown(ADMilk,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond Holding(ADMilk) - cond At(Robot,Coffee) -act PutDown(ADMilk,Bar2) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table3) - cond At(Robot,Coffee) -act PutDown(ADMilk,Table3) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(ADMilk,Table2) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(ADMilk,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(BottledDrink) - cond At(Robot,Coffee) -act PutDown(BottledDrink,CoffeeTable) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table1) - cond At(Robot,Coffee) -act PutDown(BottledDrink,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond Holding(BottledDrink) - cond At(Robot,Coffee) -act PutDown(BottledDrink,Bar2) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table3) - cond At(Robot,Coffee) -act PutDown(BottledDrink,Table3) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Coffee) - cond At(Robot,Table2) -act PutDown(BottledDrink,Table2) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Coffee) - cond At(Robot,WaterTable) -act PutDown(BottledDrink,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Water) -act PutDown(Water,CoffeeTable) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table1) -act PutDown(Water,Table1) -} -sequence{ -cond Holding(Water) - cond At(Robot,Bar2) -act PutDown(Water,Bar2) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table3) -act PutDown(Water,Table3) -} -sequence{ -cond Holding(Water) - cond At(Robot,Table2) -act PutDown(Water,Table2) -} -sequence{ -cond Holding(Water) - cond At(Robot,Bar) -act PutDown(Water,Bar) -} -sequence{ -cond Holding(Water) - cond At(Robot,WaterTable) -act PutDown(Water,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Softdrink) -act PutDown(Softdrink,CoffeeTable) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table1) -act PutDown(Softdrink,Table1) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Bar2) -act PutDown(Softdrink,Bar2) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table3) -act PutDown(Softdrink,Table3) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Table2) -act PutDown(Softdrink,Table2) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,Bar) -act PutDown(Softdrink,Bar) -} -sequence{ -cond Holding(Softdrink) - cond At(Robot,WaterTable) -act PutDown(Softdrink,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Milk) -act PutDown(Milk,CoffeeTable) -} -sequence{ -cond At(Robot,Table1) - cond Holding(Milk) -act PutDown(Milk,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond Holding(Milk) -act PutDown(Milk,Bar2) -} -sequence{ -cond At(Robot,Table3) - cond Holding(Milk) -act PutDown(Milk,Table3) -} -sequence{ -cond At(Robot,Table2) - cond Holding(Milk) -act PutDown(Milk,Table2) -} -sequence{ -cond At(Robot,Bar) - cond Holding(Milk) -act PutDown(Milk,Bar) -} -sequence{ -cond At(Robot,WaterTable) - cond Holding(Milk) -act PutDown(Milk,WaterTable) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,CoffeeTable) -act PutDown(Yogurt,CoffeeTable) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table1) -act PutDown(Yogurt,Table1) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Bar2) -act PutDown(Yogurt,Bar2) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table3) -act PutDown(Yogurt,Table3) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Table2) -act PutDown(Yogurt,Table2) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,Bar) -act PutDown(Yogurt,Bar) -} -sequence{ -cond Holding(Yogurt) - cond At(Robot,WaterTable) -act PutDown(Yogurt,WaterTable) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,CoffeeTable) -act PutDown(MilkDrink,CoffeeTable) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table1) -act PutDown(MilkDrink,Table1) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Bar2) -act PutDown(MilkDrink,Bar2) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table3) -act PutDown(MilkDrink,Table3) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Table2) -act PutDown(MilkDrink,Table2) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,Bar) -act PutDown(MilkDrink,Bar) -} -sequence{ -cond Holding(MilkDrink) - cond At(Robot,WaterTable) -act PutDown(MilkDrink,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(VacuumCup) -act PutDown(VacuumCup,CoffeeTable) -} -sequence{ -cond At(Robot,Table1) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Bar2) -} -sequence{ -cond At(Robot,Table3) - cond Holding(VacuumCup) -act PutDown(VacuumCup,Table3) -} -sequence{ -cond Holding(VacuumCup) - cond At(Robot,Table2) -act PutDown(VacuumCup,Table2) -} -sequence{ -cond Holding(VacuumCup) - cond At(Robot,Bar) -act PutDown(VacuumCup,Bar) -} -sequence{ -cond Holding(VacuumCup) - cond At(Robot,WaterTable) -act PutDown(VacuumCup,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(Dessert) -act PutDown(Dessert,CoffeeTable) -} -sequence{ -cond At(Robot,Table1) - cond Holding(Dessert) -act PutDown(Dessert,Table1) -} -sequence{ -cond At(Robot,Bar2) - cond Holding(Dessert) -act PutDown(Dessert,Bar2) -} -sequence{ -cond At(Robot,Table3) - cond Holding(Dessert) -act PutDown(Dessert,Table3) -} -sequence{ -cond Holding(Dessert) - cond At(Robot,Table2) -act PutDown(Dessert,Table2) -} -sequence{ -cond Holding(Dessert) - cond At(Robot,Bar) -act PutDown(Dessert,Bar) -} -sequence{ -cond Holding(Dessert) - cond At(Robot,WaterTable) -act PutDown(Dessert,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(ADMilk) -act PutDown(ADMilk,CoffeeTable) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table1) -act PutDown(ADMilk,Table1) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Bar2) -act PutDown(ADMilk,Bar2) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table3) -act PutDown(ADMilk,Table3) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Table2) -act PutDown(ADMilk,Table2) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,Bar) -act PutDown(ADMilk,Bar) -} -sequence{ -cond Holding(ADMilk) - cond At(Robot,WaterTable) -act PutDown(ADMilk,WaterTable) -} -sequence{ -cond At(Robot,CoffeeTable) - cond Holding(BottledDrink) -act PutDown(BottledDrink,CoffeeTable) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table1) -act PutDown(BottledDrink,Table1) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Bar2) -act PutDown(BottledDrink,Bar2) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table3) -act PutDown(BottledDrink,Table3) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Table2) -act PutDown(BottledDrink,Table2) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,Bar) -act PutDown(BottledDrink,Bar) -} -sequence{ -cond Holding(BottledDrink) - cond At(Robot,WaterTable) -act PutDown(BottledDrink,WaterTable) -} -sequence{ -cond Holding(Water) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(Softdrink) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(Milk) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(Yogurt) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(MilkDrink) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(VacuumCup) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(Dessert) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(ADMilk) -act MoveTo(CoffeeTable) -} -sequence{ -cond Holding(BottledDrink) -act MoveTo(CoffeeTable) -} +act MoveTo(Table2) } diff --git a/zoo/opt_bt_expansion/OptimalBTExpansionAlgorithm.py b/zoo/opt_bt_expansion/OptimalBTExpansionAlgorithm.py index 6ec11d5..b886f8d 100644 --- a/zoo/opt_bt_expansion/OptimalBTExpansionAlgorithm.py +++ b/zoo/opt_bt_expansion/OptimalBTExpansionAlgorithm.py @@ -183,7 +183,7 @@ class OptBTExpAlgorithm: c_set_str = ', '.join(map(str, child.content)) + "\n" self.ptml_string += c_set_str elif child.type == 'act': - self.ptml_string += 'act '+child.content.name+"\n" + self.ptml_string += 'act ' + child.content.name + "\n" elif isinstance(child, ControlBT): if parnode.type == '?': self.ptml_string += "selector{\n" diff --git a/zoo/opt_bt_expansion/tools.py b/zoo/opt_bt_expansion/tools.py index 1af057d..c2e0695 100644 --- a/zoo/opt_bt_expansion/tools.py +++ b/zoo/opt_bt_expansion/tools.py @@ -10,7 +10,7 @@ import time def print_action_data_table(goal,start,actions): data = [] for a in actions: - data.append([a.name ,a.pre ,a.add ,a.del_set ,a.cost]) + data.append([a.name , a.pre , a.add , a.del_set , a.cost]) data.append(["Goal" ,goal ," " ,"Start" ,start]) print(tabulate(data, headers=["Name", "Pre", "Add" ,"Del" ,"Cost"], tablefmt="fancy_grid")) # grid plain simple github fancy_grid