From 0e8bc182cd32e6d5ad33a37344a7b958677bc9dd Mon Sep 17 00:00:00 2001 From: Hz_Zhang <47402297+HaozheZhang6@users.noreply.github.com> Date: Thu, 9 Jul 2026 10:40:34 -0700 Subject: [PATCH 1/2] Fix Wipe table height drifting across resets --- robosuite/environments/manipulation/wipe.py | 6 +-- .../test_wipe_table_height.py | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 tests/test_environments/test_wipe_table_height.py diff --git a/robosuite/environments/manipulation/wipe.py b/robosuite/environments/manipulation/wipe.py index a4f87c2904..7daa853692 100644 --- a/robosuite/environments/manipulation/wipe.py +++ b/robosuite/environments/manipulation/wipe.py @@ -237,6 +237,7 @@ def __init__( self.table_height_std = self.task_config["table_height_std"] self.delta_height = None # sample variation in height done in load_model self.table_offset = np.array(self.task_config["table_offset"]) + self.base_table_offset = np.array(self.task_config["table_offset"]) self.table_friction = self.task_config["table_friction"] self.table_friction_std = self.task_config["table_friction_std"] self.line_width = self.task_config["line_width"] @@ -534,9 +535,8 @@ def _load_model(self): # Get robot's contact geoms self.robot_contact_geoms = self.robots[0].robot_model.contact_geoms - if self.delta_height is None: - self.delta_height = self.rng.normal(self.table_height, self.table_height_std) - self.table_offset[2] += self.delta_height + self.delta_height = self.rng.normal(self.table_height, self.table_height_std) + self.table_offset[2] = self.base_table_offset[2] + self.delta_height mujoco_arena = WipeArena( table_full_size=self.table_full_size, table_friction=self.table_friction, diff --git a/tests/test_environments/test_wipe_table_height.py b/tests/test_environments/test_wipe_table_height.py new file mode 100644 index 0000000000..71bb55b794 --- /dev/null +++ b/tests/test_environments/test_wipe_table_height.py @@ -0,0 +1,39 @@ +""" +Test that the Wipe environment's randomized table height does not drift across +resets (issue #815). The table z-offset should stay centered on the base height +with per-episode variation, instead of accumulating a fixed delta every reset. +""" +import robosuite as suite +from robosuite.environments.manipulation.wipe import DEFAULT_WIPE_CONFIG + + +def test_wipe_table_height_no_drift(): + config = {k: v for k, v in DEFAULT_WIPE_CONFIG.items()} + config["table_height_std"] = 0.02 + base_z = config["table_offset"][2] + + env = suite.make( + "Wipe", + robots="Panda", + has_renderer=False, + has_offscreen_renderer=False, + use_camera_obs=False, + task_config=config, + ) + try: + heights = [] + for _ in range(6): + env.reset() + heights.append(float(env.table_offset[2])) + finally: + env.close() + + # the height must not accumulate (ramp) across resets + is_monotonic = all(heights[i] < heights[i + 1] for i in range(len(heights) - 1)) + assert not is_monotonic, f"table height drifts across resets: {heights}" + + # it should stay centered on the base height + assert all(abs(h - base_z) < 0.1 for h in heights), heights + + # and vary per episode when a std is set + assert len(set(heights)) > 1, heights From 4abac2864470b1d4a9a10df23572a49c8486e4fd Mon Sep 17 00:00:00 2001 From: Hz_Zhang <47402297+HaozheZhang6@users.noreply.github.com> Date: Sat, 11 Jul 2026 15:15:44 -0700 Subject: [PATCH 2/2] Remove standalone test file per review --- .../test_wipe_table_height.py | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 tests/test_environments/test_wipe_table_height.py diff --git a/tests/test_environments/test_wipe_table_height.py b/tests/test_environments/test_wipe_table_height.py deleted file mode 100644 index 71bb55b794..0000000000 --- a/tests/test_environments/test_wipe_table_height.py +++ /dev/null @@ -1,39 +0,0 @@ -""" -Test that the Wipe environment's randomized table height does not drift across -resets (issue #815). The table z-offset should stay centered on the base height -with per-episode variation, instead of accumulating a fixed delta every reset. -""" -import robosuite as suite -from robosuite.environments.manipulation.wipe import DEFAULT_WIPE_CONFIG - - -def test_wipe_table_height_no_drift(): - config = {k: v for k, v in DEFAULT_WIPE_CONFIG.items()} - config["table_height_std"] = 0.02 - base_z = config["table_offset"][2] - - env = suite.make( - "Wipe", - robots="Panda", - has_renderer=False, - has_offscreen_renderer=False, - use_camera_obs=False, - task_config=config, - ) - try: - heights = [] - for _ in range(6): - env.reset() - heights.append(float(env.table_offset[2])) - finally: - env.close() - - # the height must not accumulate (ramp) across resets - is_monotonic = all(heights[i] < heights[i + 1] for i in range(len(heights) - 1)) - assert not is_monotonic, f"table height drifts across resets: {heights}" - - # it should stay centered on the base height - assert all(abs(h - base_z) < 0.1 for h in heights), heights - - # and vary per episode when a std is set - assert len(set(heights)) > 1, heights