Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Haosulab ManiSkill ActionRepeatWrapper

From Leeroopedia
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=1 means no action repeat (standard single step).
  • repeat=N means the action is executed N times per step() 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_dones mask 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

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

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment