From efe3b583a66e5f76ddc657e7c382c8f6e26bd1f8 Mon Sep 17 00:00:00 2001 From: Abdelrhman Bassiouny Date: Tue, 8 Oct 2024 11:59:27 +0200 Subject: [PATCH 1/4] [MultiverseDev] changed how multiverse is searched for, and changed the way contact points list is printed. --- src/pycram/datastructures/dataclasses.py | 2 +- src/pycram/helper.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pycram/datastructures/dataclasses.py b/src/pycram/datastructures/dataclasses.py index 040189ce3..ddf5d7b21 100644 --- a/src/pycram/datastructures/dataclasses.py +++ b/src/pycram/datastructures/dataclasses.py @@ -603,7 +603,7 @@ def get_objects_that_have_points(self) -> List[Object]: return list({point.link_b.object for point in self}) def __str__(self): - return f"ContactPointsList: {', '.join(self.get_names_of_objects_that_have_points())}" + return f"ContactPointsList: {', '.join([point.__str__() for point in self])}" def __repr__(self): return self.__str__() diff --git a/src/pycram/helper.py b/src/pycram/helper.py index d3c39176e..c184c0c70 100644 --- a/src/pycram/helper.py +++ b/src/pycram/helper.py @@ -100,6 +100,7 @@ def find_multiverse_path() -> Optional[str]: """ # Get the value of PYTHONPATH environment variable pythonpath = os.getenv('PYTHONPATH') + multiverse_relative_path = "Multiverse/multiverse" # Check if PYTHONPATH is set if pythonpath: @@ -108,8 +109,8 @@ def find_multiverse_path() -> Optional[str]: # Iterate through each path and check if 'Multiverse' is in it for path in paths: - if 'multiverse' in path: - multiverse_path = path.split('multiverse')[0] - return multiverse_path + 'multiverse' + if multiverse_relative_path in path: + multiverse_path = path.split(multiverse_relative_path)[0] + return multiverse_path + multiverse_relative_path From 5fb56918ef0b7ed196627b8ac59ce64dd2204029 Mon Sep 17 00:00:00 2001 From: Abdelrhman Bassiouny Date: Wed, 9 Oct 2024 16:14:20 +0200 Subject: [PATCH 2/4] [WorldSyncCIBugFix] increased wait time between sync. --- src/pycram/datastructures/world.py | 5 +++-- test/test_attachment.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pycram/datastructures/world.py b/src/pycram/datastructures/world.py index d9c16e5e9..a7248476b 100644 --- a/src/pycram/datastructures/world.py +++ b/src/pycram/datastructures/world.py @@ -1572,7 +1572,7 @@ class WorldSync(threading.Thread): if reasoning should be done in the prospection world. """ - WAIT_TIME_AS_N_SIMULATION_STEPS = 20 + WAIT_TIME_AS_N_SIMULATION_STEPS = 30 """ The time in simulation steps to wait between each iteration of the syncing loop. """ @@ -1655,7 +1655,8 @@ def add_objects_not_in_prospection_world(self): """ Adds all objects that are in the main world but not in the prospection world to the prospection world. """ - [self.add_object(obj) for obj in self.world.objects if obj not in self.object_to_prospection_object_map] + obj_map_copy = copy(self.object_to_prospection_object_map) + [self.add_object(obj) for obj in self.world.objects if obj not in obj_map_copy.keys()] def add_object(self, obj: Object) -> None: """ diff --git a/test/test_attachment.py b/test/test_attachment.py index a6491eece..bf8487942 100644 --- a/test/test_attachment.py +++ b/test/test_attachment.py @@ -26,12 +26,13 @@ def test_detach_sync_in_prospection_world(self): pass self.milk.detach(self.robot) with UseProspectionWorld(): - self.assertTrue(self.milk not in self.robot.attachments) - self.assertTrue(self.robot not in self.milk.attachments) - prospection_milk = self.world.get_prospection_object_for_object(self.milk) - prospection_robot = self.world.get_prospection_object_for_object(self.robot) - self.assertTrue(prospection_milk not in prospection_robot.attachments) - self.assertTrue(prospection_robot not in prospection_milk.attachments) + pass + self.assertTrue(self.milk not in self.robot.attachments) + self.assertTrue(self.robot not in self.milk.attachments) + prospection_milk = self.world.get_prospection_object_for_object(self.milk) + prospection_robot = self.world.get_prospection_object_for_object(self.robot) + self.assertTrue(prospection_milk not in prospection_robot.attachments) + self.assertTrue(prospection_robot not in prospection_milk.attachments) def test_attachment_behavior(self): self.robot.attach(self.milk) @@ -104,5 +105,3 @@ def test_attaching_to_robot_and_moving(self): new_milk_pos = self.milk.get_position() self.assertEqual(new_milk_pos.x, milk_pos.x + 1) - - From 77ad3fae029d22743cd159bffe3e1d7ccf6eb09d Mon Sep 17 00:00:00 2001 From: Abdelrhman Bassiouny Date: Wed, 9 Oct 2024 16:25:14 +0200 Subject: [PATCH 3/4] [WorldSyncCIBugFix] set wait time between sync to 0. --- src/pycram/datastructures/world.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pycram/datastructures/world.py b/src/pycram/datastructures/world.py index a7248476b..05ba732ab 100644 --- a/src/pycram/datastructures/world.py +++ b/src/pycram/datastructures/world.py @@ -1572,7 +1572,7 @@ class WorldSync(threading.Thread): if reasoning should be done in the prospection world. """ - WAIT_TIME_AS_N_SIMULATION_STEPS = 30 + WAIT_TIME_AS_N_SIMULATION_STEPS = 0 """ The time in simulation steps to wait between each iteration of the syncing loop. """ From f229ac4020e745b38e9800ba56167f1df7ab5956 Mon Sep 17 00:00:00 2001 From: Jonas Dech Date: Fri, 11 Oct 2024 13:36:31 +0200 Subject: [PATCH 4/4] [world] Call world_sync from UseProspectionWorld explictly --- src/pycram/datastructures/world.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/pycram/datastructures/world.py b/src/pycram/datastructures/world.py index 05ba732ab..655ecb343 100644 --- a/src/pycram/datastructures/world.py +++ b/src/pycram/datastructures/world.py @@ -1535,10 +1535,7 @@ class UseProspectionWorld: with UseProspectionWorld(): NavigateAction.Action([[1, 0, 0], [0, 0, 0, 1]]).perform() """ - WAIT_TIME_AS_N_SIMULATION_STEPS: int = 20 - """ - The time in simulation steps to wait before switching to the prospection world - """ + def __init__(self): self.prev_world: Optional[World] = None @@ -1548,12 +1545,12 @@ def __enter__(self): """ This method is called when entering the with block, it will set the current world to the prospection world """ + # Please do not edit this function, it works as it is now! if not World.current_world.is_prospection_world: self.prev_world = World.current_world World.current_world = World.current_world.prospection_world - World.current_world.resume_world_sync() - time.sleep(self.WAIT_TIME_AS_N_SIMULATION_STEPS * World.current_world.simulation_time_step) - World.current_world.pause_world_sync() + # This is also a join statement since it is called from the main thread. + World.current_world.world_sync.sync_worlds() def __exit__(self, *args): """ @@ -1572,7 +1569,7 @@ class WorldSync(threading.Thread): if reasoning should be done in the prospection world. """ - WAIT_TIME_AS_N_SIMULATION_STEPS = 0 + WAIT_TIME_AS_N_SIMULATION_STEPS = 20 """ The time in simulation steps to wait between each iteration of the syncing loop. """