Implementation:ARISE Initiative Robosuite TextureModder
Metadata:
- robosuite
- Domain Randomization for Sim2Real
- Sim_To_Real_Transfer
- Computer_Vision
- last_updated: 2026-02-15 12:00 GMT
Overview
Concrete class for randomizing textures and material properties in MuJoCo simulations provided by the robosuite modding utilities.
Description
TextureModder modifies geom textures and materials in MuJoCo simulations. It supports four variation types: rgb, checker, noise, and gradient. The class can also randomize the skybox texture for environmental variation.
The class inherits from BaseModder and implements the standard modding interface:
- save_defaults(): Saves original texture and material properties
- restore_defaults(): Restores saved original properties
- randomize(): Applies random texture variations
For full texture effect, materials should be whitened first (setting reflectance to white and shininess/specular to appropriate values) so that applied textures are not tinted by existing material colors.
Usage
TextureModder is used internally by DomainRandomizationWrapper to provide texture randomization as part of the domain randomization pipeline. It can also be used standalone for custom randomization strategies when more fine-grained control over the randomization process is needed.
Code Reference
Source: robosuite
File: robosuite/utils/mjmod.py
Lines: L782-1366
Signature:
class TextureModder(BaseModder):
def __init__(self, sim, random_state=None, geom_names=None, randomize_local=False,
randomize_material=False, local_rgb_interpolation=0.1,
local_material_interpolation=0.2,
texture_variations=("rgb", "checker", "noise", "gradient"),
randomize_skybox=True):
"""
Args:
sim (MjSim): MuJoCo simulation instance
random_state (RandomState): Random state for reproducibility
geom_names (list): List of geom names to randomize (None for all)
randomize_local (bool): Interpolate between original and random colors
randomize_material (bool): Also randomize material properties
local_rgb_interpolation (float): Interpolation weight for local RGB mode
local_material_interpolation (float): Interpolation weight for local material mode
texture_variations (tuple): Types of texture variations to apply
randomize_skybox (bool): Whether to randomize skybox texture
"""
Import:
from robosuite.utils.mjmod import TextureModder
I/O Contract
Inputs
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| sim | MjSim | Yes | N/A | MuJoCo simulation instance to modify |
| random_state | RandomState | No | None | Random state for reproducible randomization |
| geom_names | list | No | None | List of geom names to randomize; if None, all geoms are randomized |
| randomize_local | bool | No | False | If True, interpolate between original and random colors |
| randomize_material | bool | No | False | If True, also randomize material properties |
| local_rgb_interpolation | float | No | 0.1 | Interpolation weight for local RGB mode (0.0 to 1.0) |
| local_material_interpolation | float | No | 0.2 | Interpolation weight for local material mode (0.0 to 1.0) |
| texture_variations | tuple | No | ("rgb", "checker", "noise", "gradient") | Types of texture variations to apply |
| randomize_skybox | bool | No | True | Whether to randomize skybox texture |
Methods
- randomize(): Applies random texture variations to the specified geoms according to the configuration
- save_defaults(): Saves the original texture and material properties before randomization
- restore_defaults(): Restores the saved original properties
Usage Examples
Standalone Usage
import numpy as np
from mujoco_py import MjSim
from robosuite.utils.mjmod import TextureModder
# Create simulation
sim = MjSim(model)
# Create texture modder with specific geoms
texture_modder = TextureModder(
sim=sim,
random_state=np.random.RandomState(42),
geom_names=["table_visual", "cube_visual"],
randomize_local=True,
randomize_material=True,
local_rgb_interpolation=0.2,
texture_variations=("rgb", "checker", "noise")
)
# Save original state
texture_modder.save_defaults()
# Apply randomization
texture_modder.randomize()
# ... run simulation ...
# Restore original textures
texture_modder.restore_defaults()
Usage via DomainRandomizationWrapper
import robosuite as suite
from robosuite.wrappers import DomainRandomizationWrapper
# Create environment
env = suite.make(
"Lift",
robots="Panda",
has_renderer=True,
has_offscreen_renderer=False,
use_camera_obs=False,
)
# Wrap with domain randomization
env = DomainRandomizationWrapper(
env,
seed=123,
randomize_every_n_steps=100,
randomize_texture=True,
texture_randomization_kwargs={
"randomize_local": True,
"randomize_material": True,
"local_rgb_interpolation": 0.15,
"local_material_interpolation": 0.25,
"texture_variations": ("rgb", "checker", "noise", "gradient"),
"randomize_skybox": True,
}
)
# Reset applies texture randomization
env.reset()