Implementation:Haosulab ManiSkill ActionRepeatWrapper
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, Environment Wrapper |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for repeating the same action for multiple simulation steps within a single environment step, with proper handling of early termination in batched environments.
Description
The ActionRepeatWrapper is a Gymnasium wrapper that repeats a given action for a configurable number of steps. This is useful for frame-skipping in reinforcement learning, where the agent acts at a lower frequency than the simulation.
Key behavior:
repeat=1means no action repeat (standard single step).repeat=Nmeans the action is executed N times perstep()call.- Rewards are accumulated (summed) across repeated steps.
- If an environment becomes done (terminated or truncated) before all repeats are completed, that environment stops receiving further actions. The final observation and info come from the step where the environment became done.
- Uses a
not_donesmask to selectively update only active (non-done) environments across the batch. - Supports both dict and tensor observations.
The _update_dict_values() helper recursively updates nested dictionaries, applying the not_dones mask to only copy data from environments that are still active.
Usage
Wrap a ManiSkill environment when you want the agent to act at a lower frequency than the control frequency. Commonly used with continuous control tasks.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/utils/wrappers/action_repeat.py
Signature
class ActionRepeatWrapper(gym.Wrapper):
def __init__(self, env: BaseEnv, repeat: int): ...
def step(self, action) -> tuple: ...
Import
from mani_skill.utils.wrappers.action_repeat import ActionRepeatWrapper
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| env | BaseEnv | Yes | The ManiSkill environment to wrap |
| repeat | int | Yes | Number of times to repeat each action |
Outputs
| Name | Type | Description |
|---|---|---|
| obs | dict or torch.Tensor | Final observation (from last valid step per env) |
| reward | torch.Tensor | Accumulated reward across all repeats |
| terminated | torch.Tensor | OR of all termination signals |
| truncated | torch.Tensor | OR of all truncation signals |
| info | dict | Info from last valid step per environment |
Usage Examples
Basic Usage
import gymnasium as gym
from mani_skill.utils.wrappers.action_repeat import ActionRepeatWrapper
env = gym.make("PickCube-v1", num_envs=4)
env = ActionRepeatWrapper(env, repeat=3)
obs, info = env.reset()
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
# The action was applied 3 times; reward is the sum of 3 steps