From 5a1d5f60a43438519d0c25096bd8564aaff8b0e1 Mon Sep 17 00:00:00 2001 From: Antiman-cmyk <1519764165@qq.com> Date: Tue, 17 Oct 2023 16:28:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=A8behaviour=5Flib=E4=B8=AD?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E8=8A=82=E7=82=B9=E7=9A=84=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=87=BD=E6=95=B0=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=8F=82?= =?UTF-8?q?=E6=95=B0scene=E7=94=A8=E4=BA=8E=E8=B0=83=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=9Btasks=E4=B8=AD=E7=BB=99=E5=87=BA=E4=BA=86?= =?UTF-8?q?=E8=A6=81=E5=AE=8C=E6=88=90=E7=9A=84=E4=BB=BB=E5=8A=A1demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 110 +++++++++++++++++++++- ptml/CoffeeDelivery.ptml | 2 +- ptml/behaviour_lib/CoffeeCupFound.py | 13 ++- ptml/behaviour_lib/CoffeeCupGrasped.py | 2 +- ptml/behaviour_lib/CoffeeCupPlaced.py | 2 +- ptml/behaviour_lib/DestinationAReached.py | 2 +- ptml/behaviour_lib/FindCoffeeCup.py | 2 +- ptml/behaviour_lib/Grasp.py | 2 +- ptml/behaviour_lib/GraspCoffeeCup.py | 2 +- ptml/behaviour_lib/Istask.py | 2 +- ptml/behaviour_lib/Move.py | 2 +- ptml/behaviour_lib/PlaceCoffeeCup.py | 2 +- ptml/behaviour_lib/ReachDestinationA.py | 2 +- ptml/behaviour_lib/SeqTest.py | 2 +- ptml/behaviour_lib/TestTask.py | 2 +- ptml/behaviour_lib/__init__.py | 0 ptml/ptmlCompiler.py | 4 +- ptml/ptmlLexer.py | 4 +- ptml/ptmlListener.py | 2 +- ptml/ptmlParser.py | 4 +- ptml/ptmlTranslator.py | 20 ++-- ptml/ptml_test.py | 8 +- scene_utils/control.py | 61 +++++++----- tasks/AEM.py | 20 ++++ tasks/Auto_tasks.py | 9 ++ tasks/GQA.py | 10 ++ tasks/Multi_tasks.py | 19 ++++ tasks/VLM.py | 29 ++++++ tasks/VLN.py | 32 +++++++ 29 files changed, 309 insertions(+), 62 deletions(-) create mode 100644 ptml/behaviour_lib/__init__.py create mode 100644 tasks/AEM.py create mode 100644 tasks/Auto_tasks.py create mode 100644 tasks/GQA.py create mode 100644 tasks/Multi_tasks.py create mode 100644 tasks/VLM.py create mode 100644 tasks/VLN.py diff --git a/README.md b/README.md index 796cda2..68975c1 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,112 @@ from scene_utils import control control.init_world(scene_num=1, mapID=3) ``` -当前只有一个咖啡馆场景。加载操作只需要执行一遍,当引擎进入相应场景后,可以用`control.reset()`重置场景。 \ No newline at end of file +当前只有一个咖啡馆场景。加载操作只需要执行一遍,当引擎进入相应场景后,可以用`control.reset()`重置场景。 + +2. 物品类别 + +| ID | Item | +|-----|----------------------| +| 0 | Mug | +| 1 | Banana | +| 2 | Toothpaste | +| 3 | Bread | +| 4 | Softdrink | +| 5 | Yogurt | +| 6 | ADMilk | +| 7 | VacuumCup | +| 8 | Bernachon | +| 9 | BottledDrink | +| 10 | PencilVase | +| 11 | Teacup | +| 12 | Caddy | +| 13 | Dictionary | +| 14 | Cake | +| 15 | Date | +| 16 | Stapler | +| 17 | LunchBox | +| 18 | Bracelet | +| 19 | MilkDrink | +| 20 | CocountWater | +| 21 | Walnut | +| 22 | HamSausage | +| 23 | GlueStick | +| 24 | AdhensiveTape | +| 25 | Calculator | +| 26 | Chess | +| 27 | Orange | +| 28 | Glass | +| 29 | Washbowl | +| 30 | Durian | +| 31 | Gum | +| 32 | Towl | +| 33 | OrangeJuice | +| 34 | Cardcase | +| 35 | RubikCube | +| 36 | StickyNotes | +| 37 | NFCJuice | +| 38 | SpringWater | +| 39 | Apple | +| 40 | Coffee | +| 41 | Gauze | +| 42 | Mangosteen | +| 43 | SesameSeedCake | +| 44 | Glove | +| 45 | Mouse | +| 46 | Kettle | +| 47 | Atomize | +| 48 | Chips | +| 49 | SpongeGourd | +| 50 | Garlic | +| 51 | Potato | +| 52 | Tray | +| 53 | Hemomanometer | +| 54 | TennisBall | +| 55 | ToyDog | +| 56 | ToyBear | +| 57 | TeaTray | +| 58 | Sock | +| 59 | Scarf | +| 60 | ToiletPaper | +| 61 | Milk | +| 62 | Soap | +| 63 | Novel | +| 64 | Watermelon | +| 65 | Tomato | +| 66 | CleansingFoam | +| 67 | CocountMilk | +| 68 | SugarlessGum | +| 69 | MedicalAdhensiveTape | +| 70 | SourMilkDrink | +| 71 | PaperCup | +| 72 | Tissue | +| 73 | YogurtDrink | +| 74 | Newspaper | +| 75 | Box | +| 76 | PaperCupStarbucks | +| 77 | CoffeeMachine | +| 78 | GingerLHand | +| 79 | GingerRHand | +| 80 | Straw | +| 81 | Cake | +| 82 | Tray | +| 83 | Bread | +| 84 | Glass | +| 85 | Door | +| 86 | Mug | +| 87 | Machine | +| 88 | Packaged Coffee | +| 89 | Cube Sugar | +| 90 | Apple | +| 91 | Spoon | +| 92 | Drinks | +| 93 | Drink | +| 94 | Take-Away Cup | +| 95 | Saucer | +| 96 | Trash Bin | +| 97 | Knife | +| 251 | Ginger | +| 252 | Floor | +| 253 | Roof | +| 254 | Wall | +注意:78及以后无法使用add_object方法生成 \ No newline at end of file diff --git a/ptml/CoffeeDelivery.ptml b/ptml/CoffeeDelivery.ptml index 50cd0ed..b21e38b 100644 --- a/ptml/CoffeeDelivery.ptml +++ b/ptml/CoffeeDelivery.ptml @@ -5,7 +5,7 @@ // parallel 2: // act action3(int a, float b) // act action4() - + sequence{ selector{ cond CoffeeCupFound() diff --git a/ptml/behaviour_lib/CoffeeCupFound.py b/ptml/behaviour_lib/CoffeeCupFound.py index b3e6db3..0c73896 100644 --- a/ptml/behaviour_lib/CoffeeCupFound.py +++ b/ptml/behaviour_lib/CoffeeCupFound.py @@ -1,21 +1,20 @@ import py_trees as ptree from typing import Any -class CoffeeCupFound(ptree.behaviour.Behaviour): - def __init__(self, name: str): +class CoffeeCupFound(ptree.behaviour.Behaviour): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: return super().setup(**kwargs) - + def initialise(self) -> None: return super().initialise() - + def update(self) -> ptree.common.Status: - print('Start checking IsChatting...') + print("Start checking IsChatting...") return ptree.common.Status.SUCCESS - + def terminate(self, new_status: ptree.common.Status) -> None: return super().terminate(new_status) - \ No newline at end of file diff --git a/ptml/behaviour_lib/CoffeeCupGrasped.py b/ptml/behaviour_lib/CoffeeCupGrasped.py index f12d12b..9485f40 100644 --- a/ptml/behaviour_lib/CoffeeCupGrasped.py +++ b/ptml/behaviour_lib/CoffeeCupGrasped.py @@ -3,7 +3,7 @@ from typing import Any class CoffeeCupGrasped(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/CoffeeCupPlaced.py b/ptml/behaviour_lib/CoffeeCupPlaced.py index 2b6f2e3..d4cdb35 100644 --- a/ptml/behaviour_lib/CoffeeCupPlaced.py +++ b/ptml/behaviour_lib/CoffeeCupPlaced.py @@ -3,7 +3,7 @@ from typing import Any class CoffeeCupPlaced(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/DestinationAReached.py b/ptml/behaviour_lib/DestinationAReached.py index 48c75df..9092023 100644 --- a/ptml/behaviour_lib/DestinationAReached.py +++ b/ptml/behaviour_lib/DestinationAReached.py @@ -3,7 +3,7 @@ from typing import Any class DestinationAReached(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/FindCoffeeCup.py b/ptml/behaviour_lib/FindCoffeeCup.py index 3504e7f..6781c50 100644 --- a/ptml/behaviour_lib/FindCoffeeCup.py +++ b/ptml/behaviour_lib/FindCoffeeCup.py @@ -3,7 +3,7 @@ from typing import Any class FindCoffeeCup(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/Grasp.py b/ptml/behaviour_lib/Grasp.py index 964aed1..69d42fd 100644 --- a/ptml/behaviour_lib/Grasp.py +++ b/ptml/behaviour_lib/Grasp.py @@ -3,7 +3,7 @@ from typing import Any class Grasp(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/GraspCoffeeCup.py b/ptml/behaviour_lib/GraspCoffeeCup.py index ca97d68..285804e 100644 --- a/ptml/behaviour_lib/GraspCoffeeCup.py +++ b/ptml/behaviour_lib/GraspCoffeeCup.py @@ -3,7 +3,7 @@ from typing import Any class GraspCoffeeCup(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/Istask.py b/ptml/behaviour_lib/Istask.py index 293022b..4a1922c 100644 --- a/ptml/behaviour_lib/Istask.py +++ b/ptml/behaviour_lib/Istask.py @@ -3,7 +3,7 @@ from typing import Any class Istask(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/Move.py b/ptml/behaviour_lib/Move.py index 0e76abd..4922b73 100644 --- a/ptml/behaviour_lib/Move.py +++ b/ptml/behaviour_lib/Move.py @@ -3,7 +3,7 @@ from typing import Any class Move(ptree.behaviour.Behaviour): - def __init__(self, name: str, a, b, c, d): + def __init__(self, name: str, scene, a, b, c, d): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/PlaceCoffeeCup.py b/ptml/behaviour_lib/PlaceCoffeeCup.py index 592837f..7cf0bbd 100644 --- a/ptml/behaviour_lib/PlaceCoffeeCup.py +++ b/ptml/behaviour_lib/PlaceCoffeeCup.py @@ -3,7 +3,7 @@ from typing import Any class PlaceCoffeeCup(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/ReachDestinationA.py b/ptml/behaviour_lib/ReachDestinationA.py index 08134de..18fbe03 100644 --- a/ptml/behaviour_lib/ReachDestinationA.py +++ b/ptml/behaviour_lib/ReachDestinationA.py @@ -3,7 +3,7 @@ from typing import Any class ReachDestinationA(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/SeqTest.py b/ptml/behaviour_lib/SeqTest.py index 4ebca75..e07ab74 100644 --- a/ptml/behaviour_lib/SeqTest.py +++ b/ptml/behaviour_lib/SeqTest.py @@ -3,7 +3,7 @@ from typing import Any class SeqTest(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/TestTask.py b/ptml/behaviour_lib/TestTask.py index 0ee6fbb..c9c53d7 100644 --- a/ptml/behaviour_lib/TestTask.py +++ b/ptml/behaviour_lib/TestTask.py @@ -3,7 +3,7 @@ from typing import Any class TestTask(ptree.behaviour.Behaviour): - def __init__(self, name: str): + def __init__(self, name: str, scene): super().__init__(name) def setup(self, **kwargs: Any) -> None: diff --git a/ptml/behaviour_lib/__init__.py b/ptml/behaviour_lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ptml/ptmlCompiler.py b/ptml/ptmlCompiler.py index 020ee8f..548369d 100644 --- a/ptml/ptmlCompiler.py +++ b/ptml/ptmlCompiler.py @@ -12,7 +12,7 @@ else: from ptmlLexer import ptmlLexer as Lexer -def load(ptml_path: str, behaviour_lib_path: str): +def load(scene, ptml_path: str, behaviour_lib_path: str): """_summary_ Args: @@ -40,7 +40,7 @@ def load(ptml_path: str, behaviour_lib_path: str): tree = parser.root() walker = ParseTreeWalker() - ptml = ptmlTranslator() # listener mode + ptml = ptmlTranslator(scene, behaviour_lib_path) # listener mode walker.walk(ptml, tree) return ptml.bt_root diff --git a/ptml/ptmlLexer.py b/ptml/ptmlLexer.py index 813fde6..5fe957a 100644 --- a/ptml/ptmlLexer.py +++ b/ptml/ptmlLexer.py @@ -1,4 +1,4 @@ -# Generated from ./ptml.g4 by ANTLR 4.13.0 +# Generated from E:/Projects/UE5/HARIX_RDKSim/Plugins/HarixSim/Python/ptml/ptml.g4 by ANTLR 4.13.1 from antlr4 import * from io import StringIO import sys @@ -111,7 +111,7 @@ class ptmlLexer(Lexer): def __init__(self, input=None, output:TextIO = sys.stdout): super().__init__(input, output) - self.checkVersion("4.13.0") + self.checkVersion("4.13.1") self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions = None self._predicates = None diff --git a/ptml/ptmlListener.py b/ptml/ptmlListener.py index 306e4d7..41056b2 100644 --- a/ptml/ptmlListener.py +++ b/ptml/ptmlListener.py @@ -1,4 +1,4 @@ -# Generated from ./ptml.g4 by ANTLR 4.13.0 +# Generated from E:/Projects/UE5/HARIX_RDKSim/Plugins/HarixSim/Python/ptml/ptml.g4 by ANTLR 4.13.1 from antlr4 import * if "." in __name__: from .ptmlParser import ptmlParser diff --git a/ptml/ptmlParser.py b/ptml/ptmlParser.py index f194969..9af021d 100644 --- a/ptml/ptmlParser.py +++ b/ptml/ptmlParser.py @@ -1,4 +1,4 @@ -# Generated from ./ptml.g4 by ANTLR 4.13.0 +# Generated from E:/Projects/UE5/HARIX_RDKSim/Plugins/HarixSim/Python/ptml/ptml.g4 by ANTLR 4.13.1 # encoding: utf-8 from antlr4 import * from io import StringIO @@ -83,7 +83,7 @@ class ptmlParser ( Parser ): def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) - self.checkVersion("4.13.0") + self.checkVersion("4.13.1") self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._predicates = None diff --git a/ptml/ptmlTranslator.py b/ptml/ptmlTranslator.py index 369760a..d0b13b4 100644 --- a/ptml/ptmlTranslator.py +++ b/ptml/ptmlTranslator.py @@ -20,10 +20,12 @@ class ptmlTranslator(ptmlListener): ptmlListener (_type_): _description_ """ - def __init__(self) -> None: + def __init__(self, scene, behaviour_lib_path) -> None: super().__init__() self.bt_root = None self.stack = [] + self.scene = scene + self.behaviour_lib_path = behaviour_lib_path # Enter a parse tree produced by ptmlParser#root. def enterRoot(self, ctx: ptmlParser.RootContext): @@ -91,24 +93,20 @@ class ptmlTranslator(ptmlListener): args = "".join(args) - # dynamic import - if "." in __name__: # in package - behaviour_lib_config = "ptml/behaviour_lib" - else: - behaviour_lib_config = "./behaviour_lib" - import sys - sys.path.append(behaviour_lib_config) + sys.path.append(self.behaviour_lib_path) + exec("from {} import {}".format(name, name)) # tag = "cond_" + short_uuid() if node_type == "cond" else "task_" + short_uuid() - node = None - node = eval("{}('{}', {})".format(name, tag, args)) + + node = eval( + "{}('{}', scene, {})".format(name, tag, args), {"scene": self.scene, **locals()} + ) # connect self.stack[-1].add_child(node) - # print(self.stack) # Exit a parse tree produced by ptmlParser#action_sign. def exitAction_sign(self, ctx: ptmlParser.Action_signContext): diff --git a/ptml/ptml_test.py b/ptml/ptml_test.py index b9c8ea1..ba18089 100644 --- a/ptml/ptml_test.py +++ b/ptml/ptml_test.py @@ -1,6 +1,7 @@ import os import py_trees as ptree +from scene_utils import control from ptmlCompiler import load @@ -10,9 +11,12 @@ if __name__ == '__main__': ptml_path = os.path.join(project_path, 'CoffeeDelivery.ptml') behavior_lib_path = os.path.join(project_path, 'behaviour_lib') + + scene = control.Scene(sceneID=0) # load - bt = load(ptml_path, behavior_lib_path) + scene.load_BT(ptml_path, behavior_lib_path) # ptree.display.render_dot_tree(bt) # build and tick - bt = ptree.trees.BehaviourTree(bt) + scene.BT = ptree.trees.BehaviourTree(scene.BT) # todo: tick this bt + print(scene.BT) \ No newline at end of file diff --git a/scene_utils/control.py b/scene_utils/control.py index ce58029..ad6e52f 100644 --- a/scene_utils/control.py +++ b/scene_utils/control.py @@ -18,6 +18,7 @@ channel = grpc.insecure_channel( stub = GrabSim_pb2_grpc.GrabSimStub(channel) animation_step = [4, 5, 7, 3, 3] +loc_offset = [-700, -1400] def init_world(scene_num, mapID): @@ -25,15 +26,6 @@ def init_world(scene_num, mapID): time.sleep(3) # wait for the map to load -def walker_control_generator(walkerID, autowalk, speed, X, Y, Yaw): - return GrabSim_pb2.WalkerControls.WControl( - id=walkerID, - autowalk=autowalk, - speed=speed, - pose=GrabSim_pb2.Pose(X=X, Y=Y, Yaw=Yaw), - ) - - def image_extract(camera_data): image = camera_data.images[0] return np.frombuffer(image.data, dtype=image.dtype).reshape( @@ -55,10 +47,10 @@ class Scene: collision: str, info: str """ - def __init__(self, sceneID): + def __init__(self, sceneID=0): self.sceneID = sceneID + self.use_offset = True self.BT = None - self.reset() @property def status(self): @@ -67,7 +59,19 @@ class Scene: def reset(self): stub.Reset(GrabSim_pb2.ResetParams(scene=self.sceneID)) - def walk_to(self, X, Y, Yaw, velocity, dis_limit): + def walker_control_generator(self, walkerID, autowalk, speed, X, Y, Yaw): + if self.use_offset: + X, Y = X + loc_offset[0], Y + loc_offset[1] + return GrabSim_pb2.WalkerControls.WControl( + id=walkerID, + autowalk=autowalk, + speed=speed, + pose=GrabSim_pb2.Pose(X=X, Y=Y, Yaw=Yaw), + ) + + def walk_to(self, X, Y, Yaw, velocity=150, dis_limit=100): + if self.use_offset: + X, Y = X + loc_offset[0], Y + loc_offset[1] stub.Do( GrabSim_pb2.Action( scene=self.sceneID, @@ -77,6 +81,8 @@ class Scene: ) def reachable_check(self, X, Y, Yaw): + if self.use_offset: + X, Y = X + loc_offset[0], Y + loc_offset[1] navigation_info = stub.Do( GrabSim_pb2.Action( scene=self.sceneID, @@ -90,6 +96,8 @@ class Scene: return True def add_walker(self, X, Y, Yaw): + if self.use_offset: + X, Y = X + loc_offset[0], Y + loc_offset[1] if self.reachable_check(X, Y, Yaw): stub.AddWalker( GrabSim_pb2.WalkerList( @@ -133,7 +141,9 @@ class Scene: ) ) - def add_object(self, X, Y, Yaw, Z, type): + def add_object(self, type, X, Y, Z, Yaw=0): + if self.use_offset: + X, Y = X + loc_offset[0], Y + loc_offset[1] stub.AddObjects( GrabSim_pb2.ObjectList( objects=[ @@ -173,29 +183,38 @@ class Scene: ) ) - def get_camera_color(self): + def get_camera_color(self, image_only=True): camera_data = stub.Capture( GrabSim_pb2.CameraList( cameras=[GrabSim_pb2.CameraName.Head_Color], scene=self.sceneID ) ) - return image_extract(camera_data) + if image_only: + return image_extract(camera_data) + else: + return camera_data - def get_camera_depth(self): + def get_camera_depth(self, image_only=True): camera_data = stub.Capture( GrabSim_pb2.CameraList( cameras=[GrabSim_pb2.CameraName.Head_Depth], scene=self.sceneID ) ) - return image_extract(camera_data) + if image_only: + return image_extract(camera_data) + else: + return camera_data - def get_camera_segment(self): + def get_camera_segment(self, image_only=True): camera_data = stub.Capture( GrabSim_pb2.CameraList( cameras=[GrabSim_pb2.CameraName.Head_Segment], scene=self.sceneID ) ) - return image_extract(camera_data) + if image_only: + return image_extract(camera_data) + else: + return camera_data def chat_bubble(self, message): stub.ControlRobot( @@ -220,5 +239,5 @@ class Scene: def animation_reset(self): stub.ControlRobot(GrabSim_pb2.ControlInfo(scene=self.sceneID, type=0, action=0)) - def load_BT(self, ptml_path): - self.BT = ptmlCompiler.load(ptml_path, "ptml/behaviour_lib") + def load_BT(self, ptml_path, behaviour_lib_path): + self.BT = ptmlCompiler.load(self, ptml_path, behaviour_lib_path) diff --git a/tasks/AEM.py b/tasks/AEM.py new file mode 100644 index 0000000..18baed8 --- /dev/null +++ b/tasks/AEM.py @@ -0,0 +1,20 @@ +""" +环境主动探索和记忆 +要求输出探索结果(语义地图)对环境重点信息记忆。生成环境的语义拓扑地图,和不少于10个环境物品的识别和位置记忆,可以是图片或者文字或者格式化数据。 +""" + +from scene_utils import control + +# control.init_world(1, 3) + +scene = control.Scene(sceneID=0) + +scene.reset() +scene.add_object(0, 570, 1600, 85.5) # type与物品编号对应,具体参考README.md +scene.add_object(1, 570, 1630, 85.5) +scene.add_object(2, 570, 1660, 85.5) +scene.add_object(3, 580, 1680, 85.5) + +# todo: 探索并获得语义地图 + +print(scene.status.objects) # 全部的物品信息,包括名称、位置等,与获得的语义地图进行对比 diff --git a/tasks/Auto_tasks.py b/tasks/Auto_tasks.py new file mode 100644 index 0000000..f5e1cf9 --- /dev/null +++ b/tasks/Auto_tasks.py @@ -0,0 +1,9 @@ +""" +在特定环境下,机器人发现目标,可自主完成任务 +1. 打扫地面:地面有垃圾,机器人主动扫地、清理地面垃圾 +2. 收拾桌子:桌子上的污渍,机器人主动擦桌子 +3. 摆椅子:椅子不正,机器人主动摆正椅子 +4. 开灯:室内光线暗,机器人主动打开房屋的灯 +""" + +# todo: 通过行为树控制自动任务 diff --git a/tasks/GQA.py b/tasks/GQA.py new file mode 100644 index 0000000..48a0b3c --- /dev/null +++ b/tasks/GQA.py @@ -0,0 +1,10 @@ +""" +具身多轮对话 +点餐(order)的对话,咖啡厅服务员可以为客人(NPC)完成点餐基本对话 +场景对话(GQA)结合场景:询问卫生间、附近娱乐场所(数据来源自主定义) +开始条件:顾客NPC发出点餐指令 +结束条件:顾客NPC发出指令,表示不再需要服务 +""" + +# todo: 使用大模型进行对话,获得指令信息,适时结束对话 +# order = {...} diff --git a/tasks/Multi_tasks.py b/tasks/Multi_tasks.py new file mode 100644 index 0000000..9ac2b94 --- /dev/null +++ b/tasks/Multi_tasks.py @@ -0,0 +1,19 @@ +""" +人提出请求,机器人完成任务 +1. 做咖啡(固定动画):接收到做咖啡指令、走到咖啡机、拿杯子、操作咖啡机、取杯子、送到客人桌子上 +2. 倒水 +3. 夹点心 + +具体描述:设计一套点单规则(如菜单包含咖啡、水、点心等),按照规则拟造随机的订单。在收到订单后,通过大模型让机器人输出合理的备餐计划,并尝试在模拟环境中按照这个规划实现任务。 + +""" + +from scene_utils import control + +# control.init_world(1, 3) + +scene = control.Scene(sceneID=0) + +scene.reset() + +# todo: 接收点单信息,大模型生成任务规划 diff --git a/tasks/VLM.py b/tasks/VLM.py new file mode 100644 index 0000000..d9d2af5 --- /dev/null +++ b/tasks/VLM.py @@ -0,0 +1,29 @@ +""" +视觉语言操作 +机器人根据指令人的指令调节空调,自主探索环境导航到目标点,通过手臂的运动规划能力操作空调,比如开关按钮、调温按钮、显示面板 +""" + +import time +from scene_utils import control + +# control.init_world(1, 3) + +scene = control.Scene(sceneID=0) + +scene.reset() + +# 空调操作 +scene.walk_to(950, 1260, 90) # 没法转向? +# todo: 手臂操作 +time.sleep(5) +scene.walk_to(947, 1900, 0) + +# 物品挪动 +# todo: 视觉导航至目标点,操作手臂至可抓位置 +""" +scene.grasp(1, your_objectID) +""" +# todo: 视觉导航至目标点,找准释放位置 +""" +scene.release(1) +""" diff --git a/tasks/VLN.py b/tasks/VLN.py new file mode 100644 index 0000000..7c58d49 --- /dev/null +++ b/tasks/VLN.py @@ -0,0 +1,32 @@ +""" +视觉语言导航 +识别顾客(NPC)靠近、打招呼、对话、领位导航到适合人数的空闲餐桌 +开始条件:监测到顾客靠近 +结束条件:完成领位,语音:“请问您想喝点什么?”,并等待下一步指令 +""" + +from scene_utils import control + +# control.init_world(1, 3) + +scene = control.Scene(sceneID=0) + +# 实现单顾客领位 +scene.reset() +scene.add_walker(1085, 2630, 220) +scene.control_walker([scene.walker_control_generator(0, False, 100, 755, 1900, 180)]) + +# todo: 监测到顾客靠近,打招呼,对话,识别获取空闲餐桌位置 +# 可以使用scene.chat_bubble(message)函数实现对话 + +""" +scene.walk_to(your_free_table_location) +time.sleep(5) +scene.control_walker([scene.walker_control_generator(your_free_table_location)]) +""" + +reach = True +if reach: + scene.chat_bubble("请问您想喝点什么?") + +print(scene.status.walkers)