Skip to content

Commit d3cc0a0

Browse files
authored
refactor(tasks): mujoco_playground pick/open_cabinet delta control via _process_action (#798)
PandaPickCube and PandaOpenCabinet overrode step() purely for delta position control (delta = action*scale; new = last_action+delta; clamp; latch _last_action). Move that into the sanctioned _process_action hook and drop the step override. Behaviour identical: RLTaskEnv.step calls _process_action (delta+clamp, latch _last_action) then its own clamp + simulate — the same double-clamp the old override+super().step performed, and _last_action is latched to the same value (only read on the next step, so the earlier-in-step latch is observably equal). handover.py is intentionally NOT migrated — its step() also does post-step reward/episode tracking, so it stays in KNOWN_STEP_OVERRIDES pending a parity-checked refactor. Allowlist 22->20; 7/7 guardrail checks pass; ruff clean.
1 parent 29337a6 commit d3cc0a0

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

roboverse_pack/tasks/mujoco_playground/open_cabinet.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,21 @@ def reset(self, states=None, env_ids=None, seed=None):
161161

162162
return super().reset(states=states, env_ids=env_ids, seed=seed)
163163

164-
def step(self, actions):
165-
"""Step with delta control."""
164+
def _process_action(self, actions):
165+
"""Delta position control (sanctioned action hook).
166+
167+
Replaces the old ``step`` override: ``RLTaskEnv.step`` calls
168+
``_process_action`` before clamping/applying, so behaviour is identical
169+
(delta + clamp, latch ``_last_action``) without overriding step.
170+
"""
166171
# mj: delta = action * self._config.action_scale
167172
# mj: ctrl = state.data.ctrl + delta
168173
# mj: ctrl = jp.clip(ctrl, self._lowers, self._uppers)
169174
delta_actions = actions * self._action_scale
170175
new_actions = self._last_action + delta_actions
171176
real_actions = torch.maximum(torch.minimum(new_actions, self._action_high), self._action_low)
172-
obs, reward, terminated, time_out, info = super().step(real_actions)
173177
self._last_action = real_actions
174-
return obs, reward, terminated, time_out, info
178+
return real_actions
175179

176180
def _reward_handle_target(self, env_states) -> torch.Tensor:
177181
"""Reward for bringing handle to target position."""

roboverse_pack/tasks/mujoco_playground/pick.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,18 @@ def reset(self, states=None, env_ids=None, seed=None):
125125
self._last_action[env_ids] = self._initial_states.robots[self.robot_name].joint_pos[env_ids, :]
126126
return super().reset(states=states, env_ids=env_ids, seed=seed)
127127

128-
def step(self, actions):
129-
"""Step with delta control."""
128+
def _process_action(self, actions):
129+
"""Delta position control (sanctioned action hook).
130+
131+
Replaces the old ``step`` override: ``RLTaskEnv.step`` calls
132+
``_process_action`` before clamping/applying, so behaviour is identical
133+
(delta + clamp, latch ``_last_action``) without overriding step.
134+
"""
130135
delta_actions = actions * self._action_scale
131136
new_actions = self._last_action + delta_actions
132137
real_actions = torch.maximum(torch.minimum(new_actions, self._action_high), self._action_low)
133-
obs, reward, terminated, time_out, info = super().step(real_actions)
134138
self._last_action = real_actions
135-
return obs, reward, terminated, time_out, info
139+
return real_actions
136140

137141
def _reward_box_target(self, env_states) -> torch.Tensor:
138142
"""Reward for bringing box to target position and orientation."""

tests/test_task_reset_seed_contract.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373
"humanoid/base/base_legged_robot.py",
7474
"mjlab/cartpole_train.py",
7575
"mujoco_playground/handover.py",
76-
"mujoco_playground/open_cabinet.py",
77-
"mujoco_playground/pick.py",
7876
"pick_place/approach_grasp.py",
7977
"pick_place/approach_grasp_ceramic_teapot.py",
8078
"pick_place/approach_grasp_knife.py",

0 commit comments

Comments
 (0)