Implementation:ARISE Initiative Robosuite LightingModder
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 lighting properties in MuJoCo simulations provided by the robosuite modding utilities.
Description
LightingModder perturbs light position, direction, specular/ambient/diffuse intensities, and active state. Default direction perturbation of 0.35 radians is ~20 degrees. Inherits from BaseModder.
Usage
Used internally by DomainRandomizationWrapper. Can be used standalone.
Code Reference
Source: robosuite
File: robosuite/utils/mjmod.py
Lines: L62-515
Signature:
class LightingModder(BaseModder):
def __init__(self, sim, random_state=None, light_names=None,
randomize_position=True, randomize_direction=True,
randomize_specular=True, randomize_ambient=True,
randomize_diffuse=True, randomize_active=True,
position_perturbation_size=0.1, direction_perturbation_size=0.35,
specular_perturbation_size=0.1, ambient_perturbation_size=0.1,
diffuse_perturbation_size=0.1):
Import: from robosuite.utils.mjmod import LightingModder
I/O Contract
Inputs:
- sim (required): MuJoCo simulation instance
- random_state (optional): Random state for reproducibility
- light_names (optional): List of light names to randomize
- randomize_position (bool, optional, default=True): Whether to randomize light position
- randomize_direction (bool, optional, default=True): Whether to randomize light direction
- randomize_specular (bool, optional, default=True): Whether to randomize specular intensity
- randomize_ambient (bool, optional, default=True): Whether to randomize ambient intensity
- randomize_diffuse (bool, optional, default=True): Whether to randomize diffuse intensity
- randomize_active (bool, optional, default=True): Whether to randomize active state
- position_perturbation_size (float, optional, default=0.1): Size of position perturbation
- direction_perturbation_size (float, optional, default=0.35): Size of direction perturbation in radians
- specular_perturbation_size (float, optional, default=0.1): Size of specular intensity perturbation
- ambient_perturbation_size (float, optional, default=0.1): Size of ambient intensity perturbation
- diffuse_perturbation_size (float, optional, default=0.1): Size of diffuse intensity perturbation
Methods:
- randomize(): Apply randomization to lighting properties
- save_defaults(): Save current lighting properties as defaults
- restore_defaults(): Restore lighting properties to saved defaults
Usage Examples
LightingModder is typically used via the DomainRandomizationWrapper by providing lighting_randomization_args:
from robosuite.wrappers import DomainRandomizationWrapper
env = DomainRandomizationWrapper(
env,
seed=0,
randomize_lighting=True,
lighting_randomization_args={
'randomize_position': True,
'randomize_direction': True,
'randomize_specular': True,
'randomize_ambient': True,
'randomize_diffuse': True,
'randomize_active': True,
'position_perturbation_size': 0.1,
'direction_perturbation_size': 0.35,
'specular_perturbation_size': 0.1,
'ambient_perturbation_size': 0.1,
'diffuse_perturbation_size': 0.1
}
)
Standalone usage:
from robosuite.utils.mjmod import LightingModder
import numpy as np
# Create modder
random_state = np.random.RandomState(0)
lighting_modder = LightingModder(
sim=env.sim,
random_state=random_state,
randomize_direction=True,
direction_perturbation_size=0.35
)
# Save default lighting
lighting_modder.save_defaults()
# Randomize lighting
lighting_modder.randomize()
# Restore defaults if needed
lighting_modder.restore_defaults()