From 2b8f0fc4354563534e80beb33e605ae973d1fa79 Mon Sep 17 00:00:00 2001 From: Abdelrhman Bassiouny Date: Fri, 11 Oct 2024 19:31:54 +0200 Subject: [PATCH] [MultiverseTest] added check for if apartment already exists before spawning it again. --- test/test_multiverse.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_multiverse.py b/test/test_multiverse.py index 4026bbb07..a10fbf205 100644 --- a/test/test_multiverse.py +++ b/test/test_multiverse.py @@ -57,7 +57,10 @@ def test_save_and_restore_state(self): milk = self.spawn_milk([1, 1, 0.1]) robot = self.spawn_robot() cup = self.spawn_cup([1, 2, 0.1]) - apartment = Object("apartment", ObjectType.ENVIRONMENT, f"apartment.urdf") + if "apartment" not in self.multiverse.get_object_names(): + apartment = Object("apartment", ObjectType.ENVIRONMENT, f"apartment.urdf") + else: + apartment = self.multiverse.get_object_by_name("apartment") apartment.set_joint_position("cabinet10_drawer1_joint", 0.1) robot.attach(milk) milk.attach(cup) @@ -302,7 +305,10 @@ def step_robot_pose(self, robot, position_step, angle_step, num_steps): orientation_delta=self.multiverse.conf.orientation_tolerance) def test_get_environment_pose(self): - apartment = Object("apartment", ObjectType.ENVIRONMENT, f"apartment.urdf") + if "apartment" not in self.multiverse.get_object_names(): + apartment = Object("apartment", ObjectType.ENVIRONMENT, f"apartment.urdf") + else: + apartment = self.multiverse.get_object_by_name("apartment") pose = apartment.get_pose() self.assertIsInstance(pose, Pose)